mirror of
https://github.com/MaskRay/ccls.git
synced 2025-02-16 21:58:08 +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:
|
||||
```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")
|
||||
; Use lsp-goto-implementation or lsp-ui-peek-find-implementation for derived types/functions
|
||||
|
||||
;; 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 1) ;; field
|
||||
(ccls/vars 4) ;; parameter
|
||||
```
|
||||
|
||||
There are flattened versions of hierarchies with `:flat t`:
|
||||
Recommended helpers:
|
||||
|
||||
```elisp
|
||||
(defun ccls/bases ()
|
||||
(defun ccls/callee ()
|
||||
(interactive)
|
||||
(lsp-ui-peek-find-custom 'base "$ccls/inheritanceHierarchy"
|
||||
(append (lsp--text-document-position-params) '(:flat t :level 3))))
|
||||
(defun ccls/derived ()
|
||||
(lsp-ui-peek-find-custom 'callee "$ccls/call" '(:callee t)))
|
||||
(defun ccls/caller ()
|
||||
(interactive)
|
||||
(lsp-ui-peek-find-custom 'derived "$ccls/inheritanceHierarchy"
|
||||
(append (lsp--text-document-position-params) '(:flat t :level 3 :derived t))))
|
||||
(lsp-ui-peek-find-custom 'caller "$ccls/call"))
|
||||
(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:
|
||||
|
||||
```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)
|
||||
|
||||
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
|
||||
|
||||
`M-x ccls-member-hierarchy`
|
||||
![$ccls/memberHierarchy](https://ptpb.pw/iOSt.gif)
|
||||
![$ccls/member hierarchy:true](https://ptpb.pw/iOSt.gif)
|
||||
|
||||
```elisp
|
||||
(ccls-call-hierarchy nil) ; caller hierarchy
|
||||
(ccls-call-hierarchy t) ; callee hierarchy
|
||||
```
|
||||
![$ccls/callHierarchy](https://ptpb.pw/Dv8K.gif)
|
||||
![$ccls/call](https://ptpb.pw/Dv8K.gif)
|
||||
|
||||
```elisp
|
||||
(ccls-inheritance-hierarchy nil) ; base hierarchy
|
||||
(ccls-inheritance-hierarchy t) ; derived hierarchy
|
||||
```
|
||||
|
||||
![$ccls/inheritanceHierarchy](https://ptpb.pw/JkyT.gif)
|
||||
![$ccls/inheritance hierarchy:true](https://ptpb.pw/JkyT.gif)
|
||||
|
||||
### `ccls-navigate`
|
||||
|
||||
|
@ -73,36 +73,44 @@ nn <silent> xl :call LanguageClient#findLocations({'method':'$ccls/navigate','di
|
||||
### Custom cross references
|
||||
|
||||
```vim
|
||||
" bases
|
||||
nn <silent> xb :call LanguageClient#findLocations({'method':'$ccls/inheritance'})<cr>
|
||||
" 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
|
||||
nn <silent> xd :call LanguageClient#findLocations({'method':'$ccls/inheritanceHierarchy','flat':v:true,'levels':3,'derived':v:true})<cr>
|
||||
nn <silent> xe :call LanguageClient#findLocations({'method':'$ccls/callers'})<cr>
|
||||
nn <silent> xm :call LanguageClient#findLocations({'method':'$ccls/memberHierarchy','flat':v:true})<cr>
|
||||
nn <silent> xt :call LanguageClient#textDocument_typeDefinition()<cr>
|
||||
nn <silent> xv :call LanguageClient#findLocations({'method':'$ccls/vars'})<cr>
|
||||
nn <silent> xV :call LanguageClient#findLocations({'method':'$ccls/vars','kind':1})<cr>
|
||||
nn <silent> xd :call LanguageClient#findLocations({'method':'$ccls/inheritance','derived':v:true})<cr>
|
||||
" derived of up to 3 levels
|
||||
nn <silent> xD :call LanguageClient#findLocations({'method':'$ccls/inheritance','derived':v:true,'levels':3})<cr>
|
||||
|
||||
" caller
|
||||
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
|
||||
```
|
||||
|
||||
`$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:false](https://ptpb.pw/pEDL.jpg)
|
||||
![$ccls/inheritanceHierarchy derived:false](https://ptpb.pw/pEDL.jpg)
|
||||
|
||||
`$ccls/inheritanceHierarchy flat:t derived:true`
|
||||
`$ccls/inheritance derived:true`
|
||||
|
||||
![$ccls/inheritanceHierarchy flat:t derived:true](https://ptpb.pw/QgCd.jpg)
|
||||
![$ccls/inheritanceHierarchy derived:true](https://ptpb.pw/QgCd.jpg)
|
||||
|
||||
`$ccls/callers`: callers of a function
|
||||
`$ccls/call`: callers/callees of a function
|
||||
|
||||
![$ccls/callers](https://ptpb.pw/2RDi.jpg)
|
||||
|
||||
The more general `$ccls/callHierarchy` has not been implemented by a Vim plugin.
|
||||
|
||||
`$ccls/vars`: instances of a type
|
||||
|
||||
![$ccls/vars](https://ptpb.pw/peyX.jpg)
|
||||
|
||||
`$ccls/memberHierarchy flat:t`: fields of a struct/class/union/...
|
||||
`$ccls/member`: fields of a struct/class/union/...
|
||||
|
||||
![$ccls/memberHierarchy flat:t](https://ptpb.pw/V8WR.jpg)
|
||||
![$ccls/member](https://ptpb.pw/V8WR.jpg)
|
||||
|
||||
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