lsp-camel.el (2221B)
1 ;;; lsp-camel.el --- LSP Camel server integration -*- lexical-binding: t; -*- 2 3 4 ;;; Code: 5 6 (require 'lsp-mode) 7 8 (defgroup lsp-camel nil 9 "LSP support for Camel, using camel-language-server" 10 :group 'lsp-mode 11 :tag "Language Server" 12 :package-version '(lsp-mode . "9.0.0")) 13 14 ;; Define a variable to store camel language server jar version 15 (defconst lsp-camel-jar-version "1.5.0") 16 17 ;; Define a variable to store camel language server jar name 18 (defconst lsp-camel-jar-name (format "camel-lsp-server-%s.jar" lsp-camel-jar-version)) 19 20 ;; Directory in which the servers will be installed. Lsp Server Install Dir: ~/.emacs.d/.cache/camells 21 (defcustom lsp-camel-jar-file (f-join lsp-server-install-dir "camells" lsp-camel-jar-name) 22 "Camel Language server jar command." 23 :type 'string 24 :group 'lsp-camel 25 :type 'file 26 :package-version '(lsp-mode . "9.0.0")) 27 28 (defcustom lsp-camel-jar-download-url 29 (format "https://repo1.maven.org/maven2/com/github/camel-tooling/camel-lsp-server/%s/%s" lsp-camel-jar-version lsp-camel-jar-name) 30 "Automatic download url for lsp-camel." 31 :type 'string 32 :group 'lsp-camel 33 :package-version '(lsp-mode . "9.0.0")) 34 35 (lsp-dependency 36 'camells 37 '(:system lsp-camel-jar-file) 38 `(:download :url lsp-camel-jar-download-url 39 :store-path lsp-camel-jar-file)) 40 41 (defcustom lsp-camel-server-command `("java" "-jar" , lsp-camel-jar-file) 42 "Camel server command." 43 :type '(repeat string) 44 :group 'lsp-camel 45 :package-version '(lsp-mode . "9.0.0")) 46 47 (defun lsp-camel--create-connection () 48 (lsp-stdio-connection 49 (lambda () lsp-camel-server-command) 50 (lambda () (f-exists? lsp-camel-jar-file)))) 51 52 (lsp-register-client 53 (make-lsp-client :new-connection (lsp-camel--create-connection) 54 :activation-fn (lsp-activate-on "xml" "java") 55 :priority 0 56 :server-id 'camells 57 :add-on? t 58 :multi-root t 59 :initialized-fn (lambda (workspace) 60 (with-lsp-workspace workspace 61 (lsp--set-configuration (lsp-configuration-section "camel")))) 62 :download-server-fn (lambda (_client callback error-callback _update?) 63 (lsp-package-ensure 'camells callback error-callback)))) 64 65 (lsp-consistency-check lsp-camel) 66 67 (provide 'lsp-camel) 68 ;;; lsp-camel.el ends here