mirror of
https://codeberg.org/andyscott/dotfiles.git
synced 2024-12-22 01:43:10 -05:00
Trying emacs-lsp-booster and eglot with zls
This commit is contained in:
parent
220e26d91f
commit
ada842259c
2 changed files with 68 additions and 10 deletions
|
@ -43,9 +43,9 @@
|
|||
|
||||
;; Move eln-cache to XDG_CACHE_HOME
|
||||
(when (fboundp 'startup-redirect-eln-cache)
|
||||
(if (< emacs-major-version 29)
|
||||
(push (expand-file-name "eln-cache/" xdg_cache_home) native-comp-eln-load-path)
|
||||
(startup-redirect-eln-cache (expand-file-name "eln-cache/" xdg_cache_home))))
|
||||
(if (< emacs-major-version 29)
|
||||
(push (expand-file-name "eln-cache/" xdg_cache_home) native-comp-eln-load-path)
|
||||
(startup-redirect-eln-cache (expand-file-name "eln-cache/" xdg_cache_home))))
|
||||
|
||||
;; Disable package.el
|
||||
(setq package-enable-at-startup nil)
|
||||
|
@ -95,5 +95,8 @@
|
|||
(push '(tool-bar-lines . 0) default-frame-alist)
|
||||
(push '(vertical-scroll-bars) default-frame-alist)
|
||||
|
||||
;; Make lsp-mode use plists
|
||||
(setenv "LSP_USE_PLISTS" "true")
|
||||
|
||||
(provide 'early-init)
|
||||
;;; early-init.el ends here
|
||||
|
|
|
@ -166,15 +166,25 @@
|
|||
|
||||
(use-package display-fill-column-indicator
|
||||
:ensure nil
|
||||
:init (setq-default fill-column 100)
|
||||
:hook ((conf-mode
|
||||
markdown-mode
|
||||
prog-mode) . display-fill-column-indicator-mode)
|
||||
:config (setq-default fill-column 100))
|
||||
prog-mode) . display-fill-column-indicator-mode))
|
||||
|
||||
(use-package display-line-numbers
|
||||
:ensure nil
|
||||
:hook ((conf-mode prog-mode) . display-line-numbers-mode))
|
||||
|
||||
(use-package eglot
|
||||
:ensure nil
|
||||
:hook (zig-mode . eglot-ensure)
|
||||
:bind (:map
|
||||
eglot-mode-map
|
||||
("C-c c a" . eglot-code-actions)
|
||||
("C-c c o" . eglot-code-actions-organize-imports)
|
||||
("C-c c r" . eglot-rename)
|
||||
("C-c c f" . eglot-format)))
|
||||
|
||||
(use-package elec-pair
|
||||
:ensure nil
|
||||
:defer 3
|
||||
|
@ -196,6 +206,15 @@
|
|||
require-final-newline t
|
||||
version-control t))
|
||||
|
||||
(use-package flymake
|
||||
:ensure nil
|
||||
:bind (:map flymake-mode-map
|
||||
("C-c ! d" . flymake-show-buffer-diagnostics)
|
||||
("C-c ! D" . flymake-show-project-diagnostics)
|
||||
("C-c ! n" . flymake-goto-next-error)
|
||||
("C-c ! p" . flymake-goto-prev-error))
|
||||
:config (flymake-mode))
|
||||
|
||||
(use-package flyspell
|
||||
:ensure nil
|
||||
:defer 3
|
||||
|
@ -203,7 +222,7 @@
|
|||
(((git-commit-mode
|
||||
markdown-mode
|
||||
text-mode) . flyspell-mode)
|
||||
(lsp-mode . flyspell-prog-mode)))
|
||||
(prog-mode . flyspell-prog-mode)))
|
||||
|
||||
(use-package mwheel
|
||||
:ensure nil
|
||||
|
@ -243,7 +262,7 @@
|
|||
(save-place-mode))
|
||||
|
||||
(use-package seq
|
||||
; Unload seq before elpaca build
|
||||
;; Unload seq before elpaca build
|
||||
:ensure `(seq :build ,(+elpaca-seq-build-steps)))
|
||||
|
||||
(use-package simple
|
||||
|
@ -594,16 +613,22 @@
|
|||
:after (consult flycheck))
|
||||
|
||||
;; LSP
|
||||
(use-package eglot-booster
|
||||
:ensure (eglot-booster :host github :repo "jdtsmith/eglot-booster")
|
||||
:after eglot
|
||||
:config (eglot-booster-mode))
|
||||
|
||||
(use-package lsp-mode
|
||||
:hook
|
||||
(((c-ts-mode
|
||||
c++-ts-mode
|
||||
csharp-ts-mode
|
||||
go-ts-mode
|
||||
python-ts-mode
|
||||
zig-mode) . lsp)
|
||||
python-ts-mode) . lsp)
|
||||
;; zig-mode) . lsp)
|
||||
(lsp-mode . lsp-enable-which-key-integration))
|
||||
:custom
|
||||
(lsp-use-plists t)
|
||||
(lsp-idle-delay 0.6)
|
||||
(lsp-prefer-flymake nil)
|
||||
(lsp-session-file (concat xdg_cache_home "lsp-session")))
|
||||
|
@ -617,7 +642,7 @@
|
|||
(lsp-ui-peek-enable t)
|
||||
(lsp-ui-sideline-delay 0.6)
|
||||
(lsp-ui-sideline-show-code-actions t)
|
||||
(lsp-ui-sideline-show-hover t)
|
||||
(lsp-ui-sideline-show-hover nil)
|
||||
(lsp-ui-sideline-update-mode 'line))
|
||||
|
||||
(use-package consult-lsp
|
||||
|
@ -630,6 +655,36 @@
|
|||
:after (lsp-mode treemacs)
|
||||
:config (lsp-treemacs-sync-mode))
|
||||
|
||||
;; Configure emacs-lsp-booster for lsp-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
|
||||
(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)
|
||||
|
||||
;; Debugging
|
||||
(use-package dap-mode
|
||||
:after (lsp-mode)
|
||||
|
|
Loading…
Reference in a new issue