diff --git a/init.org b/init.org index 4365e79..ee7454f 100644 --- a/init.org +++ b/init.org @@ -1624,14 +1624,14 @@ LSP sets it's prefix key to =s-l= by default, which uses the Super key which I u ) :config (setq - lsp-idle-delay 0.5 + lsp-idle-delay 0.2 lsp-inlay-hint-enable t lsp-modeline-code-actions-enable t lsp-modeline-code-actions-segments '(name count) lsp-modeline-diagnostics-enable t lsp-completion-enable-additional-text-edit t - lsp-completion-provider :capf + lsp-completion-provider :none lsp-enable-snippet t lsp-rust-server 'rust-analyzer @@ -1648,6 +1648,14 @@ LSP sets it's prefix key to =s-l= by default, which uses the Super key which I u (setq lsp-glsl-executable '("glsl_analyzer")) (add-to-list 'lsp-language-id-configuration '("CMakeLists.txt" . "cmake")) + + (advice-add (if (progn (require 'json) + (fboundp 'json-parse-buffer)) + 'json-parse-buffer + 'json-read) + :around + #'lsp-booster--advice-json-parse) + (advice-add 'lsp-resolve-final-command :around #'lsp-booster--advice-final-command) ) (use-package consult-lsp @@ -1696,6 +1704,39 @@ LSP sets it's prefix key to =s-l= by default, which uses the Super key which I u "Format on save using LSP server." (if nemo/lsp-format-on-save (lsp-format-buffer))) + +(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))) + +(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))) +#+end_src + +Make lsp use plists instead of hash-tables: +#+begin_src emacs-lisp :tangle early-init.el +(setenv "LSP_USE_PLISTS" "true") +#+end_src + +#+begin_src emacs-lisp +(add-to-list 'exec-path-from-shell-variables "LSP_USE_PLISTS") #+end_src ** Graphics