config

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

lsp-magik.el (6427B)


      1 ;;; lsp-magik.el --- Language server client for Magik  -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2022 Keronic
      4 
      5 ;; Author: <robin.putters@keronic.com>
      6 ;; Keywords: lsp, magik
      7 
      8 ;; This program is free software; you can redistribute it and/or modify
      9 ;; it under the terms of the GNU General Public License as published by
     10 ;; the Free Software Foundation, either version 3 of the License, or
     11 ;; (at your option) any later version.
     12 
     13 ;; This program is distributed in the hope that it will be useful,
     14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 ;; GNU General Public License for more details.
     17 
     18 ;; You should have received a copy of the GNU General Public License
     19 ;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
     20 
     21 ;;; Commentary:
     22 
     23 ;; LSP client for the Magik programming language
     24 ;; https://github.com/StevenLooman/magik-tools
     25 
     26 ;;; Code:
     27 
     28 (require `lsp-mode)
     29 
     30 (defgroup lsp-magik nil
     31   "LSP support for Magik."
     32   :link '(url-link "https://github.com/StevenLooman/magik-tools")
     33   :group 'lsp-mode
     34   :tag "Lsp Magik"
     35   :package-version '(lsp-mode . "9.0.0"))
     36 
     37 (defcustom lsp-magik-version "0.10.0"
     38   "Version of LSP server."
     39   :type `string
     40   :group `lsp-magik
     41   :package-version '(lsp-mode . "9.0.0"))
     42 
     43 (defcustom lsp-magik-download-url-lsp (format "https://github.com/StevenLooman/magik-tools/releases/download/%s/magik-language-server-%s.jar" lsp-magik-version lsp-magik-version)
     44   "URL of LSP server to download."
     45   :type `string
     46   :group `lsp-magik
     47   :package-version '(lsp-mode . "9.0.0"))
     48 
     49 (lsp-dependency
     50  'magik-ls
     51  `(:download :url lsp-magik-download-url-lsp
     52              :store-path ,(f-join lsp-server-install-dir "magik-ls" (format "magik-language-server-%s.jar" lsp-magik-version))))
     53 
     54 (defcustom lsp-magik-ls-path
     55   (f-join lsp-server-install-dir (format "magik-ls/magik-language-server-%s.jar" lsp-magik-version))
     56   "Path of the language server."
     57   :type 'string
     58   :group `lsp-magik
     59   :package-version '(lsp-mode . "9.0.0"))
     60 
     61 (defcustom lsp-magik-java-home nil
     62   "Path to Java Runtime, Java 17 minimum."
     63   :type `string
     64   :group `lsp-magik
     65   :package-version '(lsp-mode . "9.0.0"))
     66 
     67 (defcustom lsp-magik-product-dirs []
     68   "Paths to (compiled, containing a libs/ directory) products."
     69   :type `lsp-string-vector
     70   :group `lsp-magik
     71   :package-version '(lsp-mode . "9.0.0"))
     72 
     73 (defcustom lsp-magik-lint-override-config-file nil
     74   "Override path to magiklintrc.properties."
     75   :type 'string
     76   :group `lsp-magik
     77   :package-version '(lsp-mode . "9.0.0"))
     78 
     79 (defcustom lsp-magik-typing-type-database-paths []
     80   "Paths to type databases."
     81   :type `lsp-string-vector
     82   :group `lsp-magik
     83   :package-version '(lsp-mode . "9.0.0"))
     84 
     85 (defcustom lsp-magik-typing-show-typing-inlay-hints nil
     86   "Show typing inlay hints."
     87   :type `boolean
     88   :group `lsp-magik
     89   :package-version '(lsp-mode . "9.0.0"))
     90 
     91 (defcustom lsp-magik-typing-show-argument-inlay-hints nil
     92   "Show (certain) argument name inlay hints."
     93   :type `boolean
     94   :group `lsp-magik
     95   :package-version '(lsp-mode . "9.0.0"))
     96 
     97 (defcustom lsp-magik-typing-enable-checks nil
     98   "Enable typing checks."
     99   :type `boolean
    100   :group `lsp-magik
    101   :package-version '(lsp-mode . "9.0.0"))
    102 
    103 (defcustom lsp-magik-typing-index-global-usages t
    104   "Enable indexing of usages of globals by methods."
    105   :type `boolean
    106   :group `lsp-magik
    107   :package-version '(lsp-mode . "9.0.0"))
    108 
    109 (defcustom lsp-magik-typing-index-method-usages nil
    110   "Enable indexing of usages of methods by methods."
    111   :type `boolean
    112   :group `lsp-magik
    113   :package-version '(lsp-mode . "9.0.0"))
    114 
    115 (defcustom lsp-magik-typing-index-slot-usages t
    116   "Enable indexing of usages of slots by methods."
    117   :type `boolean
    118   :group `lsp-magik
    119   :package-version '(lsp-mode . "9.0.0"))
    120 
    121 (defcustom lsp-magik-typing-index-condition-usages t
    122   "Enable indexing of usages of conditions by methods."
    123   :type `boolean
    124   :group `lsp-magik
    125   :package-version '(lsp-mode . "9.0.0"))
    126 
    127 (defcustom lsp-magik-typing-cache-indexed-definitions-method-usages t
    128   "Store and load the indexed definitions in the workspace folders."
    129   :type `boolean
    130   :group `lsp-magik
    131   :package-version '(lsp-mode . "9.0.0"))
    132 
    133 (defcustom lsp-magik-java-path (lambda ()
    134                                  (cond ((eq system-type 'windows-nt)
    135                                         (or (lsp-resolve-value (executable-find (expand-file-name "bin/java" (getenv "JAVA_HOME"))))
    136                                             (lsp-resolve-value (executable-find "java"))))
    137                                        (t "java")))
    138   "Path to Java Runtime, Java 11 minimum."
    139   :type 'string
    140   :group `lsp-magik
    141   :package-version '(lsp-mode . "9.0.0"))
    142 
    143 (lsp-register-client
    144  (make-lsp-client
    145   :download-server-fn (lambda (_client callback error-callback _update?)
    146                         (lsp-package-ensure 'magik-ls callback error-callback))
    147   :new-connection (lsp-stdio-connection
    148                    (lambda ()
    149                      (list
    150                       (substitute-in-file-name (lsp-resolve-value lsp-magik-java-path))
    151                       "-jar"
    152                       (substitute-in-file-name lsp-magik-ls-path)
    153                       "--debug")))
    154   :activation-fn (lsp-activate-on "magik")
    155   :initialized-fn (lambda (workspace)
    156                     (with-lsp-workspace workspace
    157                       (lsp--set-configuration (lsp-configuration-section "magik"))))
    158   :server-id 'magik))
    159 
    160 (lsp-register-custom-settings
    161  `(("magik.javaHome" lsp-magik-java-home)
    162    ("magik.productDirs" lsp-magik-product-dirs)
    163    ("magik.lint.overrideConfigFile" lsp-magik-lint-override-config-file)
    164    ("magik.typing.typeDatabasePaths" lsp-magik-typing-type-database-paths)
    165    ("magik.typing.showTypingInlayHints" lsp-magik-typing-show-typing-inlay-hints)
    166    ("magik.typing.showArgumentInlayHints" lsp-magik-typing-show-argument-inlay-hints)
    167    ("magik.typing.enableChecks" lsp-magik-typing-enable-checks)
    168    ("magik.typing.indexGlobalUsages" lsp-magik-typing-index-global-usages)
    169    ("magik.typing.indexMethodUsages" lsp-magik-typing-index-method-usages)
    170    ("magik.typing.indexSlotUsages" lsp-magik-typing-index-slot-usages)
    171    ("magik.typing.indexConditionUsages" lsp-magik-typing-index-condition-usages)
    172    ("magik.typing.cacheIndexedDefinitions" lsp-magik-typing-cache-indexed-definitions)))
    173 
    174 (lsp-consistency-check lsp-magik)
    175 
    176 (provide 'lsp-magik)
    177 ;;; lsp-magik.el ends here