chore: Fix eglot-booster & switch to eglot for now
This commit is contained in:
parent
0bfa64b4ba
commit
ec1d7194dd
4 changed files with 21 additions and 146 deletions
|
@ -1,124 +0,0 @@
|
||||||
;;; eglot-booster.el --- Boost eglot using lsp-booster -*- lexical-binding: t; -*-
|
|
||||||
;; Copyright (C) 2024 J.D. Smith
|
|
||||||
|
|
||||||
;; Author: J.D. Smith
|
|
||||||
;; Homepage: https://github.com/jdtsmith/eglot-booster
|
|
||||||
;; Package-Requires: ((emacs "29.1") (jsonrpc "1.0") (eglot "1.0") (seq "2.24"))
|
|
||||||
;; Version: 0.0.1
|
|
||||||
;; Keywords: convenience, programming
|
|
||||||
;; Prefix: eglot-booster
|
|
||||||
;; Separator: -
|
|
||||||
|
|
||||||
;; eglot-booster is free software: you can redistribute it and/or
|
|
||||||
;; modify it under the terms of the GNU General Public License as
|
|
||||||
;; published by the Free Software Foundation, either version 3 of the
|
|
||||||
;; License, or (at your option) any later version.
|
|
||||||
|
|
||||||
;; eglot-booster is distributed in the hope that it will be useful,
|
|
||||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
;; General Public License for more details.
|
|
||||||
|
|
||||||
;; You should have received a copy of the GNU General Public License
|
|
||||||
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
;;; Commentary:
|
|
||||||
|
|
||||||
;; This small minor mode boosts eglot with emacs-lsp-booster.
|
|
||||||
;; Using it is simple:
|
|
||||||
;;
|
|
||||||
;; 1. Download/build a recent emacs-lsp-booster from
|
|
||||||
;; https://github.com/blahgeek/emacs-lsp-booster using the
|
|
||||||
;; instructions there.
|
|
||||||
;; 2. Enable eglot-booster-mode either in your init or, interactively,
|
|
||||||
;; use M-x eglot-booster-mode.
|
|
||||||
;; 3. Use eglot like normal.
|
|
||||||
;;
|
|
||||||
;; You can disable boosting by turning the minor mode off; any boosted
|
|
||||||
;; eglot servers will need to be restarted. Note: boosting works only
|
|
||||||
;; with local lsp servers programs which communicate via standard
|
|
||||||
;; input/output, not remote or network-port LSP servers.
|
|
||||||
|
|
||||||
;;; Code:
|
|
||||||
(require 'eglot)
|
|
||||||
(require 'jsonrpc)
|
|
||||||
|
|
||||||
(defcustom eglot-booster-no-remote-boost nil
|
|
||||||
"If non-nil, do not boost remote hosts."
|
|
||||||
:group 'eglot
|
|
||||||
:type 'boolean)
|
|
||||||
|
|
||||||
(defun eglot-booster-plain-command (com)
|
|
||||||
"Test if command COM is a plain eglot server command."
|
|
||||||
(and (consp com)
|
|
||||||
(not (integerp (cadr com)))
|
|
||||||
(not (memq :autoport com))))
|
|
||||||
|
|
||||||
(defvar-local eglot-booster-boosted nil)
|
|
||||||
(defun eglot-booster--jsonrpc--json-read (orig-func)
|
|
||||||
"Read JSON or bytecode, wrapping the ORIG-FUNC JSON reader."
|
|
||||||
(if eglot-booster-boosted ; local to process-buffer
|
|
||||||
(or (and (= (following-char) ?#)
|
|
||||||
(let ((bytecode (read (current-buffer))))
|
|
||||||
(when (byte-code-function-p bytecode)
|
|
||||||
(funcall bytecode))))
|
|
||||||
(funcall orig-func))
|
|
||||||
;; Not in a boosted process, fallback
|
|
||||||
(funcall orig-func)))
|
|
||||||
|
|
||||||
(defun eglot-booster--init (server)
|
|
||||||
"Register eglot SERVER as boosted if it is."
|
|
||||||
(when-let ((server)
|
|
||||||
(proc (jsonrpc--process server))
|
|
||||||
(com (process-command proc))
|
|
||||||
(buf (process-buffer proc)))
|
|
||||||
(unless (and (file-remote-p default-directory) eglot-booster-no-remote-boost)
|
|
||||||
(if (file-remote-p default-directory) ; com will likely be /bin/sh -i or so
|
|
||||||
(when (seq-find (apply-partially #'string-search "emacs-lsp-booster")
|
|
||||||
(process-get proc 'remote-command)) ; tramp applies this
|
|
||||||
(with-current-buffer buf (setq eglot-booster-boosted t)))
|
|
||||||
(when (string-search "emacs-lsp-booster" (car-safe com))
|
|
||||||
(with-current-buffer buf (setq eglot-booster-boosted t)))))))
|
|
||||||
|
|
||||||
(defvar eglot-booster--boost
|
|
||||||
'("emacs-lsp-booster" "--json-false-value" ":json-false" "--"))
|
|
||||||
|
|
||||||
(defun eglot-booster--wrap-contact (args)
|
|
||||||
"Wrap contact within ARGS if possible."
|
|
||||||
(let ((contact (nth 3 args)))
|
|
||||||
(cond
|
|
||||||
((and eglot-booster-no-remote-boost (file-remote-p default-directory)))
|
|
||||||
((functionp contact)
|
|
||||||
(setf (nth 3 args)
|
|
||||||
(lambda (&optional interactive)
|
|
||||||
(let ((res (funcall contact interactive)))
|
|
||||||
(if (eglot-booster-plain-command res)
|
|
||||||
(append eglot-booster--boost res)
|
|
||||||
res)))))
|
|
||||||
((eglot-booster-plain-command contact)
|
|
||||||
(setf (nth 3 args) (append eglot-booster--boost contact))))
|
|
||||||
args))
|
|
||||||
|
|
||||||
;;;###autoload
|
|
||||||
(define-minor-mode eglot-booster-mode
|
|
||||||
"Minor mode which boosts 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."
|
|
||||||
:global t
|
|
||||||
:group 'eglot
|
|
||||||
(cond
|
|
||||||
(eglot-booster-mode
|
|
||||||
(unless (executable-find "emacs-lsp-booster")
|
|
||||||
(setq eglot-booster-mode nil)
|
|
||||||
(user-error "The emacs-lsp-booster program is not installed"))
|
|
||||||
(advice-add 'jsonrpc--json-read :around #'eglot-booster--jsonrpc--json-read)
|
|
||||||
(advice-add 'eglot--connect :filter-args #'eglot-booster--wrap-contact)
|
|
||||||
(add-hook 'eglot-server-initialized-hook #'eglot-booster--init))
|
|
||||||
(t
|
|
||||||
(advice-remove 'jsonrpc--json-read #'eglot-booster--jsonrpc--json-read)
|
|
||||||
(advice-remove 'eglot--connect #'eglot-booster--wrap-contact)
|
|
||||||
(remove-hook 'eglot-server-initialized-hook #'eglot-booster--init))))
|
|
||||||
|
|
||||||
(provide 'eglot-booster)
|
|
||||||
;;; eglot-booster.el ends here
|
|
|
@ -25,7 +25,7 @@
|
||||||
(setq nerd-icons-font-names '("SymbolsNerdFontMono-Regular.ttf"))
|
(setq nerd-icons-font-names '("SymbolsNerdFontMono-Regular.ttf"))
|
||||||
|
|
||||||
(setq doom-font (font-spec :family "Iosevka Nerd Font Mono" :size 16)
|
(setq doom-font (font-spec :family "Iosevka Nerd Font Mono" :size 16)
|
||||||
doom-variable-pitch-font (font-spec :family "Iosevka Nerd Font Propo" :size 16)
|
doom-variable-pitch-font (font-spec :family "Iosevka Nerd Font Mono" :size 16)
|
||||||
;; doom-symbol-font (font-spec :family "all-the-icons" :size 13)
|
;; doom-symbol-font (font-spec :family "all-the-icons" :size 13)
|
||||||
doom-big-font (font-spec :family "Iosevka Nerd Font Mono" :size 20 :weight 'demibold))
|
doom-big-font (font-spec :family "Iosevka Nerd Font Mono" :size 20 :weight 'demibold))
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@
|
||||||
:after lsp)
|
:after lsp)
|
||||||
|
|
||||||
|
|
||||||
(use-package eglot-booster
|
(use-package! eglot-booster
|
||||||
:after eglot
|
:after eglot
|
||||||
:config
|
:config
|
||||||
(eglot-booster-mode))
|
(eglot-booster-mode))
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
ophints ; highlight the region an operation acts on
|
ophints ; highlight the region an operation acts on
|
||||||
(popup +defaults) ; tame sudden yet inevitable temporary windows
|
(popup +defaults) ; tame sudden yet inevitable temporary windows
|
||||||
;; tabs ; a tab bar for Emacs
|
;; tabs ; a tab bar for Emacs
|
||||||
(treemacs +lsp) ; a project drawer, like neotree but cooler
|
treemacs ; a project drawer, like neotree but cooler
|
||||||
;;unicode ; extended unicode support for various languages
|
;;unicode ; extended unicode support for various languages
|
||||||
(vc-gutter
|
(vc-gutter
|
||||||
+diff-hl
|
+diff-hl
|
||||||
|
@ -60,7 +60,8 @@
|
||||||
(evil +everywhere) ; come to the dark side, we have cookies
|
(evil +everywhere) ; come to the dark side, we have cookies
|
||||||
file-templates ; auto-snippets for empty files
|
file-templates ; auto-snippets for empty files
|
||||||
fold ; (nigh) universal code folding
|
fold ; (nigh) universal code folding
|
||||||
(format +onsave) ; automated prettiness
|
(format +onsave
|
||||||
|
+lsp) ; automated prettiness
|
||||||
;;god ; run Emacs commands without modifier keys
|
;;god ; run Emacs commands without modifier keys
|
||||||
;;lispy ; vim for lisp, for people who don't like vim
|
;;lispy ; vim for lisp, for people who don't like vim
|
||||||
;;multiple-cursors ; editing in many places at once
|
;;multiple-cursors ; editing in many places at once
|
||||||
|
@ -97,7 +98,7 @@
|
||||||
;;collab ; buffers with friends
|
;;collab ; buffers with friends
|
||||||
;;debugger ; FIXME stepping through code, to help you add bugs
|
;;debugger ; FIXME stepping through code, to help you add bugs
|
||||||
direnv
|
direnv
|
||||||
(docker +lsp)
|
docker
|
||||||
;;editorconfig ; let someone else argue about tabs vs spaces
|
;;editorconfig ; let someone else argue about tabs vs spaces
|
||||||
;;ein ; tame Jupyter notebooks with emacs
|
;;ein ; tame Jupyter notebooks with emacs
|
||||||
(eval +overlay) ; run code, run (also, repls)
|
(eval +overlay) ; run code, run (also, repls)
|
||||||
|
@ -105,7 +106,7 @@
|
||||||
(lookup
|
(lookup
|
||||||
+docsets
|
+docsets
|
||||||
+dictionary) ; navigate your code and its documentation
|
+dictionary) ; navigate your code and its documentation
|
||||||
lsp ; M-x vscode
|
(lsp +eglot) ; M-x vscode
|
||||||
magit ; a git porcelain for Emacs
|
magit ; a git porcelain for Emacs
|
||||||
;;make ; run make tasks from Emacs
|
;;make ; run make tasks from Emacs
|
||||||
;;pass ; password manager for nerds
|
;;pass ; password manager for nerds
|
||||||
|
@ -125,7 +126,8 @@
|
||||||
:lang
|
:lang
|
||||||
;;agda ; types of types of types of types...
|
;;agda ; types of types of types of types...
|
||||||
;;beancount ; mind the GAAP
|
;;beancount ; mind the GAAP
|
||||||
(cc +lsp
|
(cc
|
||||||
|
+lsp ;;;; supports eglot
|
||||||
+tree-sitter) ; C > C++ == 1
|
+tree-sitter) ; C > C++ == 1
|
||||||
;;clojure ; java with a lisp
|
;;clojure ; java with a lisp
|
||||||
;;common-lisp ; if you've seen one lisp, you've seen them all
|
;;common-lisp ; if you've seen one lisp, you've seen them all
|
||||||
|
@ -139,23 +141,22 @@
|
||||||
;;elm ; care for a cup of TEA?
|
;;elm ; care for a cup of TEA?
|
||||||
emacs-lisp ; drown in parentheses
|
emacs-lisp ; drown in parentheses
|
||||||
;;erlang ; an elegant language for a more civilized age
|
;;erlang ; an elegant language for a more civilized age
|
||||||
(ess +lsp) ; emacs speaks statistics
|
ess ; emacs speaks statistics
|
||||||
;;factor
|
;;factor
|
||||||
;;faust ; dsp, but you get to keep your soul
|
;;faust ; dsp, but you get to keep your soul
|
||||||
;;fortran ; in FORTRAN, GOD is REAL (unless declared INTEGER)
|
;;fortran ; in FORTRAN, GOD is REAL (unless declared INTEGER)
|
||||||
;;fsharp ; ML stands for Microsoft's Language
|
;;fsharp ; ML stands for Microsoft's Language
|
||||||
;;fstar ; (dependent) types and (monadic) effects and Z3
|
;;fstar ; (dependent) types and (monadic) effects and Z3
|
||||||
;;gdscript ; the language you waited for
|
;;gdscript ; the language you waited for
|
||||||
;;(go +lsp) ; the hipster dialect
|
;;go ; the hipster dialect
|
||||||
(graphql +lsp) ; Give queries a REST
|
graphql ; Give queries a REST
|
||||||
;;(haskell +lsp) ; a language that's lazier than I am
|
;;haskell ; a language that's lazier than I am
|
||||||
;;hy ; readability of scheme w/ speed of python
|
;;hy ; readability of scheme w/ speed of python
|
||||||
;;idris ; a language you can depend on
|
;;idris ; a language you can depend on
|
||||||
(json
|
(json
|
||||||
+tree-sitter) ; At least it ain't XML
|
+tree-sitter) ; At least it ain't XML
|
||||||
;;(java +lsp) ; the poster child for carpal tunnel syndrome
|
;;java ; the poster child for carpal tunnel syndrome
|
||||||
(javascript
|
(javascript
|
||||||
+lsp
|
|
||||||
+tree-sitter) ; all(hope(abandon(ye(who(enter(here))))))
|
+tree-sitter) ; all(hope(abandon(ye(who(enter(here))))))
|
||||||
;;julia ; a better, faster MATLAB
|
;;julia ; a better, faster MATLAB
|
||||||
;;kotlin ; a better, slicker Java(Script)
|
;;kotlin ; a better, slicker Java(Script)
|
||||||
|
@ -165,8 +166,7 @@
|
||||||
;;lua ; one-based indices? one-based indices
|
;;lua ; one-based indices? one-based indices
|
||||||
markdown ; writing docs for people to ignore
|
markdown ; writing docs for people to ignore
|
||||||
;;nim ; python + lisp at the speed of c
|
;;nim ; python + lisp at the speed of c
|
||||||
(nix +lsp
|
(nix +tree-sitter) ; I hereby declare "nix geht mehr!"
|
||||||
+tree-sitter) ; I hereby declare "nix geht mehr!"
|
|
||||||
;;ocaml ; an objective camel
|
;;ocaml ; an objective camel
|
||||||
(org ; organize your plain life in plain text
|
(org ; organize your plain life in plain text
|
||||||
+jupyter
|
+jupyter
|
||||||
|
@ -187,13 +187,12 @@
|
||||||
rest ; Emacs as a REST client
|
rest ; Emacs as a REST client
|
||||||
;;rst ; ReST in peace
|
;;rst ; ReST in peace
|
||||||
;;(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"}
|
;;(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"}
|
||||||
(rust +lsp
|
(rust +lsp ;;;; supports eglot
|
||||||
+tree-sitter) ; Fe2O3.unwrap().unwrap().unwrap().unwrap()
|
+tree-sitter) ; Fe2O3.unwrap().unwrap().unwrap().unwrap()
|
||||||
;;scala ; java, but good
|
;;scala ; java, but good
|
||||||
;;(scheme +guile) ; a fully conniving family of lisps
|
;;(scheme +guile) ; a fully conniving family of lisps
|
||||||
(sh
|
(sh
|
||||||
+fish
|
+fish
|
||||||
+lsp
|
|
||||||
+tree-sitter) ; she sells {ba,z,fi}sh shells on the C xor
|
+tree-sitter) ; she sells {ba,z,fi}sh shells on the C xor
|
||||||
;;sml
|
;;sml
|
||||||
;;solidity ; do you need a blockchain? No.
|
;;solidity ; do you need a blockchain? No.
|
||||||
|
@ -201,11 +200,9 @@
|
||||||
;;terra ; Earth and Moon in alignment for performance.
|
;;terra ; Earth and Moon in alignment for performance.
|
||||||
(web
|
(web
|
||||||
+css
|
+css
|
||||||
+lsp
|
|
||||||
+tree-sitter) ; the tubes
|
+tree-sitter) ; the tubes
|
||||||
(yaml
|
(yaml
|
||||||
+tree-sitter
|
+tree-sitter) ; JSON, but readable
|
||||||
+lsp) ; JSON, but readable
|
|
||||||
;;zig ; C, but simpler
|
;;zig ; C, but simpler
|
||||||
|
|
||||||
:email
|
:email
|
||||||
|
|
|
@ -39,6 +39,8 @@
|
||||||
|
|
||||||
;; Use `:pin' to specify a particular commit to install.
|
;; Use `:pin' to specify a particular commit to install.
|
||||||
|
|
||||||
|
(package! eglot-booster :recipe (:type git :host nil :repo "https://github.com/jdtsmith/eglot-booster.git" :branch "main"))
|
||||||
|
|
||||||
;; tabs
|
;; tabs
|
||||||
(package! centaur-tabs)
|
(package! centaur-tabs)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue