Integrate jerboa-lsp as default LSP server for all .ss/.sls files
ober
97f7ee4296becf38ca786a7826c675aec6b525b8
--- a/lib/jerboa-emacs/qt/commands-lsp.sls +++ b/lib/jerboa-emacs/qt/commands-lsp.sls @@ -81,32 +81,36 @@ (define *marker-lsp-info*--cell (vector 10)) (define *marker-lsp-hint*--cell (vector 11)) (def (lsp-maybe-auto-start! app buf) - "Auto-start LSP when opening a Gerbil/Scheme file if not running." + "Auto-start LSP when opening a Scheme file if not running." (when (and (not (lsp-running?)) (not *lsp-initializing*) (buffer-file-path buf)) (let ([path (buffer-file-path buf)]) (when (and path (let ([ext (path-extension path)]) - (or (string=? ext ".ss") (string=? ext ".scm")))) + (or (string=? ext ".ss") + (string=? ext ".sls") + (string=? ext ".scm")))) (let ([root (lsp-find-project-root path)]) (when root (echo-message! (app-state-echo app) - "LSP: starting gerbil-lsp...") + "LSP: starting jerboa-lsp...") (if (lsp-start! root) (echo-message! (app-state-echo app) "LSP: initializing...") (echo-error! (app-state-echo app) - "LSP: failed to start gerbil-lsp")))))))) + "LSP: failed to start jerboa-lsp")))))))) (def (lsp-find-project-root path) - "Walk up from PATH to find a directory containing gerbil.pkg or .git." + "Walk up from PATH to find a directory containing a project marker." (let loop ([dir (path-directory (path-expand path))]) (cond [(or (string=? dir "/") (string=? dir "")) #f] - [(or (file-exists? (path-expand "gerbil.pkg" dir)) + [(or (file-exists? (path-expand "jerboa.pkg" dir)) + (file-exists? (path-expand ".jerboa-lsp.json" dir)) + (file-exists? (path-expand "gerbil.pkg" dir)) (file-exists? (path-expand ".git" dir))) dir] [else @@ -1655,7 +1659,7 @@ (lsp-ensure-diagnostic-margin! ed)) (echo-message! (app-state-echo app) - "LSP: starting gerbil-lsp...")) + "LSP: starting jerboa-lsp...")) (echo-error! (app-state-echo app) "LSP: no project root found"))))) --- a/src/jerboa-emacs/core.ss +++ b/src/jerboa-emacs/core.ss @@ -295,8 +295,10 @@ (def *ctrl-c-map* (make-keymap)) (def *ctrl-c-l-map* (make-keymap)) (def *ctrl-c-m-map* (make-keymap)) -(def *lsp-server-command* "gerbil-lsp") ;; overridable via ~/.jemacs-init -(defvar! 'lsp-server-command "gerbil-lsp" "Command to launch the LSP server" +(def *lsp-server-command* + (let ((home (or (getenv "HOME") ""))) + (string-append home "/mine/jerboa-lsp/scripts/jerboa-lsp"))) +(defvar! 'lsp-server-command *lsp-server-command* "Command to launch the LSP server" setter: (lambda (v) (set! *lsp-server-command* v)) type: 'string group: 'lsp) (def *meta-g-map* (make-keymap)) --- a/src/jerboa-emacs/persist.ss +++ b/src/jerboa-emacs/persist.ss @@ -851,7 +851,7 @@ (when (and n (> n 0) (<= n 2000)) (custom-set! 'chord-timeout n)))) ;; LSP server command: lsp-server-command PATH - ;; e.g. "lsp-server-command /home/user/gerbil-lsp/.gerbil/bin/gerbil-lsp" + ;; e.g. "lsp-server-command /home/user/mine/jerboa-lsp/scripts/jerboa-lsp" ((string=? key "lsp-server-command") (when (> (string-length val) 0) (custom-set! 'lsp-server-command val))) --- a/src/jerboa-emacs/qt/commands-lsp.ss +++ b/src/jerboa-emacs/qt/commands-lsp.ss @@ -63,28 +63,31 @@ ;;;============================================================================ (def (lsp-maybe-auto-start! app buf) - "Auto-start LSP when opening a Gerbil/Scheme file if not running." + "Auto-start LSP when opening a Scheme file if not running." (when (and (not (lsp-running?)) (not *lsp-initializing*) (buffer-file-path buf)) (let ((path (buffer-file-path buf))) (when (and path (let ((ext (path-extension path))) - (or (string=? ext ".ss") (string=? ext ".scm")))) + (or (string=? ext ".ss") (string=? ext ".sls") + (string=? ext ".scm")))) (let ((root (lsp-find-project-root path))) (when root - (echo-message! (app-state-echo app) "LSP: starting gerbil-lsp...") + (echo-message! (app-state-echo app) "LSP: starting jerboa-lsp...") (if (lsp-start! root) (echo-message! (app-state-echo app) "LSP: initializing...") - (echo-error! (app-state-echo app) "LSP: failed to start gerbil-lsp")))))))) + (echo-error! (app-state-echo app) "LSP: failed to start jerboa-lsp")))))))) (def (lsp-find-project-root path) - "Walk up from PATH to find a directory containing gerbil.pkg or .git." + "Walk up from PATH to find a directory containing a project marker." (let loop ((dir (path-directory (path-expand path)))) (cond ((or (string=? dir "/") (string=? dir "")) #f) - ((or (file-exists? (path-expand "gerbil.pkg" dir)) + ((or (file-exists? (path-expand "jerboa.pkg" dir)) + (file-exists? (path-expand ".jerboa-lsp.json" dir)) + (file-exists? (path-expand "gerbil.pkg" dir)) (file-exists? (path-expand ".git" dir))) dir) (else @@ -1394,7 +1397,7 @@ ;; Proactively set up diagnostic margin so indicators are visible immediately (let ((ed (current-qt-editor app))) (lsp-ensure-diagnostic-margin! ed)) - (echo-message! (app-state-echo app) "LSP: starting gerbil-lsp...")) + (echo-message! (app-state-echo app) "LSP: starting jerboa-lsp...")) (echo-error! (app-state-echo app) "LSP: no project root found"))))) ;;;============================================================================ --- a/src/jerboa-emacs/qt/lsp-client.ss +++ b/src/jerboa-emacs/qt/lsp-client.ss @@ -4,7 +4,7 @@ ;;; - JSON-RPC transport over stdio (Content-Length framing) ;;; - Background reader thread + mutex-protected UI action queue ;;; - Document synchronization (didOpen/didChange/didSave/didClose) -;;; - Process management (start/stop gerbil-lsp) +;;; - Process management (start/stop jerboa-lsp) (export #t)