mirror of
https://github.com/MaskRay/ccls.git
synced 2025-06-07 16:54:54 +00:00
Use $ccls/{call,inheritance,member}
parent
e67d9aa3a6
commit
31cb83bf41
57
Emacs.md
57
Emacs.md
@ -133,49 +133,50 @@ For a symbol named `Name::FooBar`, all of `FooBar`, `foo bar`, `nafoba` find the
|
|||||||
|
|
||||||
Aside from definitions/references/workspace symbol, ccls provides some LSP extensions that find base/derived classes/methods, vars of a type, callers of a function. You may call:
|
Aside from definitions/references/workspace symbol, ccls provides some LSP extensions that find base/derived classes/methods, vars of a type, callers of a function. You may call:
|
||||||
```elisp
|
```elisp
|
||||||
(lsp-find-custom "$ccls/callers")
|
;; direct callers
|
||||||
|
(lsp-find-custom "$ccls/call")
|
||||||
|
;; callers up to 2 levels
|
||||||
|
(lsp-find-custom "$ccls/call" '(:levels 2))
|
||||||
|
;; direct callees
|
||||||
|
(lsp-find-custom "$ccls/call" '(:callee t))
|
||||||
|
|
||||||
(lsp-find-custom "$ccls/vars")
|
(lsp-find-custom "$ccls/vars")
|
||||||
; Use lsp-goto-implementation or lsp-ui-peek-find-implementation for derived types/functions
|
; Use lsp-goto-implementation or lsp-ui-peek-find-implementation for derived types/functions
|
||||||
|
|
||||||
;; Alternatively, use lsp-ui-peek interface
|
;; Alternatively, use lsp-ui-peek interface
|
||||||
(lsp-ui-peek-find-custom 'callers "$ccls/callers")
|
(lsp-ui-peek-find-custom 'caller "$ccls/call")
|
||||||
|
(lsp-ui-peek-find-custom 'callee "$ccls/call" '(:callee t))
|
||||||
|
|
||||||
(defun ccls/vars (kind) (lsp-ui-peek-find-custom 'vars "$ccls/vars" (plist-put (lsp--text-document-position-params) :kind kind)))
|
(defun ccls/vars (kind) (lsp-ui-peek-find-custom 'vars "$ccls/vars" `(:kind ,kind)))
|
||||||
(ccls/vars 3) ;; field or local variable
|
(ccls/vars 3) ;; field or local variable
|
||||||
(ccls/vars 1) ;; field
|
(ccls/vars 1) ;; field
|
||||||
(ccls/vars 4) ;; parameter
|
(ccls/vars 4) ;; parameter
|
||||||
```
|
```
|
||||||
|
|
||||||
There are flattened versions of hierarchies with `:flat t`:
|
Recommended helpers:
|
||||||
|
|
||||||
```elisp
|
```elisp
|
||||||
(defun ccls/bases ()
|
(defun ccls/callee ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(lsp-ui-peek-find-custom 'base "$ccls/inheritanceHierarchy"
|
(lsp-ui-peek-find-custom 'callee "$ccls/call" '(:callee t)))
|
||||||
(append (lsp--text-document-position-params) '(:flat t :level 3))))
|
(defun ccls/caller ()
|
||||||
(defun ccls/derived ()
|
|
||||||
(interactive)
|
(interactive)
|
||||||
(lsp-ui-peek-find-custom 'derived "$ccls/inheritanceHierarchy"
|
(lsp-ui-peek-find-custom 'caller "$ccls/call"))
|
||||||
(append (lsp--text-document-position-params) '(:flat t :level 3 :derived t))))
|
(defun ccls/vars (kind)
|
||||||
|
(lsp-ui-peek-find-custom 'vars "$ccls/vars" `(:kind ,kind)))
|
||||||
|
(defun ccls/base (level)
|
||||||
|
(lsp-ui-peek-find-custom 'base "$ccls/inheritance" `(:level ,level)))
|
||||||
|
(defun ccls/derived (level)
|
||||||
|
(lsp-ui-peek-find-custom 'derived "$ccls/inheritance" `(:level ,level :derived t)))
|
||||||
|
(defun ccls/member ()
|
||||||
|
(interactive)
|
||||||
|
(lsp-ui-peek-find-custom 'member "$ccls/member"))
|
||||||
|
|
||||||
|
;; ccls/vars ccls/base ccls/derived have a parameter while others are interactive.
|
||||||
```
|
```
|
||||||
|
|
||||||
Hierarchies provide a flattened xref interface:
|
Hierarchies provide a flattened xref interface:
|
||||||
|
|
||||||
```elisp
|
|
||||||
(defun ccls/bases ()
|
|
||||||
(interactive)
|
|
||||||
(lsp-ui-peek-find-custom 'base "$ccls/inheritanceHierarchy"
|
|
||||||
(append (lsp--text-document-position-params) '(:flat t :level 3))))
|
|
||||||
(defun ccls/derived ()
|
|
||||||
(interactive)
|
|
||||||
(lsp-ui-peek-find-custom 'derived "$ccls/inheritanceHierarchy"
|
|
||||||
(append (lsp--text-document-position-params) '(:flat t :level 3 :derived t))))
|
|
||||||
(defun ccls/members ()
|
|
||||||
(interactive)
|
|
||||||
(lsp-ui-peek-find-custom 'base "$ccls/memberHierarchy"
|
|
||||||
(append (lsp--text-document-position-params) '(:flat t))))
|
|
||||||
```
|
|
||||||
|
|
||||||
### Documentation (comments)
|
### Documentation (comments)
|
||||||
|
|
||||||
lsp-ui-doc.el renders comments in a child frame (Emacs >= 26) or inline (< 26).
|
lsp-ui-doc.el renders comments in a child frame (Emacs >= 26) or inline (< 26).
|
||||||
@ -249,20 +250,20 @@ For the long story, refer to the corresponding [emacs-devel thread](https://list
|
|||||||
### Call/member/inheritance Hierarchies
|
### Call/member/inheritance Hierarchies
|
||||||
|
|
||||||
`M-x ccls-member-hierarchy`
|
`M-x ccls-member-hierarchy`
|
||||||

|

|
||||||
|
|
||||||
```elisp
|
```elisp
|
||||||
(ccls-call-hierarchy nil) ; caller hierarchy
|
(ccls-call-hierarchy nil) ; caller hierarchy
|
||||||
(ccls-call-hierarchy t) ; callee hierarchy
|
(ccls-call-hierarchy t) ; callee hierarchy
|
||||||
```
|
```
|
||||||

|

|
||||||
|
|
||||||
```elisp
|
```elisp
|
||||||
(ccls-inheritance-hierarchy nil) ; base hierarchy
|
(ccls-inheritance-hierarchy nil) ; base hierarchy
|
||||||
(ccls-inheritance-hierarchy t) ; derived hierarchy
|
(ccls-inheritance-hierarchy t) ; derived hierarchy
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### `ccls-navigate`
|
### `ccls-navigate`
|
||||||
|
|
||||||
|
@ -73,36 +73,44 @@ nn <silent> xl :call LanguageClient#findLocations({'method':'$ccls/navigate','di
|
|||||||
### Custom cross references
|
### Custom cross references
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
|
" bases
|
||||||
|
nn <silent> xb :call LanguageClient#findLocations({'method':'$ccls/inheritance'})<cr>
|
||||||
" bases of up to 3 levels
|
" bases of up to 3 levels
|
||||||
nn <silent> xb :call LanguageClient#findLocations({'method':'$ccls/inheritanceHierarchy','flat':v:true,'levels':3,'derived':v:false})<cr>
|
nn <silent> xB :call LanguageClient#findLocations({'method':'$ccls/inheritance','levels':3})<cr>
|
||||||
" derived of up to 3 levels
|
" derived of up to 3 levels
|
||||||
nn <silent> xd :call LanguageClient#findLocations({'method':'$ccls/inheritanceHierarchy','flat':v:true,'levels':3,'derived':v:true})<cr>
|
nn <silent> xd :call LanguageClient#findLocations({'method':'$ccls/inheritance','derived':v:true})<cr>
|
||||||
nn <silent> xe :call LanguageClient#findLocations({'method':'$ccls/callers'})<cr>
|
" derived of up to 3 levels
|
||||||
nn <silent> xm :call LanguageClient#findLocations({'method':'$ccls/memberHierarchy','flat':v:true})<cr>
|
nn <silent> xD :call LanguageClient#findLocations({'method':'$ccls/inheritance','derived':v:true,'levels':3})<cr>
|
||||||
nn <silent> xt :call LanguageClient#textDocument_typeDefinition()<cr>
|
|
||||||
nn <silent> xv :call LanguageClient#findLocations({'method':'$ccls/vars'})<cr>
|
" caller
|
||||||
nn <silent> xV :call LanguageClient#findLocations({'method':'$ccls/vars','kind':1})<cr>
|
nn <silent> xc :call LanguageClient#findLocations({'method':'$ccls/call'})<cr>
|
||||||
|
" callee
|
||||||
|
nn <silent> xC :call LanguageClient#findLocations({'method':'$ccls/call','callee':v:true})<cr>
|
||||||
|
|
||||||
|
" $ccls/member
|
||||||
|
nn <silent> xm :call LanguageClient#findLocations({'method':'$ccls/member'})<cr>
|
||||||
|
|
||||||
nn xx x
|
nn xx x
|
||||||
```
|
```
|
||||||
|
|
||||||
`$ccls/inheritanceHierarchy flat:t derived:false`: base classes/overridden methods/specialized from
|
`$ccls/inheritance derived:false`: base classes/overridden methods/specialized from
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
`$ccls/inheritanceHierarchy flat:t derived:true`
|
`$ccls/inheritance derived:true`
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
`$ccls/callers`: callers of a function
|
`$ccls/call`: callers/callees of a function
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
The more general `$ccls/callHierarchy` has not been implemented by a Vim plugin.
|
|
||||||
|
|
||||||
`$ccls/vars`: instances of a type
|
`$ccls/vars`: instances of a type
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
`$ccls/memberHierarchy flat:t`: fields of a struct/class/union/...
|
`$ccls/member`: fields of a struct/class/union/...
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
There are also hierarchical views of `$ccls/call` `$ccls/inheritance` `$ccls/member` (see the Emacs page) but they have not been implemented by a Vim plugin.
|
||||||
|
Loading…
Reference in New Issue
Block a user