mirror of
https://github.com/librephoenix/nixos-config
synced 2025-01-19 07:05:51 +05:30
Trying lsp-booster
This commit is contained in:
parent
cabfed6f4b
commit
868b0db976
|
@ -1503,6 +1503,11 @@ If the path from LINK does not exist, nil is returned."
|
||||||
(require 'nix-mode)
|
(require 'nix-mode)
|
||||||
(require 'gdscript-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-java-workspace-dir (concat user-home-directory "/.local/share/doom/java-workspace"))
|
||||||
|
|
||||||
(setq lsp-treemacs-deps-position-params
|
(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))
|
(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)
|
(add-to-list 'tramp-remote-path 'tramp-own-remote-path)
|
||||||
(after! vterm
|
(after! vterm
|
||||||
(add-to-list 'vterm-tramp-shells '("ssh" "zsh")) ;; I use zsh on all my servers
|
(add-to-list 'vterm-tramp-shells '("ssh" "zsh")) ;; I use zsh on all my servers
|
||||||
|
|
|
@ -1775,6 +1775,11 @@ I don't have this active right now since it's kinda weird with pgtk...
|
||||||
(require 'nix-mode)
|
(require 'nix-mode)
|
||||||
(require 'gdscript-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-java-workspace-dir (concat user-home-directory "/.local/share/doom/java-workspace"))
|
||||||
|
|
||||||
(setq lsp-treemacs-deps-position-params
|
(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))
|
(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
|
#+END_SRC
|
||||||
** Terminal
|
** Terminal
|
||||||
#+BEGIN_SRC emacs-lisp :tangle config.el
|
#+BEGIN_SRC emacs-lisp :tangle config.el
|
||||||
|
@ -2136,6 +2172,7 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
home.packages = (with pkgs-emacs; [
|
home.packages = (with pkgs-emacs; [
|
||||||
|
emacs-lsp-booster
|
||||||
nil
|
nil
|
||||||
nixfmt
|
nixfmt
|
||||||
file
|
file
|
||||||
|
|
Loading…
Reference in a new issue