[review] Changes
This commit is contained in:
parent
6a163fd5c1
commit
718d9a2690
5 changed files with 46 additions and 53 deletions
|
@ -58,7 +58,7 @@
|
|||
:desc "LSP Format buffer/region" "F" #'eglot-format
|
||||
:desc "LSP Rename" "r" #'eglot-rename
|
||||
:desc "LSP Find declaration" "j" #'eglot-find-declaration
|
||||
:desc "LSP Find implementation" "J" #' eglot-find-implementation))
|
||||
:desc "LSP Find implementation" "J" #'eglot-find-implementation))
|
||||
|
||||
;;; <leader> f --- file
|
||||
(:prefix-map ("f" . "file")
|
||||
|
|
|
@ -237,41 +237,42 @@ If rtags or rdm aren't available, fail silently instead of throwing a breaking e
|
|||
(lsp!))))
|
||||
|
||||
(when (and (featurep! +lsp) (featurep! :tools lsp +eglot))
|
||||
;; TODO : test this value
|
||||
;; IS-MAC custom configuration
|
||||
(when IS-MAC
|
||||
(add-to-list 'eglot-workspace-configuration
|
||||
((:ccls . ((:clang . ,(list :extraArgs ["-isystem/Library/Developer/CommandLineTools/usr/include/c++/v1"
|
||||
"-isystem/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
|
||||
"-isystem/usr/local/include"]
|
||||
:resourceDir (string-trim (shell-command-to-string "clang -print-resource-dir")))))))))
|
||||
;; Eglot specific helper, courtesy of MaskRay
|
||||
(defun eglot-ccls-inheritance-hierarchy (&optional derived)
|
||||
"Show inheritance hierarchy for the thing at point.
|
||||
;; NOTE : This setting is untested yet
|
||||
(after! eglot
|
||||
;; IS-MAC custom configuration
|
||||
(when IS-MAC
|
||||
(add-to-list 'eglot-workspace-configuration
|
||||
((:ccls . ((:clang . ,(list :extraArgs ["-isystem/Library/Developer/CommandLineTools/usr/include/c++/v1"
|
||||
"-isystem/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
|
||||
"-isystem/usr/local/include"]
|
||||
:resourceDir (string-trim (shell-command-to-string "clang -print-resource-dir")))))))))
|
||||
;; Eglot specific helper, courtesy of MaskRay
|
||||
(defun eglot-ccls-inheritance-hierarchy (&optional derived)
|
||||
"Show inheritance hierarchy for the thing at point.
|
||||
If DERIVED is non-nil (interactively, with prefix argument), show
|
||||
the children of class at point."
|
||||
(interactive "P")
|
||||
(if-let* ((res (jsonrpc-request
|
||||
(eglot--current-server-or-lose)
|
||||
:$ccls/inheritance
|
||||
(append (eglot--TextDocumentPositionParams)
|
||||
`(:derived ,(if derived t :json-false))
|
||||
'(:levels 100) '(:hierarchy t))))
|
||||
(tree (list (cons 0 res))))
|
||||
(with-help-window "*ccls inheritance*"
|
||||
(with-current-buffer standard-output
|
||||
(while tree
|
||||
(pcase-let ((`(,depth . ,node) (pop tree)))
|
||||
(cl-destructuring-bind (&key uri range) (plist-get node :location)
|
||||
(insert (make-string depth ?\ ) (plist-get node :name) "\n")
|
||||
(make-text-button (+ (point-at-bol 0) depth) (point-at-eol 0)
|
||||
'action (lambda (_arg)
|
||||
(interactive)
|
||||
(find-file (eglot--uri-to-path uri))
|
||||
(goto-char (car (eglot--range-region range)))))
|
||||
(cl-loop for child across (plist-get node :children)
|
||||
do (push (cons (1+ depth) child) tree)))))))
|
||||
(eglot--error "Hierarchy unavailable"))))
|
||||
(interactive "P")
|
||||
(if-let* ((res (jsonrpc-request
|
||||
(eglot--current-server-or-lose)
|
||||
:$ccls/inheritance
|
||||
(append (eglot--TextDocumentPositionParams)
|
||||
`(:derived ,(if derived t :json-false))
|
||||
'(:levels 100) '(:hierarchy t))))
|
||||
(tree (list (cons 0 res))))
|
||||
(with-help-window "*ccls inheritance*"
|
||||
(with-current-buffer standard-output
|
||||
(while tree
|
||||
(pcase-let ((`(,depth . ,node) (pop tree)))
|
||||
(cl-destructuring-bind (&key uri range) (plist-get node :location)
|
||||
(insert (make-string depth ?\ ) (plist-get node :name) "\n")
|
||||
(make-text-button (+ (point-at-bol 0) depth) (point-at-eol 0)
|
||||
'action (lambda (_arg)
|
||||
(interactive)
|
||||
(find-file (eglot--uri-to-path uri))
|
||||
(goto-char (car (eglot--range-region range)))))
|
||||
(cl-loop for child across (plist-get node :children)
|
||||
do (push (cons (1+ depth) child) tree)))))))
|
||||
(eglot--error "Hierarchy unavailable")))))
|
||||
|
||||
(use-package! ccls
|
||||
:when (and (featurep! +lsp) (not (featurep! :tools lsp +eglot)))
|
||||
|
|
|
@ -14,10 +14,7 @@
|
|||
:config
|
||||
(set-popup-rule! "^\\*eglot-help" :size 0.35 :quit t :select t)
|
||||
(when (featurep! :checkers syntax)
|
||||
;; Eager loading which is okay-ish since we want eglot to feed flycheck as soon as possible.
|
||||
(load! "flycheck-eglot.el")
|
||||
(require 'flycheck-eglot))
|
||||
(after! flycheck
|
||||
(load! "flycheck-eglot.el")))
|
||||
(set-lookup-handlers! 'eglot--managed-mode
|
||||
:documentation #'+eglot/documentation-lookup-handler
|
||||
:definition '(xref-find-definitions :async t)
|
||||
:references '(xref-find-references :async t)))
|
||||
:documentation #'+eglot/documentation-lookup-handler))
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
;;; flycheck-eglot --- Hacky eglot support in flycheck -*- lexical-binding: t; -*-
|
||||
|
||||
(require 'flycheck)
|
||||
|
||||
;;; Code:
|
||||
(defun flycheck-eglot--start (checker callback)
|
||||
"Clean up errors when done.
|
||||
|
@ -44,7 +42,7 @@ CALLBACK is the function that we need to call when we are done, on all the error
|
|||
|
||||
(push 'eglot flycheck-checkers)
|
||||
|
||||
(defun +doom/eglot-prefer-flycheck-h ()
|
||||
(defun +doom-eglot-prefer-flycheck-h ()
|
||||
(when eglot--managed-mode
|
||||
(when-let ((current-checker (flycheck-get-checker-for-buffer)))
|
||||
(unless (equal current-checker 'eglot)
|
||||
|
@ -53,8 +51,6 @@ CALLBACK is the function that we need to call when we are done, on all the error
|
|||
(flycheck-mode 1)
|
||||
(flymake-mode -1)))
|
||||
|
||||
(add-hook 'eglot--managed-mode-hook #'+doom/eglot-prefer-flycheck-h)
|
||||
(add-hook 'eglot--managed-mode-hook #'+doom-eglot-prefer-flycheck-h)
|
||||
|
||||
(provide 'flycheck-eglot)
|
||||
;;; flycheck-eglot.el ends here
|
||||
|
|
@ -3,10 +3,9 @@
|
|||
|
||||
(if (featurep! +eglot)
|
||||
(package! eglot :pin "d99a4478a9")
|
||||
(progn
|
||||
(package! lsp-mode :pin "81d62d581b21d847783831e6e5ca9d3c63fe9a4d")
|
||||
(package! lsp-ui :pin "271b47cb33f11915295911f7cf8575f8a82a5e1c")
|
||||
(when (featurep! :completion ivy)
|
||||
(package! lsp-ivy :pin "dce58b5509271bbedb53ba9d0278dcb563a43977"))
|
||||
(when (featurep! :completion helm)
|
||||
(package! helm-lsp :pin "6b5ce182d7c94c62b55b8f7d0c7e643b2c30e560"))))
|
||||
(package! lsp-mode :pin "81d62d581b21d847783831e6e5ca9d3c63fe9a4d")
|
||||
(package! lsp-ui :pin "271b47cb33f11915295911f7cf8575f8a82a5e1c")
|
||||
(when (featurep! :completion ivy)
|
||||
(package! lsp-ivy :pin "dce58b5509271bbedb53ba9d0278dcb563a43977"))
|
||||
(when (featurep! :completion helm)
|
||||
(package! helm-lsp :pin "6b5ce182d7c94c62b55b8f7d0c7e643b2c30e560")))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue