Last active
February 16, 2024 18:17
-
-
Save jdtsmith/d936801a4d7fd981bedf2e59dacd675e to your computer and use it in GitHub Desktop.
Revisions
-
jdtsmith revised this gist
Jan 15, 2024 . No changes.There are no files selected for viewing
-
jdtsmith revised this gist
Jan 9, 2024 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,9 @@ ;;; Commentary: ;; **UPDATE** This has been superseded by the following package: ;; https://github.com/jdtsmith/eglot-booster ;; ;; Boost eglot with emacs-lsp-booster. ;; 1. Download a recent emacs-lsp-booster from ;; https://github.com/blahgeek/emacs-lsp-booster -
jdtsmith revised this gist
Jan 6, 2024 . 1 changed file with 8 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ ;;; Commentary: ;; Boost eglot with emacs-lsp-booster. ;; 1. Download a recent emacs-lsp-booster from ;; https://github.com/blahgeek/emacs-lsp-booster ;; 2. In the cloned directory, build with cargo (rust): ;; cargo build --release @@ -39,7 +39,8 @@ be boosted." (if (get 'eglot-server-programs 'lsp-booster-p) (message "eglot-server-programs already boosted.") (let ((cnt 0) (orig-read (symbol-function 'jsonrpc--json-read)) (boost '("emacs-lsp-booster" "--json-false-value" ":json-false" "--"))) (dolist (entry eglot-server-programs) (cond ((functionp (cdr entry)) @@ -48,11 +49,11 @@ be boosted." (setcdr entry (lambda (&rest r) ; wrap function (let ((res (apply fun r))) (if (eglot-booster-plain-command res) (append boost res) res)))))) ((eglot-booster-plain-command (cdr entry)) (cl-incf cnt) (setcdr entry (append boost (cdr entry)))))) (defalias 'jsonrpc--json-read (lambda () (or (and (= (following-char) ?#) @@ -63,5 +64,8 @@ be boosted." (message "Boosted %d eglot-server-programs" cnt)) (put 'eglot-server-programs 'lsp-booster-p t))) (defun eglot-booster-reset () (put 'eglot-server-programs 'lsp-booster-p nil)) (provide 'eglot-booster) ;;; eglot-booster.el ends here -
jdtsmith revised this gist
Jan 5, 2024 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,6 +18,7 @@ ;;; Code: (eval-when-compile (require 'cl-lib)) (require 'seq) (require 'eglot) (require 'jsonrpc) -
jdtsmith revised this gist
Jan 4, 2024 . 1 changed file with 32 additions and 28 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,6 +21,12 @@ (require 'eglot) (require 'jsonrpc) (defun eglot-booster-plain-command (com) "Test if command COM is a plain eglot server command." (and (consp com) (not (integerp (cadr com))) (not (seq-intersection '(:initializationOptions :autoport) com)))) (defun eglot-booster () "Boost plain eglot server programs with emacs-lsp-booster. The emacs-lsp-booster program must be compiled and available on @@ -31,32 +37,30 @@ be boosted." (user-error "The emacs-lsp-booster program is not installed")) (if (get 'eglot-server-programs 'lsp-booster-p) (message "eglot-server-programs already boosted.") (let ((cnt 0) (orig-read (symbol-function 'jsonrpc--json-read))) (dolist (entry eglot-server-programs) (cond ((functionp (cdr entry)) (cl-incf cnt) (let ((fun (cdr entry))) (setcdr entry (lambda (&rest r) ; wrap function (let ((res (apply fun r))) (if (eglot-booster-plain-command res) (cons "emacs-lsp-booster" res) res)))))) ((eglot-booster-plain-command (cdr entry)) (cl-incf cnt) (setcdr entry (cons "emacs-lsp-booster" (cdr entry)))))) (defalias 'jsonrpc--json-read (lambda () (or (and (= (following-char) ?#) (let ((bytecode (read (current-buffer)))) (when (byte-code-function-p bytecode) (funcall bytecode)))) (funcall orig-read)))) (message "Boosted %d eglot-server-programs" cnt)) (put 'eglot-server-programs 'lsp-booster-p t))) (provide 'eglot-booster) ;;; eglot-booster.el ends here -
jdtsmith revised this gist
Jan 4, 2024 . No changes.There are no files selected for viewing
-
jdtsmith revised this gist
Jan 4, 2024 . No changes.There are no files selected for viewing
-
jdtsmith revised this gist
Jan 4, 2024 . No changes.There are no files selected for viewing
-
jdtsmith renamed this gist
Jan 4, 2024 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jdtsmith revised this gist
Jan 4, 2024 . 1 changed file with 8 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,15 +4,17 @@ ;;; Commentary: ;; Boost eglot with emacs-lsp-booster. ;; 1. Download emacs-lsp-booster from ;; https://github.com/blahgeek/emacs-lsp-booster ;; 2. In the cloned directory, build with cargo (rust): ;; cargo build --release ;; 3. place the target/release/emacs-lsp-booster program somewhere on ;; `exec-path'. ;; 4. M-x eglot-booster ;; 5. Use eglot like normal ;; ;; Note: works only with local lsp servers via standard input/output, ;; not remote LSP servers. ;;; Code: (eval-when-compile (require 'cl-lib)) -
jdtsmith created this gist
Jan 4, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ ;;; eglot-booster.el --- boost eglot using emacs-lsp-booster -*- lexical-binding: t; -*- ;; Copyright (C) 2024 J.D. Smith ;;; Commentary: ;; Boost eglot with emacs-lsp-booster. ;; 1. Download from ;; https://github.com/blahgeek/emacs-lsp-booster Build with cargo ;; 2. cargo build --release ;; 3. place the target/release/emacs-lsp-booster program somewhere on ;; exec-path. ;; 4. M-x eglot-booster ;; ;; Note: works only with local commands via standard input/output, not ;; remote LSP servers. ;;; Code: (eval-when-compile (require 'cl-lib)) (require 'eglot) (require 'jsonrpc) (defun eglot-booster () "Boost plain eglot server programs with emacs-lsp-booster. The emacs-lsp-booster program must be compiled and available on variable `exec-path'. Only local stdin/out based lsp servers can be boosted." (interactive) (unless (executable-find "emacs-lsp-booster") (user-error "The emacs-lsp-booster program is not installed")) (if (get 'eglot-server-programs 'lsp-booster-p) (message "eglot-server-programs already boosted.") (cl-labels ((plain-command (com) (and (consp com) (not (integerp (cadr com))) (not (seq-intersection '(:initializationOptions :autoport) com))))) (let ((cnt 0) (orig-read (symbol-function 'jsonrpc--json-read))) (dolist (entry eglot-server-programs) (cond ((functionp (cdr entry)) (cl-incf cnt) (let ((fun (cdr entry))) (setcdr entry (lambda (&rest r) ; wrap function (let ((res (apply fun r))) (if (plain-command res) (cons "emacs-lsp-booster" res) res)))))) ((plain-command (cdr entry)) (cl-incf cnt) (setcdr entry (cons "emacs-lsp-booster" (cdr entry)))))) (defalias 'jsonrpc--json-read (lambda () (or (and (= (following-char) ?#) (let ((bytecode (read (current-buffer)))) (when (byte-code-function-p bytecode) (funcall bytecode)))) (funcall orig-read)))) (message "Boosted %d eglot-server-programs" cnt))) (put 'eglot-server-programs 'lsp-booster-p t)))