lang/cc: fix ccls/eglot commands for vanilla users

And conform them to Doom's naming conventions.
This commit is contained in:
Henrik Lissner 2020-10-11 21:50:15 -04:00
parent dc50c6bae3
commit b76cac9b9a
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 45 additions and 43 deletions

View file

@ -129,7 +129,7 @@ simpler."
;; Eglot specific helper, courtesy of MaskRay ;; Eglot specific helper, courtesy of MaskRay
;;;###autoload ;;;###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. "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."
@ -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-show-vars ccls-show-base ccls-show-derived ccls-show-members have a
;; (ccls/base 1) direct bases ;; parameter while others are interactive.
;; (ccls/derived 1) direct derived ;;
;; (ccls/member 2) => 2 (Type) => nested classes / types in a namespace ;; (+cc/ccls-show-base 1) direct bases
;; (ccls/member 3) => 3 (Func) => member functions / functions in a namespace ;; (+cc/ccls-show-derived 1) direct derived
;; (ccls/member 0) => member variables / variables in a namespace ;; (+cc/ccls-show-member 2) => 2 (Type) => nested classes / types in a namespace
;; (ccls/vars 1) => field ;; (+cc/ccls-show-member 3) => 3 (Func) => member functions / functions in a namespace
;; (ccls/vars 2) => local variable ;; (+cc/ccls-show-member 0) => member variables / variables in a namespace
;; (ccls/vars 3) => field or local variable. 3 = 1 | 2 ;; (+cc/ccls-show-vars 1) => field
;; (ccls/vars 4) => parameter ;; (+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 ;;;###autoload
(defun +ccls/callee () (defun +cc/ccls-show-callee ()
"Show callees of symbol under point." "Show callees of symbol under point."
(interactive) (interactive)
(lsp-ui-peek-find-custom "$ccls/call" '(:callee t))) (lsp-ui-peek-find-custom "$ccls/call" '(:callee t)))
;;;###autoload ;;;###autoload
(defun +ccls/caller () (defun +cc/ccls-show-caller ()
"Show callers of symbol under point." "Show callers of symbol under point."
(interactive) (interactive)
(lsp-ui-peek-find-custom "$ccls/call")) (lsp-ui-peek-find-custom "$ccls/call"))
;;;###autoload ;;;###autoload
(defun ccls/vars (kind) (defun +cc/ccls-show-vars (kind)
"Show variables of type KIND as symbol under point. "Show variables of type KIND as symbol under point.
1 -> field 1 -> field
2 -> local variable 2 -> local variable
@ -262,17 +264,17 @@ header files."
(lsp-ui-peek-find-custom "$ccls/vars" `(:kind ,kind))) (lsp-ui-peek-find-custom "$ccls/vars" `(:kind ,kind)))
;;;###autoload ;;;###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)." "Show bases of class under point up to LEVELS levels (1 for direct bases)."
(lsp-ui-peek-find-custom "$ccls/inheritance" `(:levels ,levels))) (lsp-ui-peek-find-custom "$ccls/inheritance" `(:levels ,levels)))
;;;###autoload ;;;###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)." "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))) (lsp-ui-peek-find-custom "$ccls/inheritance" `(:levels ,levels :derived t)))
;;;###autoload ;;;###autoload
(defun ccls/member (kind) (defun +cc/ccls-show-member (kind)
"Show member elements of kind KIND for class/namespace under point. "Show member elements of kind KIND for class/namespace under point.
0 -> member variables/ variables in a namespace 0 -> member variables/ variables in a namespace
2 -> nested classes / types 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 ;; The meaning of :role corresponds to https://github.com/maskray/ccls/blob/master/src/symbol.h
;;;###autoload ;;;###autoload
(defun +ccls/references-address () (defun +cc/ccls-show-references-address ()
"References w/ Role::Address bit (e.g. variables explicitly being taken addresses)" "References w/ Role::Address bit (e.g. variables explicitly being taken addresses)"
(interactive) (interactive)
(lsp-ui-peek-find-custom "textDocument/references" (lsp-ui-peek-find-custom "textDocument/references"
(plist-put (lsp--text-document-position-params) :role 128))) (plist-put (lsp--text-document-position-params) :role 128)))
;;;###autoload ;;;###autoload
(defun +ccls/references-macro () (defun +cc/ccls-show-references-macro ()
"References w/ Role::Dynamic bit (macro expansions)" "References w/ Role::Dynamic bit (macro expansions)"
(interactive) (interactive)
(lsp-ui-peek-find-custom "textDocument/references" (lsp-ui-peek-find-custom "textDocument/references"
(plist-put (lsp--text-document-position-params) :role 64))) (plist-put (lsp--text-document-position-params) :role 64)))
;;;###autoload ;;;###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)" "References w/o Role::Call bit (e.g. where functions are taken addresses)"
(interactive) (interactive)
(lsp-ui-peek-find-custom "textDocument/references" (lsp-ui-peek-find-custom "textDocument/references"
(plist-put (lsp--text-document-position-params) :excludeRole 32))) (plist-put (lsp--text-document-position-params) :excludeRole 32)))
;;;###autoload ;;;###autoload
(defun +ccls/references-read () (defun +cc/ccls-show-references-read ()
"References w/ Role::Read" "References w/ Role::Read"
(interactive) (interactive)
(lsp-ui-peek-find-custom "textDocument/references" (lsp-ui-peek-find-custom "textDocument/references"
(plist-put (lsp--text-document-position-params) :role 8))) (plist-put (lsp--text-document-position-params) :role 8)))
;;;###autoload ;;;###autoload
(defun +ccls/references-write () (defun +cc/ccls-show-references-write ()
"References w/ Role::Write" "References w/ Role::Write"
(interactive) (interactive)
(lsp-ui-peek-find-custom "textDocument/references" (lsp-ui-peek-find-custom "textDocument/references"

View file

@ -231,32 +231,32 @@ If rtags or rdm aren't available, fail silently instead of throwing a breaking e
c++-mode-local-vars-hook c++-mode-local-vars-hook
objc-mode-local-vars-hook) objc-mode-local-vars-hook)
#'lsp!) #'lsp!)
(map!
(:after ccls (map! :after ccls
:map (c-mode-map c++-mode-map) :map (c-mode-map c++-mode-map)
:n "C-h" (λ! (ccls-navigate "U")) :n "C-h" (cmd! (ccls-navigate "U"))
:n "C-j" (λ! (ccls-navigate "R")) :n "C-j" (cmd! (ccls-navigate "R"))
:n "C-k" (λ! (ccls-navigate "L")) :n "C-k" (cmd! (ccls-navigate "L"))
:n "C-l" (λ! (ccls-navigate "D")) :n "C-l" (cmd! (ccls-navigate "D"))
(:localleader (:localleader
:desc "Preprocess file" :n "lp" #'ccls-preprocess-file :desc "Preprocess file" "lp" #'ccls-preprocess-file
:desc "Reset cache and reload CCLS" :n "lf" #'ccls-reload) :desc "Reload cache & CCLS" "lf" #'ccls-reload)
(:after lsp-ui-peek (:after lsp-ui-peek
(:localleader (:localleader
:desc "Callers list" :n "c" #'+ccls/caller :desc "Callers list" "c" #'+cc/show-caller
:desc "Callees list" :n "C" #'+ccls/callee :desc "Callees list" "C" #'+cc/show-callee
:desc "References (address)" :n "a" #'+ccls/references-address :desc "References (address)" "a" #'+cc/ccls-show-references-address
:desc "References (not call)" :n "f" #'+ccls/references-not-call :desc "References (not call)" "f" #'+cc/ccls-show-references-not-call
:desc "References (Macro)" :n "m" #'+ccls/references-macro :desc "References (Macro)" "m" #'+cc/ccls-show-references-macro
:desc "References (Read)" :n "r" #'+ccls/references-read :desc "References (Read)" "r" #'+cc/ccls-show-references-read
:desc "References (Write)" :n "w" #'+ccls/references-write)))) :desc "References (Write)" "w" #'+cc/ccls-show-references-write)))
(when (featurep! :tools lsp +eglot) (when (featurep! :tools lsp +eglot)
;; Map eglot specific helper ;; Map eglot specific helper
(map! :localleader (map! :localleader
:after cc-mode :after cc-mode
:map c++-mode-map :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 ;; NOTE : This setting is untested yet
(after! eglot (after! eglot