Change to lsp-mode
This commit is contained in:
parent
d39d3b2d41
commit
3becf805be
192
init.el
192
init.el
@ -339,8 +339,8 @@ visual states."
|
||||
(defun my/consult-setup-minibuffer-completion ()
|
||||
(setq-local completion-in-region-function #'consult-completion-in-region))
|
||||
(evil-declare-motion #'consult-line))
|
||||
(use-package consult-eglot
|
||||
:commands consult-eglot-symbols)
|
||||
;; (use-package consult-eglot
|
||||
;; :commands consult-eglot-symbols)
|
||||
|
||||
;; integration for embark and consult
|
||||
(use-package embark-consult
|
||||
@ -394,32 +394,34 @@ visual states."
|
||||
;; popup.el
|
||||
(use-package popup)
|
||||
|
||||
;; popwin
|
||||
;; posframe
|
||||
(use-package posframe)
|
||||
|
||||
;; flymake
|
||||
(use-package flymake
|
||||
:bind (:map flymake-mode-map
|
||||
("C-c e" . my/flymake-show-diagnostic-at-point)
|
||||
("C-c C-e" . consult-flymake))
|
||||
:hook (emacs-lisp-mode . flymake-mode)
|
||||
:init
|
||||
(defun my/flymake-show-diagnostic-at-point ()
|
||||
(interactive)
|
||||
(if-let ((pos (point))
|
||||
(diag (and flymake-mode
|
||||
(get-char-property pos 'flymake-diagnostic)))
|
||||
(message (flymake--diag-text diag)))
|
||||
(if (display-graphic-p)
|
||||
(progn
|
||||
(posframe-show " *flymake-error-posframe*"
|
||||
:string message
|
||||
:position (point)
|
||||
:max-width 80)
|
||||
(clear-this-command-keys)
|
||||
(push (read-event) unread-command-events)
|
||||
(posframe-hide " *flymake-error-posframe*"))
|
||||
(popup-tip message)))))
|
||||
;; (use-package flymake
|
||||
;; :bind (:map flymake-mode-map
|
||||
;; ("C-c e" . my/flymake-show-diagnostic-at-point)
|
||||
;; ("C-c C-e" . consult-flymake))
|
||||
;; ;; :hook (emacs-lisp-mode . flymake-mode)
|
||||
;; :init
|
||||
;; (defun my/flymake-show-diagnostic-at-point ()
|
||||
;; (interactive)
|
||||
;; (if-let ((pos (point))
|
||||
;; (diag (and flymake-mode
|
||||
;; (get-char-property pos 'flymake-diagnostic)))
|
||||
;; (message (flymake--diag-text diag)))
|
||||
;; (if (display-graphic-p)
|
||||
;; (progn
|
||||
;; (posframe-show " *flymake-error-posframe*"
|
||||
;; :string message
|
||||
;; :position (point)
|
||||
;; :max-width 80
|
||||
;; :border-width 2
|
||||
;; :border-color "white")
|
||||
;; (clear-this-command-keys)
|
||||
;; (push (read-event) unread-command-events)
|
||||
;; (posframe-hide " *flymake-error-posframe*"))
|
||||
;; (popup-tip message)))))
|
||||
|
||||
;; eldoc
|
||||
(use-package eldoc
|
||||
@ -433,54 +435,103 @@ visual states."
|
||||
(add-hook 'xref-backend-functions #'dumb-jump-xref-activate))
|
||||
|
||||
;; eglot
|
||||
(use-package eglot
|
||||
:demand t
|
||||
: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)
|
||||
(eglot-managed-mode . my/-eglot-setup))
|
||||
;; (use-package eglot
|
||||
;; :demand t
|
||||
;; :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)
|
||||
;; (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
|
||||
(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."
|
||||
(setq flycheck-display-errors-function nil)
|
||||
(defun my/flycheck-show-diagnostic-at-point ()
|
||||
(interactive)
|
||||
(if-let (server (eglot-current-server))
|
||||
(if-let ((flycheck-mode)
|
||||
(errors (flycheck-overlay-errors-at (point)))
|
||||
(message (apply 'concat
|
||||
(mapcar
|
||||
(lambda (error)
|
||||
(concat "•" (flycheck-error-message error) "\n"))
|
||||
errors))))
|
||||
(if (display-graphic-p)
|
||||
(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")))
|
||||
(advice-add 'eglot-completion-at-point :around #'cape-wrap-buster))
|
||||
(posframe-show " *flycheck-error-posframe*"
|
||||
:string message
|
||||
:position (point)
|
||||
:max-width 80
|
||||
:border-width 2
|
||||
:border-color "white")
|
||||
(clear-this-command-keys)
|
||||
(push (read-event) unread-command-events)
|
||||
(posframe-hide " *flycheck-error-posframe*"))
|
||||
(popup-tip message)))))
|
||||
(use-package consult-flycheck
|
||||
:bind (:map flycheck-mode-map
|
||||
("C-c C-e" . consult-flycheck)))
|
||||
|
||||
;; lsp-mode
|
||||
(use-package consult-lsp)
|
||||
(use-package lsp-mode
|
||||
:hook (((c-ts-mode c++-ts-mode java-ts-mode rust-ts-mode python-ts-mode
|
||||
latex-mode markdown-mode blueprint-ts-mode) . lsp-mode)
|
||||
(lsp-mode . my/-setup-lsp-mode-buffer))
|
||||
:init
|
||||
(setq lsp-completion-provider :none)
|
||||
(defun my/-setup-lsp-mode-buffer ()
|
||||
"Called by `lsp-mode-hook' to setup lsp-mode buffers."
|
||||
(lsp-headerline-breadcrumb-mode -1)
|
||||
(lsp-inlay-hints-mode -1)
|
||||
(evil-define-key '(normal visual motion) 'local
|
||||
"gR" #'lsp-rename
|
||||
"gA" #'lsp-execute-code-action
|
||||
"gs" #'consult-lsp-symbols)
|
||||
(setq-local evil-lookup-func #'lsp-describe-thing-at-point)))
|
||||
|
||||
;; yasnippet
|
||||
(use-package yasnippet
|
||||
@ -652,7 +703,6 @@ COMMAND and COMINT are like `compile'."
|
||||
|
||||
;; magit
|
||||
(use-package magit
|
||||
:bind ("C-x C-y" . magit)
|
||||
:init
|
||||
(evil-define-key '(normal visual motion) magit-mode-map
|
||||
"s" #'magit-stage-file
|
||||
|
Loading…
Reference in New Issue
Block a user