Skip to content

Commit 126a41b

Browse files
committed
Update docs for g:LspFindLocations
1 parent d57ed61 commit 126a41b

3 files changed

Lines changed: 46 additions & 9 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ call LspOptionsSet(#{
155155
\ customCompletionKinds: v:false,
156156
\ completionKinds: {},
157157
\ filterCompletionDuplicates: v:false,
158+
\ condensedCompletionMenu: v:false,
158159
\ })
159160
```
160161

autoload/lsp/lspserver.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ def FindLocations(lspserver: dict<any>, peek: bool, method: string, args: dict<a
10141014

10151015
# Result: Location[] | null
10161016
if reply->empty() || reply.result->empty()
1017-
util.WarnMsg('No references found')
1017+
util.WarnMsg('No location found')
10181018
return
10191019
endif
10201020

@@ -1026,7 +1026,7 @@ def FindLocations(lspserver: dict<any>, peek: bool, method: string, args: dict<a
10261026
})
10271027
endif
10281028

1029-
symbol.ShowLocations(lspserver, reply.result, peek, 'Symbol References')
1029+
symbol.ShowLocations(lspserver, reply.result, peek, 'Symbol Locations')
10301030
enddef
10311031

10321032
# process the 'textDocument/documentHighlight' reply from the LSP server

doc/lsp.txt

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ CONTENTS *lsp-contents*
2222
12. Highlight Groups ......................... |lsp-highlight-groups|
2323
13. Debugging ................................ |lsp-debug|
2424
14. Custom Command Handlers .................. |lsp-custom-commands|
25-
15. Custom LSP Completion Kinds .............. |lsp-custom-kinds|
26-
16. Multiple Language Servers for a buffer ... |lsp-multiple-servers|
27-
17. Language Servers Features ................ |lsp-features|
28-
18. License .................................. |lsp-license|
25+
15. Custom Locations Request ................. |lsp-custom-locations|
26+
16. Custom LSP Completion Kinds .............. |lsp-custom-kinds|
27+
17. Multiple Language Servers for a buffer ... |lsp-multiple-servers|
28+
18. Language Servers Features ................ |lsp-features|
29+
19. License .................................. |lsp-license|
2930

3031
==============================================================================
3132
1. Overview *lsp-overview*
@@ -1796,7 +1797,42 @@ contains the LSP Command interface fields. Refer to the LSP specification for
17961797
more information about the "Command" interface.
17971798

17981799
==============================================================================
1799-
15. Custom LSP Completion Kinds *lsp-custom-kinds*
1800+
15. Custom Locations Request *lsp-custom-locations*
1801+
1802+
Language server may support non-standard locations request. To display the
1803+
locations of the symbol under cursor, you can use the
1804+
g:LspFindLocations(server_name, peek, method, args) function. "server_name" is
1805+
then "name" you pass in LspAddServer(). "peek" is a boolean value. If true, it
1806+
displays the list of locations in a popup menu, otherwise in a new locations
1807+
list. It behaves like |:LspPeekReferences| and |:LspShowReferences| .
1808+
For example: >
1809+
1810+
vim9script
1811+
1812+
g:LspAddServer([{
1813+
filetype: ["cpp"],
1814+
name: 'ccls',
1815+
path: '/usr/bin/ccls',
1816+
}])
1817+
1818+
autocmd Filetype cpp {
1819+
# x (xref)
1820+
# bases of up to 3 levels
1821+
nmap <buffer> <localleader>b <scriptcmd>g:LspFindLocations('ccls', false, "$ccls/inheritance", {})<cr>
1822+
nmap <buffer> <localleader>B <scriptcmd>g:LspFindLocations('ccls', false, "$ccls/inheritance", {"levels": 3})<cr>
1823+
# derived of up to 3 levels
1824+
nmap <buffer> <localleader>d <scriptcmd>g:LspFindLocations('ccls', false, "$ccls/inheritance", {"derived": v:true})<cr>
1825+
nmap <buffer> <localleader>D <scriptcmd>g:LspFindLocations('ccls', false, "$ccls/inheritance", {"derived": v:true, "levels": 3})<cr>
1826+
# caller
1827+
nmap <buffer> <localleader>c <scriptcmd>g:LspFindLocations('ccls', false, "$ccls/call")<cr>
1828+
# callee
1829+
nmap <buffer> <localleader>C <scriptcmd>g:LspFindLocations('ccls', false, "$ccls/call", {"callee": v:true})<cr>
1830+
# member
1831+
nmap <buffer> <localleader>m <scriptcmd>g:LspFindLocations('ccls', false, "$ccls/member")<cr>
1832+
}
1833+
1834+
==============================================================================
1835+
16. Custom LSP Completion Kinds *lsp-custom-kinds*
18001836

18011837
When a completion popup is triggered, the LSP client will use a default kind
18021838
list to show in the completion "kind" section, to customize it, you need to
@@ -1854,7 +1890,7 @@ In the completion popup, will show something like this: >
18541890
| ... |
18551891
<
18561892
==============================================================================
1857-
16. Multiple Language Servers for a buffer *lsp-multiple-servers*
1893+
17. Multiple Language Servers for a buffer *lsp-multiple-servers*
18581894

18591895
It's possible to run multiple language servers for a given buffer.
18601896

@@ -1945,7 +1981,7 @@ everything else: >
19451981
])
19461982
<
19471983
==============================================================================
1948-
17. Language Server Features *lsp-features*
1984+
18. Language Server Features *lsp-features*
19491985

19501986
When using multiple language servers for a given file type, by providing the
19511987
configuration |lsp-cfg-features| it is possible to specify which language

0 commit comments

Comments
 (0)