Commit 65da2cd 1 parent 994a847 commit 65da2cd Copy full SHA for 65da2cd
File tree 4 files changed +59
-0
lines changed
modules/nixos/programs/emacs
4 files changed +59
-0
lines changed Original file line number Diff line number Diff line change 38
38
spicetify-nix . inputs . nixpkgs . follows = "nixpkgs" ;
39
39
40
40
nixos-wsl . url = "github:nix-community/NixOS-WSL/main" ;
41
+
42
+ emacs-lsp-booster . url = "github:slotThe/emacs-lsp-booster-flake" ;
43
+ emacs-lsp-booster . inputs . nixpkgs . follows = "nixpkgs" ;
41
44
} ;
42
45
43
46
outputs =
Original file line number Diff line number Diff line change 2
2
config ,
3
3
lib ,
4
4
pkgs ,
5
+ inputs ,
5
6
...
6
7
} :
7
8
with lib ;
70
71
ripgrep
71
72
# magit-delta
72
73
delta
74
+ # LSP
75
+ inputs . emacs-lsp-booster . packages . ${ pkgs . system } . default
73
76
# lsp-nix
74
77
nil
75
78
nixfmt-rfc-style
Original file line number Diff line number Diff line change 791
791
#'cape-file
792
792
#'cape-dabbrev
793
793
#'cape-keyword )))
794
+
795
+ (defun lsp-booster--advice-json-parse (old-fn &rest args )
796
+ " Try to parse bytecode instead of json."
797
+ (or
798
+ (when (equal (following-char ) ?# )
799
+ (let ((bytecode (read (current-buffer ))))
800
+ (when (byte-code-function-p bytecode)
801
+ (funcall bytecode))))
802
+ (apply old-fn args)))
803
+ (advice-add (if (progn (require 'json )
804
+ (fboundp 'json-parse-buffer ))
805
+ 'json-parse-buffer
806
+ 'json-read )
807
+ :around
808
+ #'lsp-booster--advice-json-parse )
809
+
810
+ (defun lsp-booster--advice-final-command (old-fn cmd &optional test? )
811
+ " Prepend emacs-lsp-booster command to lsp CMD."
812
+ (let ((orig-result (funcall old-fn cmd test?) ))
813
+ (if (and (not test?) ; ; for check lsp-server-present?
814
+ (not (file-remote-p default-directory)) ; ; see lsp-resolve-final-command, it would add extra shell wrapper
815
+ lsp-use-plists
816
+ (not (functionp 'json-rpc-connection )) ; ; native json-rpc
817
+ (executable-find " emacs-lsp-booster" ))
818
+ (progn
819
+ (when-let ((command-from-exec-path (executable-find (car orig-result)))) ; ; resolve command from exec-path (in case not found in $PATH)
820
+ (setcar orig-result command-from-exec-path))
821
+ (message " Using emacs-lsp-booster for %s ! " orig-result)
822
+ (cons " emacs-lsp-booster" orig-result))
823
+ orig-result)))
824
+
825
+ (advice-add 'lsp-resolve-final-command :around #'lsp-booster--advice-final-command )
794
826
:hook
795
827
(lsp-mode . lsp-enable-which-key-integration)
796
828
(lsp-mode . yas-minor-mode)
You can’t perform that action at this time.
0 commit comments