Change to lsp-mode
This commit is contained in:
parent
d39d3b2d41
commit
3becf805be
194
init.el
194
init.el
@ -339,8 +339,8 @@ visual states."
|
|||||||
(defun my/consult-setup-minibuffer-completion ()
|
(defun my/consult-setup-minibuffer-completion ()
|
||||||
(setq-local completion-in-region-function #'consult-completion-in-region))
|
(setq-local completion-in-region-function #'consult-completion-in-region))
|
||||||
(evil-declare-motion #'consult-line))
|
(evil-declare-motion #'consult-line))
|
||||||
(use-package consult-eglot
|
;; (use-package consult-eglot
|
||||||
:commands consult-eglot-symbols)
|
;; :commands consult-eglot-symbols)
|
||||||
|
|
||||||
;; integration for embark and consult
|
;; integration for embark and consult
|
||||||
(use-package embark-consult
|
(use-package embark-consult
|
||||||
@ -394,32 +394,34 @@ visual states."
|
|||||||
;; popup.el
|
;; popup.el
|
||||||
(use-package popup)
|
(use-package popup)
|
||||||
|
|
||||||
;; popwin
|
;; posframe
|
||||||
(use-package posframe)
|
(use-package posframe)
|
||||||
|
|
||||||
;; flymake
|
;; flymake
|
||||||
(use-package flymake
|
;; (use-package flymake
|
||||||
:bind (:map flymake-mode-map
|
;; :bind (:map flymake-mode-map
|
||||||
("C-c e" . my/flymake-show-diagnostic-at-point)
|
;; ("C-c e" . my/flymake-show-diagnostic-at-point)
|
||||||
("C-c C-e" . consult-flymake))
|
;; ("C-c C-e" . consult-flymake))
|
||||||
:hook (emacs-lisp-mode . flymake-mode)
|
;; ;; :hook (emacs-lisp-mode . flymake-mode)
|
||||||
:init
|
;; :init
|
||||||
(defun my/flymake-show-diagnostic-at-point ()
|
;; (defun my/flymake-show-diagnostic-at-point ()
|
||||||
(interactive)
|
;; (interactive)
|
||||||
(if-let ((pos (point))
|
;; (if-let ((pos (point))
|
||||||
(diag (and flymake-mode
|
;; (diag (and flymake-mode
|
||||||
(get-char-property pos 'flymake-diagnostic)))
|
;; (get-char-property pos 'flymake-diagnostic)))
|
||||||
(message (flymake--diag-text diag)))
|
;; (message (flymake--diag-text diag)))
|
||||||
(if (display-graphic-p)
|
;; (if (display-graphic-p)
|
||||||
(progn
|
;; (progn
|
||||||
(posframe-show " *flymake-error-posframe*"
|
;; (posframe-show " *flymake-error-posframe*"
|
||||||
:string message
|
;; :string message
|
||||||
:position (point)
|
;; :position (point)
|
||||||
:max-width 80)
|
;; :max-width 80
|
||||||
(clear-this-command-keys)
|
;; :border-width 2
|
||||||
(push (read-event) unread-command-events)
|
;; :border-color "white")
|
||||||
(posframe-hide " *flymake-error-posframe*"))
|
;; (clear-this-command-keys)
|
||||||
(popup-tip message)))))
|
;; (push (read-event) unread-command-events)
|
||||||
|
;; (posframe-hide " *flymake-error-posframe*"))
|
||||||
|
;; (popup-tip message)))))
|
||||||
|
|
||||||
;; eldoc
|
;; eldoc
|
||||||
(use-package eldoc
|
(use-package eldoc
|
||||||
@ -433,54 +435,103 @@ visual states."
|
|||||||
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate))
|
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate))
|
||||||
|
|
||||||
;; eglot
|
;; eglot
|
||||||
(use-package eglot
|
;; (use-package eglot
|
||||||
:demand t
|
;; :demand t
|
||||||
:hook (((c-ts-mode c++-ts-mode java-ts-mode rust-ts-mode python-ts-mode
|
;; :hook (((c-ts-mode c++-ts-mode java-ts-mode rust-ts-mode python-ts-mode
|
||||||
latex-mode markdown-mode blueprint-ts-mode) . eglot-ensure)
|
;; latex-mode markdown-mode blueprint-ts-mode) . eglot-ensure)
|
||||||
(eglot-managed-mode . my/-eglot-setup))
|
;; (eglot-managed-mode . my/-eglot-setup))
|
||||||
|
;; :init
|
||||||
|
;; (defvar my/-eglot-documentation-buffer nil
|
||||||
|
;; "Buffer for showing documentation for `my/eglot-documentation-at-point'.")
|
||||||
|
;; (defun my/eglot-documentation-at-point ()
|
||||||
|
;; "Show documentation for a symbol at point."
|
||||||
|
;; (interactive)
|
||||||
|
;; (if-let (server (eglot-current-server))
|
||||||
|
;; (progn
|
||||||
|
;; (if-let* (((not (buffer-live-p my/-eglot-documentation-buffer)))
|
||||||
|
;; (name (generate-new-buffer-name "*eglot documentation*")))
|
||||||
|
;; (setq my/-eglot-documentation-buffer (generate-new-buffer name)))
|
||||||
|
;; (eglot-hover-eldoc-function
|
||||||
|
;; (lambda (info _ _)
|
||||||
|
;; (if-let (((not (seq-empty-p info)))
|
||||||
|
;; (buff (current-buffer)))
|
||||||
|
;; (with-current-buffer my/-eglot-documentation-buffer
|
||||||
|
;; (read-only-mode -1)
|
||||||
|
;; (erase-buffer)
|
||||||
|
;; (insert info)
|
||||||
|
;; (special-mode)
|
||||||
|
;; (read-only-mode 1)
|
||||||
|
;; (when (not (get-buffer-window my/-eglot-documentation-buffer nil))
|
||||||
|
;; (switch-to-buffer-other-window my/-eglot-documentation-buffer t)
|
||||||
|
;; (switch-to-buffer-other-window buff t)))))))))
|
||||||
|
;; (defun my/-eglot-setup ()
|
||||||
|
;; "Setup eldoc variables for `eglot-managed-mode-hook'."
|
||||||
|
;; (setq-local eldoc-echo-area-use-multiline-p nil
|
||||||
|
;; evil-lookup-func #'my/eglot-documentation-at-point)
|
||||||
|
;; (evil-define-key '(normal motion) 'local
|
||||||
|
;; "K" #'evil-lookup
|
||||||
|
;; "gR" #'eglot-rename
|
||||||
|
;; "gA" #'eglot-code-actions
|
||||||
|
;; "gs" #'consult-eglot-symbols)
|
||||||
|
;; (eglot-inlay-hints-mode -1))
|
||||||
|
;; (setq eglot-autoshutdown t)
|
||||||
|
;; :config
|
||||||
|
;; (add-to-list 'eglot-server-programs
|
||||||
|
;; (cons '(c-mode c-ts-mode c++-mode c++-ts-mode objc-mode)
|
||||||
|
;; '("clangd" "--all-scopes-completion" "--background-index"
|
||||||
|
;; "--clang-tidy" "--completion-style=detailed"
|
||||||
|
;; "--header-insertion=never" "--pch-storage=memory"
|
||||||
|
;; "--malloc-trim" "--function-arg-placeholders"))))
|
||||||
|
|
||||||
|
;; flycheck
|
||||||
|
(use-package flycheck
|
||||||
|
:hook (emacs-lisp-mode . flycheck-mode)
|
||||||
|
:bind (:map flycheck-mode-map
|
||||||
|
("C-c e" . my/flycheck-show-diagnostic-at-point))
|
||||||
:init
|
:init
|
||||||
(defvar my/-eglot-documentation-buffer nil
|
(setq flycheck-display-errors-function nil)
|
||||||
"Buffer for showing documentation for `my/eglot-documentation-at-point'.")
|
(defun my/flycheck-show-diagnostic-at-point ()
|
||||||
(defun my/eglot-documentation-at-point ()
|
|
||||||
"Show documentation for a symbol at point."
|
|
||||||
(interactive)
|
(interactive)
|
||||||
(if-let (server (eglot-current-server))
|
(if-let ((flycheck-mode)
|
||||||
(progn
|
(errors (flycheck-overlay-errors-at (point)))
|
||||||
(if-let* (((not (buffer-live-p my/-eglot-documentation-buffer)))
|
(message (apply 'concat
|
||||||
(name (generate-new-buffer-name "*eglot documentation*")))
|
(mapcar
|
||||||
(setq my/-eglot-documentation-buffer (generate-new-buffer name)))
|
(lambda (error)
|
||||||
(eglot-hover-eldoc-function
|
(concat "•" (flycheck-error-message error) "\n"))
|
||||||
(lambda (info _ _)
|
errors))))
|
||||||
(if-let (((not (seq-empty-p info)))
|
(if (display-graphic-p)
|
||||||
(buff (current-buffer)))
|
(progn
|
||||||
(with-current-buffer my/-eglot-documentation-buffer
|
(posframe-show " *flycheck-error-posframe*"
|
||||||
(read-only-mode -1)
|
:string message
|
||||||
(erase-buffer)
|
:position (point)
|
||||||
(insert info)
|
:max-width 80
|
||||||
(special-mode)
|
:border-width 2
|
||||||
(read-only-mode 1)
|
:border-color "white")
|
||||||
(when (not (get-buffer-window my/-eglot-documentation-buffer nil))
|
(clear-this-command-keys)
|
||||||
(switch-to-buffer-other-window my/-eglot-documentation-buffer t)
|
(push (read-event) unread-command-events)
|
||||||
(switch-to-buffer-other-window buff t)))))))))
|
(posframe-hide " *flycheck-error-posframe*"))
|
||||||
(defun my/-eglot-setup ()
|
(popup-tip message)))))
|
||||||
"Setup eldoc variables for `eglot-managed-mode-hook'."
|
(use-package consult-flycheck
|
||||||
(setq-local eldoc-echo-area-use-multiline-p nil
|
:bind (:map flycheck-mode-map
|
||||||
evil-lookup-func #'my/eglot-documentation-at-point)
|
("C-c C-e" . consult-flycheck)))
|
||||||
(evil-define-key '(normal motion) 'local
|
|
||||||
"K" #'evil-lookup
|
;; lsp-mode
|
||||||
"gR" #'eglot-rename
|
(use-package consult-lsp)
|
||||||
"gA" #'eglot-code-actions
|
(use-package lsp-mode
|
||||||
"gs" #'consult-eglot-symbols)
|
:hook (((c-ts-mode c++-ts-mode java-ts-mode rust-ts-mode python-ts-mode
|
||||||
(eglot-inlay-hints-mode -1))
|
latex-mode markdown-mode blueprint-ts-mode) . lsp-mode)
|
||||||
(setq eglot-autoshutdown t)
|
(lsp-mode . my/-setup-lsp-mode-buffer))
|
||||||
:config
|
:init
|
||||||
(add-to-list 'eglot-server-programs
|
(setq lsp-completion-provider :none)
|
||||||
(cons '(c-mode c-ts-mode c++-mode c++-ts-mode objc-mode)
|
(defun my/-setup-lsp-mode-buffer ()
|
||||||
'("clangd" "--all-scopes-completion" "--background-index"
|
"Called by `lsp-mode-hook' to setup lsp-mode buffers."
|
||||||
"--clang-tidy" "--completion-style=detailed"
|
(lsp-headerline-breadcrumb-mode -1)
|
||||||
"--header-insertion=never" "--pch-storage=memory"
|
(lsp-inlay-hints-mode -1)
|
||||||
"--malloc-trim" "--function-arg-placeholders")))
|
(evil-define-key '(normal visual motion) 'local
|
||||||
(advice-add 'eglot-completion-at-point :around #'cape-wrap-buster))
|
"gR" #'lsp-rename
|
||||||
|
"gA" #'lsp-execute-code-action
|
||||||
|
"gs" #'consult-lsp-symbols)
|
||||||
|
(setq-local evil-lookup-func #'lsp-describe-thing-at-point)))
|
||||||
|
|
||||||
;; yasnippet
|
;; yasnippet
|
||||||
(use-package yasnippet
|
(use-package yasnippet
|
||||||
@ -652,7 +703,6 @@ COMMAND and COMINT are like `compile'."
|
|||||||
|
|
||||||
;; magit
|
;; magit
|
||||||
(use-package magit
|
(use-package magit
|
||||||
:bind ("C-x C-y" . magit)
|
|
||||||
:init
|
:init
|
||||||
(evil-define-key '(normal visual motion) magit-mode-map
|
(evil-define-key '(normal visual motion) magit-mode-map
|
||||||
"s" #'magit-stage-file
|
"s" #'magit-stage-file
|
||||||
|
Loading…
Reference in New Issue
Block a user