config

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

lsp-camel.el (2401B)


      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   :group 'lsp-camel
     24   :type 'file
     25   :package-version '(lsp-mode . "9.0.0"))
     26 
     27 (defcustom lsp-camel-jar-download-url
     28   (format "https://repo1.maven.org/maven2/com/github/camel-tooling/camel-lsp-server/%s/%s" lsp-camel-jar-version lsp-camel-jar-name)
     29   "Automatic download url for lsp-camel."
     30   :type 'string
     31   :group 'lsp-camel
     32   :package-version '(lsp-mode . "9.0.0"))
     33 
     34 (lsp-dependency
     35  'camells
     36  '(:system lsp-camel-jar-file)
     37  `(:download :url lsp-camel-jar-download-url
     38              :store-path lsp-camel-jar-file))
     39 
     40 (defcustom lsp-camel-server-command `("java" "-jar" , lsp-camel-jar-file)
     41   "Camel server command."
     42   :type '(repeat string)
     43   :group 'lsp-camel
     44   :package-version '(lsp-mode . "9.0.0"))
     45 
     46 (defun lsp-camel--create-connection ()
     47   (lsp-stdio-connection
     48    (lambda () lsp-camel-server-command)
     49    (lambda () (f-exists? lsp-camel-jar-file))))
     50 
     51 (lsp-register-client
     52  (make-lsp-client :new-connection (lsp-camel--create-connection)
     53                   :activation-fn (lsp-activate-on "xml" "java")
     54                   :priority 0
     55                   :server-id 'camells
     56                   :add-on? t
     57                   :multi-root t
     58                   :initialized-fn (lambda (workspace)
     59                                     (with-lsp-workspace workspace
     60                                       (lsp--set-configuration (lsp-configuration-section "camel"))))
     61                   :download-server-fn (lambda (_client callback error-callback _update?)
     62                                         (lsp-package-ensure 'camells callback error-callback))))
     63 
     64 (lsp-consistency-check lsp-camel)
     65 
     66 (provide 'lsp-camel)
     67 ;;; lsp-camel.el ends here