lsp-haxe.el (6619B)
1 ;;; lsp-haxe.el --- Haxe Client settings -*- lexical-binding: t; -*- 2 3 ;; Copyright (C) 2019 Yannik Böttcher 4 5 ;; Author: Yannik Böttcher <yannikboettcher@outlook.de> 6 ;; Keywords: 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-haxe client 24 25 ;;; Code: 26 27 28 ;; adapted from lsp-clangd configuration 29 (require 'lsp-protocol) 30 (require 'lsp-mode) 31 32 (defgroup lsp-haxe nil 33 "LSP support for Haxe using the language server provided by vshaxe" 34 :group 'lsp-mode 35 :link '(url-link "https://github.com/vshaxe/vshaxe")) 36 37 38 ;; Haxe ls is executed via node 39 (defcustom lsp-clients--haxe-executable "node" 40 "Haxe ls is executed via node." 41 :group 'lsp-haxe 42 :risky t 43 :type 'file) 44 45 ;; The server.js is being passed to node as an argument 46 (defcustom lsp-clients--haxe-server-path (expand-file-name "~/.haxe-language-server/bin/server.js") 47 "The path to the server.js file." 48 :group 'lsp-haxe 49 :risky t 50 :type 'file) 51 52 ;; Build the actual Haxe ls command. 53 (defun lsp-clients--haxe-command () 54 "Haxe ls startup command." 55 `(,lsp-clients--haxe-executable ,lsp-clients--haxe-server-path)) 56 57 ;; https://github.com/yyoncho/lsp-mode/commit/72186e1adc089d772c87ed8f287eb3333b66bfa7 58 ;; This is to force the client to send a didChangeConfiguration Message. Without this, the server won't start, https://github.com/vshaxe/vshaxe/issues/328#issuecomment-471809093 59 (defcustom lsp-clients--haxe-settings (list :haxe.executable "haxe") 60 "Lsp clients configuration settings." 61 :group 'lsp-haxe 62 :risky t 63 :type '(repeat string)) 64 65 ;; The build spec for the project. 66 (defcustom lsp-haxe-hxml "build.hxml" 67 "The compile file for the haxe project." 68 :type 'file 69 :group 'lsp-haxe 70 :package-version '(lsp-mode . "7.0")) 71 72 ;; https://github.com/emacs-lsp/lsp-mode/blob/150a933694349df960dc8fd7a15e04f5727e6433/lsp-rust.el#L251 73 (lsp-defun lsp-clients--haxe-processStart (_workspace (&haxe:ProcessStartNotification :title)) 74 "Handle processStart notification. Just logs PARAMS." 75 (lsp-log title)) 76 77 (defcustom lsp-haxe-executable "haxe" 78 nil 79 :type 'file 80 :group 'lsp-haxe) 81 82 (defcustom lsp-haxe-configurations nil 83 nil 84 :type '(repeat string) 85 :group 'lsp-haxe) 86 87 (defcustom lsp-haxe-display-configurations nil 88 nil 89 :type '(repeat string) 90 :group 'lsp-haxe) 91 92 (defcustom lsp-haxe-display-server nil 93 nil 94 :type 'string 95 :group 'lsp-haxe) 96 97 (defcustom lsp-haxe-display-port "auto" 98 nil 99 :type 'number 100 :group 'lsp-haxe) 101 102 (defcustom lsp-haxe-enable-compilation-server t 103 nil 104 :type 'boolean 105 :group 'lsp-haxe) 106 107 (defcustom lsp-haxe-task-presentation 108 '((echo . t) 109 (reveal . "always") 110 (focus . :json-false) 111 (panel . "shared") 112 (showReuseMessage . t) 113 (clear . :json-false)) 114 nil 115 :type 'plist 116 :group 'lsp-haxe) 117 118 (defcustom lsp-haxe-enable-code-lens t 119 nil 120 :type 'boolean 121 :group 'lsp-haxe) 122 123 (defcustom lsp-haxe-enable-diagnostics t 124 nil 125 :type 'boolean 126 :group 'lsp-haxe) 127 128 (defcustom lsp-haxe-enable-server-view nil 129 nil 130 :type 'boolean 131 :group 'lsp-haxe) 132 133 (defcustom lsp-haxe-enable-methods-view nil 134 nil 135 :type 'boolean 136 :group 'lsp-haxe) 137 138 (defcustom lsp-haxe-enable-signature-help-documentation t 139 nil 140 :type 'boolean 141 :group 'lsp-haxe) 142 143 (defcustom lsp-haxe-diagnostics-path-filter "${workspaceRoot}" 144 nil 145 :type 'string 146 :group 'lsp-haxe) 147 148 (defcustom lsp-haxe-build-completion-cache t 149 nil 150 :type 'boolean 151 :group 'lsp-haxe) 152 153 (defcustom lsp-haxe-enable-completion-cache-warning t 154 nil 155 :type 'boolean 156 :group 'lsp-haxe) 157 158 (defcustom lsp-haxe-code-generation nil 159 nil 160 :type 'string 161 :group 'lsp-haxe) 162 163 (defcustom lsp-haxe-exclude ["zpp_nape"] 164 nil 165 :type '(repeat string) 166 :group 'lsp-haxe) 167 168 (defcustom lsp-haxe-postfix-completion nil 169 nil 170 :type 'string 171 :group 'lsp-haxe) 172 173 (lsp-register-custom-settings 174 '(("haxe.hxml" lsp-haxe-hxml) 175 ("haxe.postfixCompletion" lsp-haxe-postfix-completion) 176 ("haxe.exclude" lsp-haxe-exclude) 177 ("haxe.codeGeneration" lsp-haxe-code-generation) 178 ("haxe.enableCompletionCacheWarning" lsp-haxe-enable-completion-cache-warning t) 179 ("haxe.buildCompletionCache" lsp-haxe-build-completion-cache t) 180 ("haxe.diagnosticsPathFilter" lsp-haxe-diagnostics-path-filter) 181 ("haxe.enableSignatureHelpDocumentation" lsp-haxe-enable-signature-help-documentation t) 182 ("haxe.enableMethodsView" lsp-haxe-enable-methods-view t) 183 ("haxe.enableServerView" lsp-haxe-enable-server-view t) 184 ("haxe.enableDiagnostics" lsp-haxe-enable-diagnostics t) 185 ("haxe.enableCodeLens" lsp-haxe-enable-code-lens t) 186 ("haxe.taskPresentation" lsp-haxe-task-presentation) 187 ("haxe.enableCompilationServer" lsp-haxe-enable-compilation-server t) 188 ("haxe.displayPort" lsp-haxe-display-port) 189 ("haxe.displayServer" lsp-haxe-display-server) 190 ("haxe.displayConfigurations" lsp-haxe-display-configurations) 191 ("haxe.configurations" lsp-haxe-configurations) 192 ("haxe.executable" lsp-haxe-executable))) 193 194 (lsp-register-client 195 (make-lsp-client 196 :new-connection (lsp-stdio-connection #'lsp-clients--haxe-command) 197 :major-modes '(haxe-mode) ; force didChangeConfiguration message 198 :initialized-fn 199 (lambda (workspace) 200 (with-lsp-workspace workspace 201 (lsp--set-configuration (lsp-configuration-section "haxe")))) 202 :priority -1 203 :server-id 'haxe 204 :initialization-options 205 (lambda () 206 `(:sendMethodResults t 207 :haxelibConfig (:executable "haxelib") 208 :displayServerConfig 209 ( :print (:reusing :json-false :completion :json-false) 210 :arguments [] 211 :env nil 212 :path "haxe") 213 :displayArguments [,lsp-haxe-hxml])) 214 :notification-handlers 215 (lsp-ht ("haxe/progressStart" 'lsp-clients--haxe-processStart) 216 ("haxe/progressStop" 'ignore) 217 ("haxe/didDetectOldPreview" 'ignore) 218 ("haxe/didChangeDisplayPort" 'ignore) 219 ("haxe/didRunHaxeMethod" 'ignore) 220 ("haxe/didChangeRequestQueue" 'ignore) 221 ("haxe/cacheBuildFailed" 'ignore)))) 222 223 (lsp-consistency-check lsp-haxe) 224 225 (provide 'lsp-haxe) 226 ;;; lsp-haxe.el ends here