lsp-magik.el (6103B)
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.1" 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 (lsp-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 :lsp-path "magik.javaHome") 67 68 (lsp-defcustom lsp-magik-product-dirs [] 69 "Paths to (compiled, containing a libs/ directory) products." 70 :type `lsp-string-vector 71 :group `lsp-magik 72 :package-version '(lsp-mode . "9.0.1") 73 :lsp-path "magik.productDirs") 74 75 (lsp-defcustom lsp-magik-lint-override-config-file nil 76 "Override path to magiklintrc.properties." 77 :type 'string 78 :group `lsp-magik 79 :package-version '(lsp-mode . "9.0.0") 80 :lsp-path "magik.lint.overrideConfigFile") 81 82 (lsp-defcustom lsp-magik-typing-type-database-paths [] 83 "Paths to type databases." 84 :type `lsp-string-vector 85 :group `lsp-magik 86 :package-version '(lsp-mode . "9.0.0") 87 :lsp-path "magik.typing.typeDatabasePaths") 88 89 (lsp-defcustom lsp-magik-typing-show-typing-inlay-hints nil 90 "Show typing inlay hints." 91 :type `boolean 92 :group `lsp-magik 93 :package-version '(lsp-mode . "9.0.1") 94 :lsp-path "magik.typing.showTypingInlayHints") 95 96 (lsp-defcustom lsp-magik-typing-show-argument-inlay-hints nil 97 "Show (certain) argument name inlay hints." 98 :type `boolean 99 :group `lsp-magik 100 :package-version '(lsp-mode . "9.0.1") 101 :lsp-path "magik.typing.showArgumentInlayHints") 102 103 (lsp-defcustom lsp-magik-typing-enable-checks nil 104 "Enable typing checks." 105 :type `boolean 106 :group `lsp-magik 107 :package-version '(lsp-mode . "9.0.0") 108 :lsp-path "magik.typing.enableChecks") 109 110 (lsp-defcustom lsp-magik-typing-index-global-usages t 111 "Enable indexing of usages of globals by methods." 112 :type `boolean 113 :group `lsp-magik 114 :package-version '(lsp-mode . "9.0.1") 115 :lsp-path "magik.typing.indexGlobalUsages") 116 117 (lsp-defcustom lsp-magik-typing-index-method-usages nil 118 "Enable indexing of usages of methods by methods." 119 :type `boolean 120 :group `lsp-magik 121 :package-version '(lsp-mode . "9.0.1") 122 :lsp-path "magik.typing.indexMethodUsages") 123 124 (lsp-defcustom lsp-magik-typing-index-slot-usages t 125 "Enable indexing of usages of slots by methods." 126 :type `boolean 127 :group `lsp-magik 128 :package-version '(lsp-mode . "9.0.1") 129 :lsp-path "magik.typing.indexSlotUsages") 130 131 (lsp-defcustom lsp-magik-typing-index-condition-usages t 132 "Enable indexing of usages of conditions by methods." 133 :type `boolean 134 :group `lsp-magik 135 :package-version '(lsp-mode . "9.0.1") 136 :lsp-path "magik.typing.indexConditionUsages") 137 138 (lsp-defcustom lsp-magik-typing-cache-indexed-definitions-method-usages t 139 "Store and load the indexed definitions in the workspace folders." 140 :type `boolean 141 :group `lsp-magik 142 :package-version '(lsp-mode . "9.0.1") 143 :lsp-path "magik.typing.cacheIndexedDefinitions") 144 145 (defcustom lsp-magik-java-path (lambda () 146 (cond ((eq system-type 'windows-nt) 147 (or (lsp-resolve-value (executable-find (expand-file-name "bin/java" (getenv "JAVA_HOME")))) 148 (lsp-resolve-value (executable-find "java")))) 149 (t "java"))) 150 "Path to Java Runtime, Java 11 minimum." 151 :type 'string 152 :group `lsp-magik 153 :package-version '(lsp-mode . "9.0.1")) 154 155 (lsp-register-client 156 (make-lsp-client 157 :download-server-fn (lambda (_client callback error-callback _update?) 158 (lsp-package-ensure 'magik-ls callback error-callback)) 159 :new-connection (lsp-stdio-connection 160 (lambda () 161 (list 162 (substitute-in-file-name (lsp-resolve-value lsp-magik-java-path)) 163 "-jar" 164 (substitute-in-file-name lsp-magik-ls-path) 165 "--debug"))) 166 :activation-fn (lsp-activate-on "magik") 167 :initialized-fn (lambda (workspace) 168 (with-lsp-workspace workspace 169 (lsp--set-configuration (lsp-configuration-section "magik")))) 170 :server-id 'magik)) 171 172 (lsp-consistency-check lsp-magik) 173 174 (provide 'lsp-magik) 175 ;;; lsp-magik.el ends here