Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vitek committed Aug 31, 2024
1 parent 4ca497e commit b845f27
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
41 changes: 41 additions & 0 deletions emacs/site-lisp/lsp-booster.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
;;; lsp-booster.el --- Emacs configuration -*- lexical-binding: t -*-

(require 'lsp-protocol)

(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)))

(defun lsp-booster-install ()
(when (executable-find "emacs-lsp-booster")
(advice-add
'lsp-resolve-final-command :around #'lsp-booster--advice-final-command)))

(provide 'lsp-booster)
;;; lsp-booster.el ends here
1 change: 0 additions & 1 deletion wayland/sway/config.d/01-idle.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@
# resumed. It will also lock your screen before your computer goes to sleep.

bindsym --to-code Mod1+Control+l exec sway-lock.sh
bindsym --to-code $mod+l exec sway-lock.sh

exec sway-idle.sh

0 comments on commit b845f27

Please sign in to comment.