From 3890c5fb90fb3a29e5ea74c7c78fddfb521bd72b Mon Sep 17 00:00:00 2001 From: Jeremy Isaac Dormitzer Date: Wed, 20 Mar 2024 12:02:40 -0400 Subject: [PATCH] Set up eglot for ruby and bash --- emacs/.emacs.d/config/init-ide.el | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/emacs/.emacs.d/config/init-ide.el b/emacs/.emacs.d/config/init-ide.el index 65aca52..aff2d13 100644 --- a/emacs/.emacs.d/config/init-ide.el +++ b/emacs/.emacs.d/config/init-ide.el @@ -58,6 +58,17 @@ `(html-web-mode . ,(eglot-alternatives '(("vscode-html-language-server" "--stdio") ("html-languageserver" "--stdio"))))) + (add-to-list 'eglot-server-programs + `((ruby-mode ruby-ts-mode) . ,(eglot-alternatives + '(("srb" "typecheck" "--lsp") + ("solargraph" "socket" "--port" :autoport))))) + ;; Sorbet passes an out-of-spec key in its connection JSON, filter it out to prevent eglot blowing up + (cl-defun jsonrpc-connection-receive--filter-args ((conn foreign-message) &rest args) + (let ((msg (cl-loop for (k v) on foreign-message by #'cddr + if (-contains? '(:method :id :error :params :result :jsonrpc) k) + collect k and collect v))) + (append (list conn msg) args))) + (advice-add 'jsonrpc-connection-receive :filter-args #'jsonrpc-connection-receive--filter-args) (defvar eglot-java-java-agent nil "Java agent JVM arg for eglot JDTLS.") ;; Custom eglot java server for deeper customization @@ -194,8 +205,12 @@ (c-mode . eglot-ensure) (terraform-mode . eglot-ensure) (ruby-mode . eglot-ensure) + (ruby-ts-mode . eglot-ensure) + (sh-mode . eglot-ensure) + (bash-ts-mode . eglot-ensure) :custom - (eglot-confirm-server-initiated-edits nil)) + (eglot-confirm-server-initiated-edits nil) + (eglot-connect-timeout nil)) ;; Some compilation-mode conveniences (use-package compile