diff --git a/modules/lang/cc/autoload.el b/modules/lang/cc/autoload.el index 9deb3b78a..1b94ade91 100644 --- a/modules/lang/cc/autoload.el +++ b/modules/lang/cc/autoload.el @@ -129,7 +129,7 @@ simpler." ;; Eglot specific helper, courtesy of MaskRay ;;;###autoload -(defun +cc/eglot-ccls-inheritance-hierarchy (&optional derived) +(defun +cc/eglot-ccls-show-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." @@ -227,33 +227,35 @@ header files." ;; -;; CCLS specific helpers +;;; CCLS specific helpers -;; ccls/vars ccls/base ccls/derived ccls/members have a parameter while others are interactive. -;; (ccls/base 1) direct bases -;; (ccls/derived 1) direct derived -;; (ccls/member 2) => 2 (Type) => nested classes / types in a namespace -;; (ccls/member 3) => 3 (Func) => member functions / functions in a namespace -;; (ccls/member 0) => member variables / variables in a namespace -;; (ccls/vars 1) => field -;; (ccls/vars 2) => local variable -;; (ccls/vars 3) => field or local variable. 3 = 1 | 2 -;; (ccls/vars 4) => parameter +;; ccls-show-vars ccls-show-base ccls-show-derived ccls-show-members have a +;; parameter while others are interactive. +;; +;; (+cc/ccls-show-base 1) direct bases +;; (+cc/ccls-show-derived 1) direct derived +;; (+cc/ccls-show-member 2) => 2 (Type) => nested classes / types in a namespace +;; (+cc/ccls-show-member 3) => 3 (Func) => member functions / functions in a namespace +;; (+cc/ccls-show-member 0) => member variables / variables in a namespace +;; (+cc/ccls-show-vars 1) => field +;; (+cc/ccls-show-vars 2) => local variable +;; (+cc/ccls-show-vars 3) => field or local variable. 3 = 1 | 2 +;; (+cc/ccls-show-vars 4) => parameter ;;;###autoload -(defun +ccls/callee () +(defun +cc/ccls-show-callee () "Show callees of symbol under point." (interactive) (lsp-ui-peek-find-custom "$ccls/call" '(:callee t))) ;;;###autoload -(defun +ccls/caller () +(defun +cc/ccls-show-caller () "Show callers of symbol under point." (interactive) (lsp-ui-peek-find-custom "$ccls/call")) ;;;###autoload -(defun ccls/vars (kind) +(defun +cc/ccls-show-vars (kind) "Show variables of type KIND as symbol under point. 1 -> field 2 -> local variable @@ -262,17 +264,17 @@ header files." (lsp-ui-peek-find-custom "$ccls/vars" `(:kind ,kind))) ;;;###autoload -(defun ccls/base (levels) +(defun +cc/ccls-show-base (levels) "Show bases of class under point up to LEVELS levels (1 for direct bases)." (lsp-ui-peek-find-custom "$ccls/inheritance" `(:levels ,levels))) ;;;###autoload -(defun ccls/derived (levels) +(defun +cc/ccls-show-derived (levels) "Show derived classes from class under point down to LEVELS levels (1 for direct derived)." (lsp-ui-peek-find-custom "$ccls/inheritance" `(:levels ,levels :derived t))) ;;;###autoload -(defun ccls/member (kind) +(defun +cc/ccls-show-member (kind) "Show member elements of kind KIND for class/namespace under point. 0 -> member variables/ variables in a namespace 2 -> nested classes / types in a namespace @@ -281,35 +283,35 @@ header files." ;; The meaning of :role corresponds to https://github.com/maskray/ccls/blob/master/src/symbol.h ;;;###autoload -(defun +ccls/references-address () +(defun +cc/ccls-show-references-address () "References w/ Role::Address bit (e.g. variables explicitly being taken addresses)" (interactive) (lsp-ui-peek-find-custom "textDocument/references" (plist-put (lsp--text-document-position-params) :role 128))) ;;;###autoload -(defun +ccls/references-macro () +(defun +cc/ccls-show-references-macro () "References w/ Role::Dynamic bit (macro expansions)" (interactive) (lsp-ui-peek-find-custom "textDocument/references" (plist-put (lsp--text-document-position-params) :role 64))) ;;;###autoload -(defun +ccls/references-not-call () +(defun +cc/ccls-show-references-not-call () "References w/o Role::Call bit (e.g. where functions are taken addresses)" (interactive) (lsp-ui-peek-find-custom "textDocument/references" (plist-put (lsp--text-document-position-params) :excludeRole 32))) ;;;###autoload -(defun +ccls/references-read () +(defun +cc/ccls-show-references-read () "References w/ Role::Read" (interactive) (lsp-ui-peek-find-custom "textDocument/references" (plist-put (lsp--text-document-position-params) :role 8))) ;;;###autoload -(defun +ccls/references-write () +(defun +cc/ccls-show-references-write () "References w/ Role::Write" (interactive) (lsp-ui-peek-find-custom "textDocument/references" diff --git a/modules/lang/cc/config.el b/modules/lang/cc/config.el index 66e2ee266..1e575fc5e 100644 --- a/modules/lang/cc/config.el +++ b/modules/lang/cc/config.el @@ -231,32 +231,32 @@ If rtags or rdm aren't available, fail silently instead of throwing a breaking e c++-mode-local-vars-hook objc-mode-local-vars-hook) #'lsp!) - (map! - (:after ccls - :map (c-mode-map c++-mode-map) - :n "C-h" (λ! (ccls-navigate "U")) - :n "C-j" (λ! (ccls-navigate "R")) - :n "C-k" (λ! (ccls-navigate "L")) - :n "C-l" (λ! (ccls-navigate "D")) - (:localleader - :desc "Preprocess file" :n "lp" #'ccls-preprocess-file - :desc "Reset cache and reload CCLS" :n "lf" #'ccls-reload) - (:after lsp-ui-peek - (:localleader - :desc "Callers list" :n "c" #'+ccls/caller - :desc "Callees list" :n "C" #'+ccls/callee - :desc "References (address)" :n "a" #'+ccls/references-address - :desc "References (not call)" :n "f" #'+ccls/references-not-call - :desc "References (Macro)" :n "m" #'+ccls/references-macro - :desc "References (Read)" :n "r" #'+ccls/references-read - :desc "References (Write)" :n "w" #'+ccls/references-write)))) + + (map! :after ccls + :map (c-mode-map c++-mode-map) + :n "C-h" (cmd! (ccls-navigate "U")) + :n "C-j" (cmd! (ccls-navigate "R")) + :n "C-k" (cmd! (ccls-navigate "L")) + :n "C-l" (cmd! (ccls-navigate "D")) + (:localleader + :desc "Preprocess file" "lp" #'ccls-preprocess-file + :desc "Reload cache & CCLS" "lf" #'ccls-reload) + (:after lsp-ui-peek + (:localleader + :desc "Callers list" "c" #'+cc/show-caller + :desc "Callees list" "C" #'+cc/show-callee + :desc "References (address)" "a" #'+cc/ccls-show-references-address + :desc "References (not call)" "f" #'+cc/ccls-show-references-not-call + :desc "References (Macro)" "m" #'+cc/ccls-show-references-macro + :desc "References (Read)" "r" #'+cc/ccls-show-references-read + :desc "References (Write)" "w" #'+cc/ccls-show-references-write))) (when (featurep! :tools lsp +eglot) ;; Map eglot specific helper (map! :localleader :after cc-mode :map c++-mode-map - :n :desc "Show type inheritance hierarchy" "ct" #'+cc/eglot-ccls-inheritance-hierarchy) + :desc "Show type inheritance hierarchy" "ct" #'+cc/eglot-ccls-inheritance-hierarchy) ;; NOTE : This setting is untested yet (after! eglot