diff --git a/user/app/doom-emacs/config.el b/user/app/doom-emacs/config.el index ec2d418..b852dcd 100644 --- a/user/app/doom-emacs/config.el +++ b/user/app/doom-emacs/config.el @@ -1503,6 +1503,11 @@ If the path from LINK does not exist, nil is returned." (require 'nix-mode) (require 'gdscript-mode) +(add-hook 'nix-mode-hook 'lsp-deferred) +(add-hook 'gdscript-mode-hook 'lsp-deferred) + +(setq gdscript-godot-executable "godot4") + (setq lsp-java-workspace-dir (concat user-home-directory "/.local/share/doom/java-workspace")) (setq lsp-treemacs-deps-position-params @@ -1520,6 +1525,37 @@ If the path from LINK does not exist, nil is returned." (setq +format-on-save-enabled-modes '(not emacs-lisp-mode sql-mode tex-mode latex-mode org-msg-edit-mode nix-mode)) +(defun lsp-booster--advice-json-parse (old-fn &rest args) + "Try to parse bytecode instead of json." + (or + (when (equal (following-char) ?#) + (let ((bytecode (read (current-buffer)))) + (when (byte-code-function-p bytecode) + (funcall bytecode)))) + (apply old-fn args))) +(advice-add (if (progn (require 'json) + (fboundp 'json-parse-buffer)) + 'json-parse-buffer + 'json-read) + :around + #'lsp-booster--advice-json-parse) + +(defun lsp-booster--advice-final-command (old-fn cmd &optional test?) + "Prepend emacs-lsp-booster command to lsp CMD." + (let ((orig-result (funcall old-fn cmd test?))) + (if (and (not test?) ;; for check lsp-server-present? + (not (file-remote-p default-directory)) ;; see lsp-resolve-final-command, it would add extra shell wrapper + lsp-use-plists + (not (functionp 'json-rpc-connection)) ;; native json-rpc + (executable-find "emacs-lsp-booster")) + (progn + (when-let ((command-from-exec-path (executable-find (car orig-result)))) ;; resolve command from exec-path (in case not found in $PATH) + (setcar orig-result command-from-exec-path)) + (message "Using emacs-lsp-booster for %s!" orig-result) + (cons "emacs-lsp-booster" orig-result)) + orig-result))) +(advice-add 'lsp-resolve-final-command :around #'lsp-booster--advice-final-command) + (add-to-list 'tramp-remote-path 'tramp-own-remote-path) (after! vterm (add-to-list 'vterm-tramp-shells '("ssh" "zsh")) ;; I use zsh on all my servers diff --git a/user/app/doom-emacs/doom.org b/user/app/doom-emacs/doom.org index bb2b94a..87dbe3d 100644 --- a/user/app/doom-emacs/doom.org +++ b/user/app/doom-emacs/doom.org @@ -1775,6 +1775,11 @@ I don't have this active right now since it's kinda weird with pgtk... (require 'nix-mode) (require 'gdscript-mode) +(add-hook 'nix-mode-hook 'lsp-deferred) +(add-hook 'gdscript-mode-hook 'lsp-deferred) + +(setq gdscript-godot-executable "godot4") + (setq lsp-java-workspace-dir (concat user-home-directory "/.local/share/doom/java-workspace")) (setq lsp-treemacs-deps-position-params @@ -1792,6 +1797,37 @@ I don't have this active right now since it's kinda weird with pgtk... (setq +format-on-save-enabled-modes '(not emacs-lisp-mode sql-mode tex-mode latex-mode org-msg-edit-mode nix-mode)) +(defun lsp-booster--advice-json-parse (old-fn &rest args) + "Try to parse bytecode instead of json." + (or + (when (equal (following-char) ?#) + (let ((bytecode (read (current-buffer)))) + (when (byte-code-function-p bytecode) + (funcall bytecode)))) + (apply old-fn args))) +(advice-add (if (progn (require 'json) + (fboundp 'json-parse-buffer)) + 'json-parse-buffer + 'json-read) + :around + #'lsp-booster--advice-json-parse) + +(defun lsp-booster--advice-final-command (old-fn cmd &optional test?) + "Prepend emacs-lsp-booster command to lsp CMD." + (let ((orig-result (funcall old-fn cmd test?))) + (if (and (not test?) ;; for check lsp-server-present? + (not (file-remote-p default-directory)) ;; see lsp-resolve-final-command, it would add extra shell wrapper + lsp-use-plists + (not (functionp 'json-rpc-connection)) ;; native json-rpc + (executable-find "emacs-lsp-booster")) + (progn + (when-let ((command-from-exec-path (executable-find (car orig-result)))) ;; resolve command from exec-path (in case not found in $PATH) + (setcar orig-result command-from-exec-path)) + (message "Using emacs-lsp-booster for %s!" orig-result) + (cons "emacs-lsp-booster" orig-result)) + orig-result))) +(advice-add 'lsp-resolve-final-command :around #'lsp-booster--advice-final-command) + #+END_SRC ** Terminal #+BEGIN_SRC emacs-lisp :tangle config.el @@ -2136,6 +2172,7 @@ in }; home.packages = (with pkgs-emacs; [ + emacs-lsp-booster nil nixfmt file