Move and map interactive eglot/c++ function
This commit is contained in:
parent
c41ae8995b
commit
0f5c5bb288
3 changed files with 47 additions and 29 deletions
|
@ -16,6 +16,8 @@
|
||||||
- [[#configure][Configure]]
|
- [[#configure][Configure]]
|
||||||
- [[#project-compile-settings][Project compile settings]]
|
- [[#project-compile-settings][Project compile settings]]
|
||||||
- [[#known-issues-with-bear-on-macos][Known issues with bear on macOS]]
|
- [[#known-issues-with-bear-on-macos][Known issues with bear on macOS]]
|
||||||
|
- [[#appendix][Appendix]]
|
||||||
|
- [[#eglot-specific-bindings][Eglot specific bindings]]
|
||||||
|
|
||||||
* Description
|
* Description
|
||||||
This module adds support for the C-family of languages: C, C++, and Objective-C.
|
This module adds support for the C-family of languages: C, C++, and Objective-C.
|
||||||
|
@ -42,7 +44,7 @@ This module adds support for the C-family of languages: C, C++, and Objective-C.
|
||||||
+ [[https://github.com/jimhourihan/glsl-mode][glsl-mode]]*
|
+ [[https://github.com/jimhourihan/glsl-mode][glsl-mode]]*
|
||||||
+ [[https://github.com/guidoschmidt/company-glsl][company-glsl]]*
|
+ [[https://github.com/guidoschmidt/company-glsl][company-glsl]]*
|
||||||
+ =+lsp=
|
+ =+lsp=
|
||||||
+ [[https://github.com/MaskRay/emacs-ccls][ccls]]
|
+ [[https://github.com/MaskRay/emacs-ccls][ccls]] if =:tools lsp= has *no* =+eglot= flag
|
||||||
+ =-lsp=
|
+ =-lsp=
|
||||||
+ [[https://github.com/Sarcasm/irony-mode][irony]]
|
+ [[https://github.com/Sarcasm/irony-mode][irony]]
|
||||||
+ [[https://github.com/ikirill/irony-eldoc][irony-eldoc]]
|
+ [[https://github.com/ikirill/irony-eldoc][irony-eldoc]]
|
||||||
|
@ -173,3 +175,12 @@ bear gmake
|
||||||
Additional info:
|
Additional info:
|
||||||
+ [[https://github.com/rizsotto/Bear/issues/158][Empty compilation database with compiler in /usr/local]]
|
+ [[https://github.com/rizsotto/Bear/issues/158][Empty compilation database with compiler in /usr/local]]
|
||||||
+ [[https://github.com/rizsotto/Bear/issues/152][Workaround for 'Empty compilation database on OS X Captain]]
|
+ [[https://github.com/rizsotto/Bear/issues/152][Workaround for 'Empty compilation database on OS X Captain]]
|
||||||
|
|
||||||
|
* Appendix
|
||||||
|
** Eglot specific bindings
|
||||||
|
When using =+lsp= and =:tools (lsp +eglot)=, lsp-mode is replaced with eglot,
|
||||||
|
and an additional function to get inheritance type hierarchy is added
|
||||||
|
| Binding | Description |
|
||||||
|
|------------------------------+--------------------------------------------------|
|
||||||
|
| ~<localleader> c t~ | ~Display inheritance type hierarchy (upwards)~ |
|
||||||
|
| ~<prefix> <localleader> c t~ | ~Display inheritance type hierarchy (downwards)~ |
|
||||||
|
|
|
@ -122,6 +122,34 @@ simpler."
|
||||||
#'rtags-imenu
|
#'rtags-imenu
|
||||||
#'imenu)))
|
#'imenu)))
|
||||||
|
|
||||||
|
;; Eglot specific helper, courtesy of MaskRay
|
||||||
|
;;;###autoload
|
||||||
|
(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")))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; Hooks
|
;; Hooks
|
||||||
|
|
|
@ -237,6 +237,12 @@ 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))
|
||||||
|
;; Map eglot specific helper
|
||||||
|
(map! :localleader
|
||||||
|
:after cc-mode
|
||||||
|
:map c++-mode-map
|
||||||
|
:n :desc "Show type inheritance hierarchy" "ct" #'eglot-ccls-inheritance-hierarchy)
|
||||||
|
|
||||||
;; NOTE : This setting is untested yet
|
;; NOTE : This setting is untested yet
|
||||||
(after! eglot
|
(after! eglot
|
||||||
;; IS-MAC custom configuration
|
;; IS-MAC custom configuration
|
||||||
|
@ -245,34 +251,7 @@ If rtags or rdm aren't available, fail silently instead of throwing a breaking e
|
||||||
((:ccls . ((:clang . ,(list :extraArgs ["-isystem/Library/Developer/CommandLineTools/usr/include/c++/v1"
|
((:ccls . ((:clang . ,(list :extraArgs ["-isystem/Library/Developer/CommandLineTools/usr/include/c++/v1"
|
||||||
"-isystem/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
|
"-isystem/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
|
||||||
"-isystem/usr/local/include"]
|
"-isystem/usr/local/include"]
|
||||||
:resourceDir (string-trim (shell-command-to-string "clang -print-resource-dir")))))))))
|
: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")))))
|
|
||||||
|
|
||||||
(use-package! ccls
|
(use-package! ccls
|
||||||
:when (and (featurep! +lsp) (not (featurep! :tools lsp +eglot)))
|
:when (and (featurep! +lsp) (not (featurep! :tools lsp +eglot)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue