config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

lsp-pls.el (4280B)


      1 ;;; lsp-pls.el --- PLS Integration for lsp-mode -*- lexical-binding: t -*-
      2 
      3 ;; Copyright (C) 2022 Alexander Adolf
      4 
      5 ;; Author: Alexander Adolf <alexander.adolf@condition-alpha.com>
      6 ;; Maintainer: Alexander Adolf <alexander.adolf@condition-alpha.com>
      7 ;; Package-Requires: (lsp-mode)
      8 ;; Keywords: perl, lsp
      9 
     10 ;; This file is not part of GNU Emacs
     11 
     12 ;; This program is free software: you can redistribute it and/or modify
     13 ;; it under the terms of the GNU General Public License as published by
     14 ;; the Free Software Foundation, either version 3 of the License, or
     15 ;; (at your option) any later version.
     16 
     17 ;; This program is distributed in the hope that it will be useful,
     18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
     19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     20 ;; GNU General Public License for more details.
     21 
     22 ;; You should have received a copy of the GNU General Public License
     23 ;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
     24 
     25 ;;; Commentary:
     26 
     27 ;; PLS client
     28 ;; https://metacpan.org/pod/PLS
     29 
     30 ;;; Code:
     31 
     32 (require 'lsp-mode)
     33 
     34 (defgroup lsp-pls nil
     35   "LSP Mode support for PLS, the Perl Language Server."
     36   :group 'lsp-mode
     37   :link '(url-link "https://metacpan.org/pod/PLS")
     38   :package-version '(lsp-mode . "9.0.0"))
     39 
     40 (defcustom lsp-pls-executable "pls"
     41   "Full path to the PLS executable."
     42   :type '(string)
     43   :group 'lsp-pls
     44   :package-version '(lsp-mode . "9.0.0"))
     45 
     46 (defcustom lsp-pls-arguments nil
     47   "Additional arguments needed to execute PLS."
     48   :type '(repeat 'string)
     49   :group 'lsp-pls
     50   :package-version '(lsp-mode . "9.0.0"))
     51 
     52 (defcustom lsp-pls-working-dir nil
     53   "Working directory to run PLS in.
     54 Defaults to the workspace root when not configured."
     55   :type '(string)
     56   :group 'lsp-pls
     57   :package-version '(lsp-mode . "9.0.0"))
     58 
     59 (defcustom lsp-pls-include nil
     60   "Paths to be added to your @INC."
     61   :type '(repeat 'string)
     62   :group 'lsp-pls
     63   :package-version '(lsp-mode . "9.0.0"))
     64 
     65 (defcustom lsp-pls-perltidy-rc nil
     66   "Path to your .perltidyrc file.
     67 Default is \"~/.perltidyrc\" when not configured."
     68   :type '(string)
     69   :group 'lsp-pls
     70   :package-version '(lsp-mode . "9.0.0"))
     71 
     72 (defcustom lsp-pls-perlcritic-rc nil
     73   "Path to your .perlcriticrc file.
     74 Default is \"~/.perlcriticrc\" when not configured."
     75   :type '(string)
     76   :group 'lsp-pls
     77   :package-version '(lsp-mode . "9.0.0"))
     78 
     79 (defcustom lsp-pls-perlcritic-enabled t
     80   "Enable perlcritic checking."
     81   :type '(boolean)
     82   :group 'lsp-pls
     83   :package-version '(lsp-mode . "9.0.0"))
     84 
     85 (defcustom lsp-pls-syntax-enabled t
     86   "Enable syntax checking."
     87   :type '(boolean)
     88   :group 'lsp-pls
     89   :package-version '(lsp-mode . "9.0.0"))
     90 
     91 (defcustom lsp-pls-syntax-perl nil
     92   "Full path to an alternate perl used for syntax checking.
     93 By default, the perl used to run PLS will be used."
     94   :type '(string)
     95   :group 'lsp-pls
     96   :package-version '(lsp-mode . "9.0.0"))
     97 
     98 (defcustom lsp-pls-syntax-args nil
     99   "Additional arguments to pass to Perl when syntax checking.
    100 This is useful if there is a BEGIN block in your code that
    101 changes behavior depending on the contents of @ARGV."
    102   :type '(repeat 'string)
    103   :group 'lsp-pls
    104   :package-version '(lsp-mode . "9.0.0"))
    105 
    106 (lsp-register-custom-settings
    107  '(("pls.cmd"                      lsp-pls-executable)
    108    ("pls.args"                     lsp-pls-arguments)
    109    ("pls.cwd"                      lsp-pls-working-dir)
    110    ("pls.inc"                      lsp-pls-include)
    111    ("pls.perltidy.perltidyrc"      lsp-pls-perltidy-rc)
    112    ("pls.perlcritic.perlcriticrc"  lsp-pls-perlcritic-rc)
    113    ("pls.perlcritic.enabled"       lsp-pls-perlcritic-enabled)
    114    ("pls.syntax.enabled"           lsp-pls-syntax-enabled)
    115    ("pls.syntax.perl"              lsp-pls-syntax-perl)
    116    ("pls.syntax.args"              lsp-pls-syntax-args)))
    117 
    118 (lsp-register-client
    119  (make-lsp-client
    120   :new-connection (lsp-stdio-connection
    121                    (lambda () (cons lsp-pls-executable lsp-pls-arguments)))
    122   :activation-fn (lsp-activate-on "perl")
    123   :initialized-fn (lambda (workspace)
    124                     (with-lsp-workspace workspace
    125                       (lsp--set-configuration
    126                        (lsp-configuration-section "pls"))))
    127   :priority -1
    128   :server-id 'pls))
    129 
    130 ;; (lsp-consistency-check lsp-pls)
    131 
    132 (provide 'lsp-pls)
    133 ;;; lsp-pls.el ends here