[review] Changes

This commit is contained in:
Gerry Agbobada 2020-05-28 11:12:35 +02:00
parent 6a163fd5c1
commit 718d9a2690
No known key found for this signature in database
GPG key ID: 53F94866E84818F6
5 changed files with 46 additions and 53 deletions

View file

@ -58,7 +58,7 @@
:desc "LSP Format buffer/region" "F" #'eglot-format :desc "LSP Format buffer/region" "F" #'eglot-format
:desc "LSP Rename" "r" #'eglot-rename :desc "LSP Rename" "r" #'eglot-rename
:desc "LSP Find declaration" "j" #'eglot-find-declaration :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 ;;; <leader> f --- file
(:prefix-map ("f" . "file") (:prefix-map ("f" . "file")

View file

@ -237,41 +237,42 @@ If rtags or rdm aren't available, fail silently instead of throwing a breaking e
(lsp!)))) (lsp!))))
(when (and (featurep! +lsp) (featurep! :tools lsp +eglot)) (when (and (featurep! +lsp) (featurep! :tools lsp +eglot))
;; TODO : test this value ;; NOTE : This setting is untested yet
;; IS-MAC custom configuration (after! eglot
(when IS-MAC ;; IS-MAC custom configuration
(add-to-list 'eglot-workspace-configuration (when IS-MAC
((:ccls . ((:clang . ,(list :extraArgs ["-isystem/Library/Developer/CommandLineTools/usr/include/c++/v1" (add-to-list 'eglot-workspace-configuration
"-isystem/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include" ((:ccls . ((:clang . ,(list :extraArgs ["-isystem/Library/Developer/CommandLineTools/usr/include/c++/v1"
"-isystem/usr/local/include"] "-isystem/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
:resourceDir (string-trim (shell-command-to-string "clang -print-resource-dir"))))))))) "-isystem/usr/local/include"]
;; Eglot specific helper, courtesy of MaskRay :resourceDir (string-trim (shell-command-to-string "clang -print-resource-dir")))))))))
(defun eglot-ccls-inheritance-hierarchy (&optional derived) ;; Eglot specific helper, courtesy of MaskRay
"Show inheritance hierarchy for the thing at point. (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 If DERIVED is non-nil (interactively, with prefix argument), show
the children of class at point." the children of class at point."
(interactive "P") (interactive "P")
(if-let* ((res (jsonrpc-request (if-let* ((res (jsonrpc-request
(eglot--current-server-or-lose) (eglot--current-server-or-lose)
:$ccls/inheritance :$ccls/inheritance
(append (eglot--TextDocumentPositionParams) (append (eglot--TextDocumentPositionParams)
`(:derived ,(if derived t :json-false)) `(:derived ,(if derived t :json-false))
'(:levels 100) '(:hierarchy t)))) '(:levels 100) '(:hierarchy t))))
(tree (list (cons 0 res)))) (tree (list (cons 0 res))))
(with-help-window "*ccls inheritance*" (with-help-window "*ccls inheritance*"
(with-current-buffer standard-output (with-current-buffer standard-output
(while tree (while tree
(pcase-let ((`(,depth . ,node) (pop tree))) (pcase-let ((`(,depth . ,node) (pop tree)))
(cl-destructuring-bind (&key uri range) (plist-get node :location) (cl-destructuring-bind (&key uri range) (plist-get node :location)
(insert (make-string depth ?\ ) (plist-get node :name) "\n") (insert (make-string depth ?\ ) (plist-get node :name) "\n")
(make-text-button (+ (point-at-bol 0) depth) (point-at-eol 0) (make-text-button (+ (point-at-bol 0) depth) (point-at-eol 0)
'action (lambda (_arg) 'action (lambda (_arg)
(interactive) (interactive)
(find-file (eglot--uri-to-path uri)) (find-file (eglot--uri-to-path uri))
(goto-char (car (eglot--range-region range))))) (goto-char (car (eglot--range-region range)))))
(cl-loop for child across (plist-get node :children) (cl-loop for child across (plist-get node :children)
do (push (cons (1+ depth) child) tree))))))) do (push (cons (1+ depth) child) tree)))))))
(eglot--error "Hierarchy unavailable")))) (eglot--error "Hierarchy unavailable")))))
(use-package! ccls (use-package! ccls
:when (and (featurep! +lsp) (not (featurep! :tools lsp +eglot))) :when (and (featurep! +lsp) (not (featurep! :tools lsp +eglot)))

View file

@ -14,10 +14,7 @@
:config :config
(set-popup-rule! "^\\*eglot-help" :size 0.35 :quit t :select t) (set-popup-rule! "^\\*eglot-help" :size 0.35 :quit t :select t)
(when (featurep! :checkers syntax) (when (featurep! :checkers syntax)
;; Eager loading which is okay-ish since we want eglot to feed flycheck as soon as possible. (after! flycheck
(load! "flycheck-eglot.el") (load! "flycheck-eglot.el")))
(require 'flycheck-eglot))
(set-lookup-handlers! 'eglot--managed-mode (set-lookup-handlers! 'eglot--managed-mode
:documentation #'+eglot/documentation-lookup-handler :documentation #'+eglot/documentation-lookup-handler))
:definition '(xref-find-definitions :async t)
:references '(xref-find-references :async t)))

View file

@ -1,7 +1,5 @@
;;; flycheck-eglot --- Hacky eglot support in flycheck -*- lexical-binding: t; -*- ;;; flycheck-eglot --- Hacky eglot support in flycheck -*- lexical-binding: t; -*-
(require 'flycheck)
;;; Code: ;;; Code:
(defun flycheck-eglot--start (checker callback) (defun flycheck-eglot--start (checker callback)
"Clean up errors when done. "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) (push 'eglot flycheck-checkers)
(defun +doom/eglot-prefer-flycheck-h () (defun +doom-eglot-prefer-flycheck-h ()
(when eglot--managed-mode (when eglot--managed-mode
(when-let ((current-checker (flycheck-get-checker-for-buffer))) (when-let ((current-checker (flycheck-get-checker-for-buffer)))
(unless (equal current-checker 'eglot) (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) (flycheck-mode 1)
(flymake-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 ;;; flycheck-eglot.el ends here

View file

@ -3,10 +3,9 @@
(if (featurep! +eglot) (if (featurep! +eglot)
(package! eglot :pin "d99a4478a9") (package! eglot :pin "d99a4478a9")
(progn (package! lsp-mode :pin "81d62d581b21d847783831e6e5ca9d3c63fe9a4d")
(package! lsp-mode :pin "81d62d581b21d847783831e6e5ca9d3c63fe9a4d") (package! lsp-ui :pin "271b47cb33f11915295911f7cf8575f8a82a5e1c")
(package! lsp-ui :pin "271b47cb33f11915295911f7cf8575f8a82a5e1c") (when (featurep! :completion ivy)
(when (featurep! :completion ivy) (package! lsp-ivy :pin "dce58b5509271bbedb53ba9d0278dcb563a43977"))
(package! lsp-ivy :pin "dce58b5509271bbedb53ba9d0278dcb563a43977")) (when (featurep! :completion helm)
(when (featurep! :completion helm) (package! helm-lsp :pin "6b5ce182d7c94c62b55b8f7d0c7e643b2c30e560")))
(package! helm-lsp :pin "6b5ce182d7c94c62b55b8f7d0c7e643b2c30e560"))))