Compare commits
366 Commits
Author | SHA1 | Date |
---|---|---|
|
3be5241bf9 | 2 weeks ago |
|
877a457473 | 3 weeks ago |
|
fd1f7e9a3d | 4 weeks ago |
|
d3c7e03113 | 4 weeks ago |
|
1c68f33ef2 | 4 weeks ago |
|
40c6bb3a5e | 4 weeks ago |
|
2def227e76 | 1 month ago |
|
736cba15dc | 2 months ago |
|
65df819a66 | 2 months ago |
|
6a02536445 | 3 months ago |
|
1af66ec104 | 3 months ago |
|
672d97facd | 3 months ago |
|
c8267c995d | 3 months ago |
|
c11ae3feed | 3 months ago |
|
c597965d0f | 4 months ago |
|
23489699f9 | 5 months ago |
|
a8b1019942 | 5 months ago |
|
d02d4c1c52 | 5 months ago |
|
29d5f05bf9 | 7 months ago |
|
5fb82ee1bc | 7 months ago |
|
b97b90140e | 7 months ago |
|
8f40d389fc | 7 months ago |
|
f6b208a24c | 7 months ago |
|
98540ed2a8 | 7 months ago |
|
40d1907f57 | 7 months ago |
|
4dbf5e1ef3 | 7 months ago |
|
3e05ae2b6c | 7 months ago |
|
229d4ee728 | 7 months ago |
|
0ce1009c92 | 7 months ago |
|
164e8ad43a | 7 months ago |
|
059973f557 | 7 months ago |
|
a4c94d315c | 7 months ago |
|
924139448f | 7 months ago |
|
231968a002 | 7 months ago |
|
18304b8a84 | 7 months ago |
|
236fb062d2 | 7 months ago |
|
5cf1459e03 | 7 months ago |
|
50973a602a | 8 months ago |
|
452eead83b | 8 months ago |
|
5c9719b235 | 8 months ago |
|
7632117666 | 8 months ago |
|
bedf65e668 | 8 months ago |
|
4d6b1b804f | 8 months ago |
|
e5ba624f85 | 8 months ago |
|
e6fcd5d7fb | 8 months ago |
|
354fb64b42 | 8 months ago |
|
3f0c3d75c3 | 8 months ago |
|
8906ef48d0 | 8 months ago |
|
8c06e1afe3 | 8 months ago |
|
7231ef9614 | 8 months ago |
|
cddb324eb0 | 8 months ago |
|
bf3c73aeb2 | 8 months ago |
|
516da37dcc | 8 months ago |
|
d6ff1ed594 | 8 months ago |
|
3c9398b599 | 9 months ago |
|
a9b63b0f9c | 9 months ago |
|
50dd4aeb24 | 9 months ago |
|
8661bcd7ff | 10 months ago |
|
4ba2c9557e | 11 months ago |
|
9d95f05a1b | 11 months ago |
|
f936d926b9 | 1 year ago |
|
b0e89b67e2 | 1 year ago |
|
1f58bc3b8a | 1 year ago |
|
b9931d5c01 | 1 year ago |
|
431ab5b6e8 | 1 year ago |
|
b81dacac5d | 1 year ago |
|
f298a844c5 | 1 year ago |
|
306af1c545 | 1 year ago |
|
d2fcc426ce | 1 year ago |
|
7aa4a623ae | 1 year ago |
|
957bc960f0 | 1 year ago |
|
2e70f736f8 | 1 year ago |
|
346397e039 | 1 year ago |
|
ab42ffc5c6 | 1 year ago |
|
d88d393d09 | 1 year ago |
|
aa9406036a | 1 year ago |
|
edd9d838f8 | 1 year ago |
|
439d30631b | 1 year ago |
|
c9b3de4e1c | 1 year ago |
|
59b89e60a8 | 1 year ago |
|
38f1c37bbc | 1 year ago |
|
f058b3fc40 | 1 year ago |
|
ac18ae5d57 | 1 year ago |
|
86ed353f62 | 1 year ago |
|
99e126fe4e | 1 year ago |
|
b8ad53bce4 | 1 year ago |
|
1f7bc9ab20 | 1 year ago |
|
274581e35e | 1 year ago |
|
8b3d26453d | 1 year ago |
|
a47462eab1 | 1 year ago |
|
f16029fd25 | 1 year ago |
|
c000890350 | 1 year ago |
|
8d96e06d18 | 1 year ago |
|
6dc7a842f7 | 1 year ago |
|
11dfaa794a | 1 year ago |
|
ccf3861867 | 1 year ago |
|
77b235b2c9 | 1 year ago |
|
d202970180 | 1 year ago |
|
66d84151e9 | 1 year ago |
|
badf6fd16a | 1 year ago |
|
1fcb0045d1 | 1 year ago |
|
a801cf6b25 | 1 year ago |
|
ed53571834 | 1 year ago |
|
cf30481246 | 1 year ago |
|
08f8b2cf13 | 1 year ago |
|
3b4569067e | 1 year ago |
|
b8a69b6d06 | 1 year ago |
|
b1cb067f7c | 1 year ago |
|
0a6f7bff15 | 1 year ago |
|
1b2a0856f4 | 1 year ago |
|
7e95b1baae | 1 year ago |
|
a513485311 | 1 year ago |
|
5a289ac77d | 1 year ago |
|
bdc962a080 | 1 year ago |
|
51727a129c | 1 year ago |
|
c75914f7f6 | 1 year ago |
|
bace7a9110 | 1 year ago |
|
f2c9f1d005 | 2 years ago |
|
45a88c08a9 | 2 years ago |
|
5bc1f93fb1 | 2 years ago |
|
7965d9c1bc | 2 years ago |
|
b55f6101fb | 2 years ago |
|
9ecc909548 | 2 years ago |
|
a356035440 | 2 years ago |
|
c0bfecc6af | 2 years ago |
|
926dc63fa4 | 2 years ago |
|
14495a0603 | 2 years ago |
|
922a4264d8 | 2 years ago |
|
bd3dfe2ee2 | 2 years ago |
|
46ba7e9887 | 2 years ago |
|
e4a5dcd33f | 2 years ago |
|
f8c743396d | 2 years ago |
|
d1db210a88 | 2 years ago |
|
a6f181708e | 2 years ago |
|
6e94065243 | 2 years ago |
|
9efdb79a5c | 2 years ago |
|
ba24ea57db | 2 years ago |
|
82a8ce6a6a | 2 years ago |
|
050902a135 | 2 years ago |
|
48932f2160 | 2 years ago |
|
b48424e2bc | 2 years ago |
|
46804da825 | 2 years ago |
|
c6e6c57c86 | 2 years ago |
|
da978e3f53 | 2 years ago |
|
d77ab354d4 | 2 years ago |
|
6ee96c35b5 | 2 years ago |
|
ce81b4a6da | 2 years ago |
|
544c006a10 | 2 years ago |
|
7a88235bd1 | 2 years ago |
|
4353d64fa3 | 2 years ago |
|
c583e1a69d | 2 years ago |
|
273f614212 | 2 years ago |
|
b954695e00 | 2 years ago |
|
1f3b01acd1 | 2 years ago |
|
1cbad111c7 | 2 years ago |
|
e882757fb2 | 2 years ago |
|
bd2b48fe6b | 2 years ago |
|
cd98ca2c5b | 2 years ago |
|
451d761f76 | 2 years ago |
|
8278f71878 | 2 years ago |
|
443fd4d585 | 2 years ago |
|
10fd76d6d0 | 2 years ago |
|
8d00282020 | 2 years ago |
|
9afcd37854 | 2 years ago |
|
c70d032b08 | 2 years ago |
|
fb6d19ddf4 | 2 years ago |
|
af7fc7d649 | 2 years ago |
|
d8f19f6fc1 | 2 years ago |
|
df7f4d7229 | 2 years ago |
|
fb87a0b1b7 | 2 years ago |
|
927c464b70 | 2 years ago |
|
e9a40aca40 | 2 years ago |
|
edee3e39c6 | 2 years ago |
|
a7886fc055 | 2 years ago |
|
de018d9ae3 | 2 years ago |
|
ef0cee5bbd | 2 years ago |
|
ab2e383b20 | 2 years ago |
|
1b262556c0 | 2 years ago |
|
b4ff1c43b9 | 2 years ago |
|
ebd88f5d09 | 2 years ago |
|
28d245510f | 2 years ago |
|
213b30950e | 2 years ago |
|
f05d2ec142 | 2 years ago |
|
9f151cf718 | 2 years ago |
|
b131251ad8 | 2 years ago |
|
8978bdb1e3 | 2 years ago |
|
ae251289b3 | 2 years ago |
|
a9c223cc22 | 2 years ago |
|
0ab4b02ff7 | 2 years ago |
|
6c0e286170 | 2 years ago |
|
f24a337f5d | 2 years ago |
|
3d87ed3b87 | 2 years ago |
|
5713f79265 | 2 years ago |
|
01ef2ce1a1 | 2 years ago |
|
547f2bc15d | 2 years ago |
|
dc0b8504bb | 2 years ago |
|
486085070d | 2 years ago |
|
bc356d555f | 2 years ago |
|
5b5a946d73 | 2 years ago |
|
fca2fa5aaa | 2 years ago |
|
49dbca889d | 2 years ago |
|
861ae038dd | 2 years ago |
|
814b712e91 | 2 years ago |
|
dcc40278c5 | 2 years ago |
|
6736293182 | 2 years ago |
|
10ef469286 | 2 years ago |
|
4775d43218 | 2 years ago |
|
89dd02c927 | 2 years ago |
|
bbdf86a66e | 2 years ago |
|
ed47d386e6 | 2 years ago |
|
480824d3f3 | 2 years ago |
|
c3ef990390 | 2 years ago |
|
de5c88c766 | 2 years ago |
|
348ab9dced | 2 years ago |
|
967fd32bae | 2 years ago |
|
4aef8dc5f2 | 2 years ago |
|
0de6c290cf | 2 years ago |
|
9aad2978dc | 2 years ago |
|
49c3e5cd4d | 2 years ago |
|
47545e03c0 | 2 years ago |
|
e5d16e4488 | 2 years ago |
|
3d9a9582dd | 2 years ago |
|
05dfed9ed9 | 2 years ago |
|
05753da8db | 2 years ago |
|
4623677b2a | 2 years ago |
|
85e3f6e045 | 2 years ago |
|
c30ccd07c9 | 2 years ago |
|
4c5d0e67d0 | 2 years ago |
|
be6da35767 | 2 years ago |
|
f567f1b99c | 2 years ago |
|
a93f7cb20f | 2 years ago |
|
289f67013d | 2 years ago |
|
56b00b83d5 | 2 years ago |
|
3fe9a876c4 | 2 years ago |
|
acca6009e0 | 2 years ago |
|
792fd2831a | 2 years ago |
|
a225d18eaf | 2 years ago |
|
7d84a9f0c0 | 2 years ago |
|
22e858f261 | 2 years ago |
|
edba3efd1e | 2 years ago |
|
724d5f3439 | 2 years ago |
|
3dc8c02c39 | 2 years ago |
|
91d1366b65 | 2 years ago |
|
d951a5fcd2 | 2 years ago |
|
68eb18c310 | 2 years ago |
|
8d77c3ab1e | 2 years ago |
|
309afcd681 | 2 years ago |
|
9f7bd6ebff | 2 years ago |
|
aba0d89745 | 2 years ago |
|
c1b0694bef | 2 years ago |
|
9dee73010b | 2 years ago |
|
1b3a02df3e | 2 years ago |
|
f856fa7033 | 2 years ago |
|
1f6103ed95 | 2 years ago |
|
7bfd9157fe | 2 years ago |
|
48e35f4e56 | 2 years ago |
|
27442d2784 | 2 years ago |
|
3ad93531b5 | 2 years ago |
|
c15bae89ab | 2 years ago |
|
61a82559d6 | 2 years ago |
|
f8985d7aa2 | 2 years ago |
|
516d643ffe | 2 years ago |
|
6b4cfa3d59 | 2 years ago |
|
cce0e90544 | 2 years ago |
|
2f35446fbe | 2 years ago |
|
1908ea5175 | 2 years ago |
|
6c3ee44729 | 2 years ago |
|
6e937e9019 | 2 years ago |
|
01801ba8fa | 2 years ago |
|
d0ab595b93 | 2 years ago |
|
3f49769abc | 2 years ago |
|
32ddd66dd2 | 2 years ago |
|
feb780fb10 | 2 years ago |
|
ea2c207ec9 | 2 years ago |
|
b249d1680a | 2 years ago |
|
13c3dd4072 | 2 years ago |
|
a0eff2c5a3 | 2 years ago |
|
51a05252a5 | 2 years ago |
|
2e96dcd327 | 2 years ago |
|
ff4bcc6d83 | 2 years ago |
|
8a32139e1a | 2 years ago |
|
a73fb38ef9 | 2 years ago |
|
96ca715ea6 | 2 years ago |
|
45385ccc9a | 2 years ago |
|
4d93172915 | 2 years ago |
|
0ac13663cf | 2 years ago |
|
500553ae6b | 2 years ago |
|
c416d99f6f | 2 years ago |
|
d1836f4299 | 2 years ago |
|
5131b30ad7 | 2 years ago |
|
eb75b09a33 | 2 years ago |
|
93e28f36d0 | 2 years ago |
|
77b572dd5a | 2 years ago |
|
794e86057d | 2 years ago |
|
03d0aaa05d | 2 years ago |
|
9c67158d9c | 2 years ago |
|
0c31d692ee | 2 years ago |
|
9ceeb41b6f | 2 years ago |
|
0bdaf1f63c | 2 years ago |
|
c2c1c57136 | 2 years ago |
|
595263e8b4 | 2 years ago |
|
2f3e2847a3 | 2 years ago |
|
cd53b02f93 | 2 years ago |
|
15e6b315b7 | 2 years ago |
|
31f2f920e1 | 2 years ago |
|
ab4daceede | 2 years ago |
|
23e25c298e | 2 years ago |
|
8b43ed23e2 | 2 years ago |
|
8dbac5efc9 | 2 years ago |
|
d08d78f6a4 | 2 years ago |
|
3d217bffce | 2 years ago |
|
2ed33d7d60 | 2 years ago |
|
e55ae08e9d | 2 years ago |
|
d990da84a6 | 2 years ago |
|
bb018d541b | 2 years ago |
|
b69154f9ee | 2 years ago |
|
5c8b3b9ca1 | 2 years ago |
|
7f22411b1f | 2 years ago |
|
77dd031f8a | 2 years ago |
|
d8e4787bfb | 2 years ago |
|
ab96133b47 | 2 years ago |
|
34c3bc9c76 | 2 years ago |
|
46aeb778ce | 2 years ago |
|
035917c57a | 2 years ago |
|
a316e7f449 | 2 years ago |
|
209e5321a8 | 2 years ago |
|
4018cab16d | 2 years ago |
|
3e03e37d9f | 2 years ago |
|
5773f66d14 | 2 years ago |
|
74eccbd799 | 2 years ago |
|
0346fc3c0f | 2 years ago |
|
b2d846647b | 2 years ago |
|
cfe8738ad5 | 2 years ago |
|
982fe81922 | 2 years ago |
|
d024335c91 | 2 years ago |
|
3d6187e534 | 2 years ago |
|
41593cb7e4 | 2 years ago |
|
429cd16292 | 2 years ago |
|
2c7334e1b6 | 2 years ago |
|
3adbbaf509 | 2 years ago |
|
37e8b68506 | 2 years ago |
|
ff8ae83300 | 2 years ago |
|
b10964e5a2 | 2 years ago |
|
e4b2fc0afe | 2 years ago |
|
8e39f65f53 | 2 years ago |
|
2e43b8ee0a | 2 years ago |
|
2232317b0a | 2 years ago |
|
ff57a1f916 | 2 years ago |
|
0f181f1d4e | 2 years ago |
|
9ed6e64877 | 2 years ago |
|
f0c5610a1f | 2 years ago |
|
92f56ffe4b | 2 years ago |
|
76e0c8d3ff | 2 years ago |
|
c7872c83a8 | 2 years ago |
|
bf2e867354 | 2 years ago |
|
11d25933ad | 2 years ago |
|
21ddd7f2f6 | 2 years ago |
|
8e9bf39f13 | 2 years ago |
|
ccb1bac250 | 2 years ago |
|
1feacfb4bd | 2 years ago |
|
ded2a6510f | 2 years ago |
|
62477b294e | 2 years ago |
|
c03cbca758 | 2 years ago |
|
2d5290d3d6 | 2 years ago |
|
dcabc38a12 | 2 years ago |
|
c9f34ac179 | 2 years ago |
@ -0,0 +1,3 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: ray-x
|
@ -1,3 +1,6 @@
|
|||||||
|
selene.toml
|
||||||
lua/navigator.lua.bak
|
lua/navigator.lua.bak
|
||||||
tests/fixtures/tests
|
tests/fixtures/tests
|
||||||
|
.vim/
|
||||||
|
*cache*/
|
||||||
|
*target*/
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json",
|
||||||
|
"Lua.workspace.library": [
|
||||||
|
"${3rd}/luassert/library"
|
||||||
|
]
|
||||||
|
}
|
@ -0,0 +1,332 @@
|
|||||||
|
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
|
||||||
|
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
|
||||||
|
!_TAG_OUTPUT_EXCMD number /number, pattern, mixed, or combineV2/
|
||||||
|
!_TAG_OUTPUT_FILESEP slash /slash or backslash/
|
||||||
|
!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/
|
||||||
|
!_TAG_PATTERN_LENGTH_LIMIT 96 /0 for no limit/
|
||||||
|
!_TAG_PROC_CWD /home/ray/github/ray-x/navigator.lua/ //
|
||||||
|
!_TAG_PROGRAM_AUTHOR Universal Ctags Team //
|
||||||
|
!_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/
|
||||||
|
!_TAG_PROGRAM_URL https://ctags.io/ /official site/
|
||||||
|
!_TAG_PROGRAM_VERSION 5.9.0 /227c65e76/
|
||||||
|
Custom_fold_text lua/navigator/foldts.lua 20;" f
|
||||||
|
Fix lua/navigator/protocal.txt 374;" f
|
||||||
|
["sumneko_lua"] issue130/init.lua 62;" f
|
||||||
|
["tsserver"] issue130/init.lua 71;" f
|
||||||
|
['<Tab>'] playground/init.lua 72;" f
|
||||||
|
['sumneko_lua'] playground/init_130.lua 34;" f
|
||||||
|
['sumneko_lua'] playground/init_131.lua 22;" f
|
||||||
|
['sumneko_lua'] playground/init_lsp_installer.lua 22;" f
|
||||||
|
['tsserver'] playground/init_130.lua 43;" f
|
||||||
|
['tsserver'] playground/init_131.lua 31;" f
|
||||||
|
['tsserver'] playground/init_lsp_installer.lua 31;" f
|
||||||
|
\x21 tests/fixtures/tests 133;" f
|
||||||
|
_ lua/navigator/util.lua 300;" f
|
||||||
|
_update_sign lua/navigator/codeAction.lua 44;" f
|
||||||
|
_update_sign lua/navigator/codelens.lua 26;" f
|
||||||
|
_update_virtual_text lua/navigator/codeAction.lua 27;" f
|
||||||
|
action_virtual_call_back lua/navigator/codeAction.lua 141;" f
|
||||||
|
add lua/navigator/lspclient/clients.lua 54;" f
|
||||||
|
add_highlight lua/navigator/lspclient/highlight.lua 34;" f unknown:M
|
||||||
|
add_locs lua/navigator/dochighlight.lua 15;" f
|
||||||
|
add_servers lua/navigator/lspclient/clients.lua 680;" f
|
||||||
|
add_workspace_folder lua/navigator/workspace.lua 9;" f unknown:M
|
||||||
|
adjust_foldend lua/navigator/foldlsp.lua 120;" f unknown:M
|
||||||
|
adjust_foldstart lua/navigator/foldlsp.lua 116;" f unknown:M
|
||||||
|
async thread.lua 4;" f
|
||||||
|
async_hdlr lua/navigator/reference.lua 139;" f unknown:M
|
||||||
|
async_ref lua/navigator/reference.lua 148;" f
|
||||||
|
autocmd lua/navigator/lspclient/mapping.lua 216;" f
|
||||||
|
before lua/navigator/dochighlight.lua 125;" f
|
||||||
|
buf_func lua/navigator/treesitter.lua 442;" f unknown:M
|
||||||
|
buf_ts lua/navigator/treesitter.lua 489;" f unknown:M
|
||||||
|
bufs_ts lua/navigator/treesitter.lua 511;" f unknown:M
|
||||||
|
call_async lua/navigator/lspwrapper.lua 153;" f unknown:M
|
||||||
|
call_hierarchy_handler lua/navigator/cclshierarchy.lua 12;" f
|
||||||
|
call_hierarchy_handler lua/navigator/hierarchy.lua 12;" f
|
||||||
|
call_sync lua/navigator/lspwrapper.lua 145;" f unknown:M
|
||||||
|
callback lua/navigator/lspwrapper.lua 155;" f
|
||||||
|
check_cap lua/navigator/lspclient/mapping.lua 84;" f
|
||||||
|
check_capabilities lua/navigator/lspwrapper.lua 121;" f unknown:M
|
||||||
|
check_lhs lua/navigator/lspwrapper.lua 31;" f
|
||||||
|
clear_all_buf lua/navigator/util.lua 380;" f unknown:M
|
||||||
|
clear_buf lua/navigator/util.lua 366;" f unknown:M
|
||||||
|
clear_diag_VT lua/navigator/diagnostics.lua 325;" f
|
||||||
|
clear_usage_highlights lua/navigator/treesitter.lua 612;" f unknown:M
|
||||||
|
cmd_nohl lua/navigator/dochighlight.lua 201;" f
|
||||||
|
cmp_kind lua/navigator/lspclient/lspkind.lua 128;" f unknown:lspkind
|
||||||
|
code_action lua/navigator/codeAction.lua 161;" f unknown:code_action
|
||||||
|
code_action_prompt lua/navigator/codeAction.lua 188;" f unknown:code_action
|
||||||
|
code_action_req lua/navigator/codeAction.lua 145;" f
|
||||||
|
codelens_hdlr lua/navigator/codelens.lua 49;" f
|
||||||
|
comp_kind lua/navigator/lspclient/lspkind.lua 120;" f unknown:lspkind
|
||||||
|
config lua/navigator/diagnostics.lua 474;" f unknown:M
|
||||||
|
config playground/init.lua 32;" f
|
||||||
|
config playground/init.lua 47;" f
|
||||||
|
config playground/init.lua 60;" f
|
||||||
|
config playground/init_131.lua 17;" f
|
||||||
|
config playground/init_131.lua 51;" f
|
||||||
|
config playground/init_lsp_installer.lua 17;" f
|
||||||
|
config playground/init_lsp_installer.lua 51;" f
|
||||||
|
config playground/init_ts_only.lua 35;" f
|
||||||
|
config playground/init_ts_only.lua 52;" f
|
||||||
|
config_values lua/navigator.lua 212;" f unknown:M
|
||||||
|
config_values lua/navigator.lua.bak 47;" f unknown:M
|
||||||
|
ctags lua/navigator/ctags.lua 133;" f
|
||||||
|
ctags_gen lua/navigator/ctags.lua 54;" f
|
||||||
|
ctags_symbols lua/navigator/ctags.lua 85;" f
|
||||||
|
curriedDot playground/js/curry.js 1;" f
|
||||||
|
cut lua/navigator/lru.lua 60;" f
|
||||||
|
debounce_trailing lua/navigator/debounce.lua 3;" f unknown:M
|
||||||
|
debug_folds lua/navigator/foldlsp.lua 82;" f unknown:M
|
||||||
|
def lua/navigator/definition.lua 145;" f
|
||||||
|
def_preview lua/navigator/definition.lua 41;" f
|
||||||
|
definition_hdlr README.md 759;" f
|
||||||
|
definition_hdlr doc/navigator.txt 662;" f
|
||||||
|
definition_hdlr lua/navigator/definition.lua 8;" f
|
||||||
|
del lua/navigator/lru.lua 95;" f
|
||||||
|
del_keymap lua/navigator/lspclient/mapping.lua 131;" f
|
||||||
|
delete lua/navigator/lru.lua 145;" f
|
||||||
|
deprecated lua/navigator.lua 117;" f unknown:M
|
||||||
|
diag_hdlr lua/navigator/diagnostics.lua 196;" f
|
||||||
|
diagnositc_config_sign lua/navigator/lspclient/highlight.lua 7;" f unknown:M
|
||||||
|
dirname lua/navigator/lspclient/clients.lua 85;" f
|
||||||
|
disable lua/navigator/codelens.lua 99;" f unknown:M
|
||||||
|
displayName playground/js/closure.js 3;" f
|
||||||
|
documentHighlight lua/navigator/dochighlight.lua 218;" f
|
||||||
|
document_symbol_handler lua/navigator/symbols.lua 43;" f unknown:M
|
||||||
|
document_symbols lua/navigator/symbols.lua 21;" f unknown:M
|
||||||
|
empty lua/navigator/util.lua 425;" f unknown:M
|
||||||
|
encoding lua/navigator/util.lua 436;" f unknown:M
|
||||||
|
entry_to_item lua/navigator/ctags.lua 9;" f
|
||||||
|
error lua/navigator/util.lua 203;" f unknown:M
|
||||||
|
error lua/navigator/util.lua 460;" f unknown:M
|
||||||
|
error_marker lua/navigator/diagnostics.lua 57;" f
|
||||||
|
exclude lua/navigator/util.lua 341;" f unknown:M
|
||||||
|
expand playground/init.lua 65;" f
|
||||||
|
extend_config lua/navigator.lua 138;" f
|
||||||
|
extend_config lua/navigator.lua.bak 27;" f
|
||||||
|
extension lua/navigator/render.lua 12;" f
|
||||||
|
extract_result lua/navigator/lspwrapper.lua 109;" f
|
||||||
|
file_exists lua/navigator/util.lua 75;" f unknown:M
|
||||||
|
filename lua/navigator/render.lua 5;" f
|
||||||
|
find_definition lua/navigator/treesitter.lua 75;" f unknown:M
|
||||||
|
find_ts_func_by_range lua/navigator/lspwrapper.lua 246;" f
|
||||||
|
fmt lua/navigator/util.lua 208;" f unknown:M
|
||||||
|
fnamemodify lua/navigator/lspwrapper.lua 56;" f
|
||||||
|
fold_handler lua/navigator/foldlsp.lua 90;" f unknown:M
|
||||||
|
folds_levels lua/navigator/foldts.lua 53;" f
|
||||||
|
format_hdl lua/navigator/formatting.lua 4;" f
|
||||||
|
func thread.lua 1;" f
|
||||||
|
get lua/navigator/lru.lua 112;" f
|
||||||
|
getArgs lua/navigator/util.lua 245;" f unknown:M
|
||||||
|
getDir lua/navigator/util.lua 119;" f
|
||||||
|
get_all_nodes lua/navigator/treesitter.lua 267;" f
|
||||||
|
get_base lua/navigator/util.lua 109;" f unknown:M
|
||||||
|
get_cfg lua/navigator/lspclient/clients.lua 685;" f
|
||||||
|
get_count lua/navigator/diagnostics.lua 49;" f
|
||||||
|
get_current_winid lua/navigator/codeAction.lua 23;" f
|
||||||
|
get_current_winid lua/navigator/util.lua 387;" f unknown:M
|
||||||
|
get_data_from_file lua/navigator/util.lua 36;" f unknown:M
|
||||||
|
get_definitions lua/navigator/treesitter.lua 111;" f
|
||||||
|
get_fold_indic lua/navigator/foldlsp.lua 130;" f unknown:M
|
||||||
|
get_fold_indic lua/navigator/foldts.lua 162;" f unknown:M
|
||||||
|
get_icon lua/navigator/treesitter.lua 27;" f
|
||||||
|
get_keymaps_help lua/navigator/lspclient/mapping.lua 333;" f unknown:M
|
||||||
|
get_line_diagnostic lua/navigator/diagnostics.lua 452;" f unknown:M
|
||||||
|
get_namespace lua/navigator/codeAction.lua 19;" f
|
||||||
|
get_node_at_line lua/navigator/treesitter.lua 561;" f unknown:M
|
||||||
|
get_node_at_pos lua/navigator/treesitter.lua 616;" f unknown:M
|
||||||
|
get_node_scope lua/navigator/treesitter.lua 632;" f unknown:M
|
||||||
|
get_pads lua/navigator/render.lua 17;" f
|
||||||
|
get_relative_path lua/navigator/util.lua 137;" f unknown:M
|
||||||
|
get_scope lua/navigator/treesitter.lua 151;" f
|
||||||
|
get_smallest_context lua/navigator/treesitter.lua 213;" f
|
||||||
|
get_symbol lua/navigator/definition.lua 36;" f
|
||||||
|
get_symbol lua/navigator/dochighlight.lua 11;" f
|
||||||
|
get_symbol lua/navigator/lspwrapper.lua 24;" f unknown:M
|
||||||
|
goto_adjacent_usage lua/navigator/treesitter.lua 230;" f unknown:M
|
||||||
|
goto_adjent_reference lua/navigator/dochighlight.lua 161;" f
|
||||||
|
goto_definition lua/navigator/treesitter.lua 35;" f unknown:M
|
||||||
|
goto_next_usage lua/navigator/treesitter.lua 256;" f unknown:M
|
||||||
|
goto_previous_usage lua/navigator/treesitter.lua 259;" f unknown:M
|
||||||
|
handle_document_highlight lua/navigator/dochighlight.lua 141;" f
|
||||||
|
handlers['textDocument/codeLens'] lua/navigator/codelens.lua 75;" f unknown:vim.lsp
|
||||||
|
handlers['textDocument/documentHighlight'] lua/navigator/dochighlight.lua 229;" f unknown:vim.lsp
|
||||||
|
hi_symbol lua/navigator/dochighlight.lua 46;" f
|
||||||
|
hide_diagnostic lua/navigator/diagnostics.lua 336;" f unknown:M
|
||||||
|
highlight_usages lua/navigator/treesitter.lua 588;" f unknown:M
|
||||||
|
i tests/fixtures/tests 122;" f
|
||||||
|
implementation lua/navigator/implementation.lua 24;" f unknown:M
|
||||||
|
implementation_handler lua/navigator/implementation.lua 18;" f
|
||||||
|
incoming_calls lua/navigator/cclshierarchy.lua 72;" f unknown:M
|
||||||
|
incoming_calls lua/navigator/hierarchy.lua 80;" f unknown:M
|
||||||
|
incoming_calls_handler lua/navigator/cclshierarchy.lua 54;" f
|
||||||
|
incoming_calls_handler lua/navigator/hierarchy.lua 63;" f
|
||||||
|
info lua/navigator.lua 7;" f
|
||||||
|
info lua/navigator/util.lua 197;" f unknown:M
|
||||||
|
info lua/navigator/util.lua 464;" f unknown:M
|
||||||
|
init lua/navigator/lazyloader.lua 2;" f
|
||||||
|
init lua/navigator/lspclient/lspkind.lua 132;" f unknown:lspkind
|
||||||
|
inline lua/navigator/codelens.lua 117;" f unknown:M
|
||||||
|
io_read lua/navigator/util.lua 64;" f unknown:M
|
||||||
|
key lua/navigator/treesitter.lua 263;" f
|
||||||
|
lines_from_locations lua/navigator/lspwrapper.lua 55;" f unknown:M
|
||||||
|
list_workspace_folders lua/navigator/workspace.lua 92;" f unknown:M
|
||||||
|
load lua/navigator/lazyloader.lua 46;" f
|
||||||
|
load_cfg lua/navigator/lspclient/clients.lua 372;" f
|
||||||
|
load_plugins playground/init.lua 26;" f
|
||||||
|
load_plugins playground/init_130.lua 13;" f
|
||||||
|
load_plugins playground/init_131.lua 10;" f
|
||||||
|
load_plugins playground/init_lsp_installer.lua 10;" f
|
||||||
|
load_plugins playground/init_ts_only.lua 26;" f
|
||||||
|
location_handler lua/navigator/implementation.lua 10;" f
|
||||||
|
locations_to_items lua/navigator/lspwrapper.lua 315;" f unknown:M
|
||||||
|
log lua/navigator/util.lua 194;" f unknown:M
|
||||||
|
lru_pairs lua/navigator/lru.lua 164;" f
|
||||||
|
lsp_startup lua/navigator/lspclient/clients.lua 462;" f
|
||||||
|
main README.md 36;" f
|
||||||
|
main doc/navigator.txt 86;" f
|
||||||
|
makeFreeSpace lua/navigator/lru.lua 105;" f
|
||||||
|
makeFunc playground/js/closure.js 1;" f
|
||||||
|
map lua/navigator/util.lua 91;" f unknown:M
|
||||||
|
match_parameter lua/navigator/signature.lua 5;" f
|
||||||
|
matches lua/navigator/foldts.lua 69;" f
|
||||||
|
merge lua/navigator/util.lua 84;" f unknown:M
|
||||||
|
mk_handler lua/navigator/util.lua 413;" f unknown:M
|
||||||
|
mynext lua/navigator/lru.lua 149;" f
|
||||||
|
nav_doc_hl lua/navigator/dochighlight.lua 208;" f
|
||||||
|
new lua/navigator/lru.lua 32;" f unknown:lru
|
||||||
|
new_list_view lua/navigator/gui.lua 10;" f unknown:M
|
||||||
|
node_in_range lua/navigator/treesitter.lua 547;" f
|
||||||
|
node_is_definination lua/navigator/treesitter.lua 51;" f
|
||||||
|
nohl lua/navigator/dochighlight.lua 34;" f
|
||||||
|
nv_ref_async lua/navigator/reference.lua 109;" f
|
||||||
|
nvim_0_6_1 lua/navigator/util.lua 391;" f unknown:M
|
||||||
|
nvim_0_8 lua/navigator/util.lua 402;" f unknown:M
|
||||||
|
oldval tests/fixtures/tests 124;" f
|
||||||
|
on_attach README.md 243;" f
|
||||||
|
on_attach README.md 303;" f
|
||||||
|
on_attach README.md 583;" f
|
||||||
|
on_attach doc/navigator.txt 247;" f
|
||||||
|
on_attach doc/navigator.txt 289;" f
|
||||||
|
on_attach doc/navigator.txt 505;" f
|
||||||
|
on_attach issue130/init.lua 72;" f unknown:options
|
||||||
|
on_attach lua/navigator.lua 26;" f
|
||||||
|
on_attach lua/navigator/foldlsp.lua 25;" f unknown:M
|
||||||
|
on_attach lua/navigator/foldts.lua 15;" f unknown:M
|
||||||
|
on_attach lua/navigator/lspclient/attach.lua 10;" f unknown:M
|
||||||
|
on_attach lua/navigator/lspclient/clients.lua 180;" f
|
||||||
|
on_attach lua/navigator/lspclient/clients.lua 204;" f
|
||||||
|
on_attach lua/navigator/lspclient/clients.lua 552;" f unknown:cfg
|
||||||
|
on_attach lua/navigator/lspclient/clients.lua 564;" f unknown:cfg
|
||||||
|
on_attach lua/navigator/lspclient/clients.lua 576;" f unknown:cfg
|
||||||
|
on_attach lua/navigator/lspclient/clients.lua 604;" f unknown:cfg
|
||||||
|
on_attach lua/navigator/lspclient/clients.lua 660;" f unknown:cfg
|
||||||
|
on_attach playground/init_130.lua 44;" f unknown:options
|
||||||
|
on_attach playground/init_131.lua 32;" f unknown:options
|
||||||
|
on_attach playground/init_lsp_installer.lua 32;" f unknown:options
|
||||||
|
on_confirm lua/navigator/workspace.lua 58;" f
|
||||||
|
on_exit lua/navigator/ctags.lua 73;" f
|
||||||
|
on_filetype lua/navigator/lspclient/clients.lua 806;" f
|
||||||
|
on_init lua/navigator/lspclient/clients.lua 594;" f unknown:cfg
|
||||||
|
on_input_filter lua/navigator/workspace.lua 65;" f
|
||||||
|
on_move lua/navigator/workspace.lua 99;" f
|
||||||
|
on_new_config lua/navigator/lspclient/clients.lua 247;" f
|
||||||
|
on_stdout lua/navigator/ctags.lua 69;" f
|
||||||
|
open_file lua/navigator/util.lua 326;" f unknown:M
|
||||||
|
open_log lua/navigator/util.lua 274;" f unknown:M
|
||||||
|
open_lsp_log lua/navigator/lspclient/config.lua 22;" f unknown:M
|
||||||
|
order_locations lua/navigator/lspwrapper.lua 262;" f
|
||||||
|
outgoing_calls lua/navigator/cclshierarchy.lua 89;" f unknown:M
|
||||||
|
outgoing_calls lua/navigator/hierarchy.lua 91;" f unknown:M
|
||||||
|
outgoing_calls_handler lua/navigator/cclshierarchy.lua 64;" f
|
||||||
|
outgoing_calls_handler lua/navigator/hierarchy.lua 72;" f
|
||||||
|
p lua/navigator/util.lua 259;" f unknown:M
|
||||||
|
pack lua/navigator/util.lua 279;" f unknown:table
|
||||||
|
partial lua/navigator/util.lua 419;" f unknown:M
|
||||||
|
path_cur lua/navigator/util.lua 23;" f unknown:M
|
||||||
|
path_sep lua/navigator/util.lua 12;" f unknown:M
|
||||||
|
prepare_for_render lua/navigator/render.lua 51;" f unknown:M
|
||||||
|
prepare_node lua/navigator/treesitter.lua 138;" f
|
||||||
|
printError lua/navigator/util.lua 263;" f unknown:M
|
||||||
|
prompt lua/navigator/workspace.lua 12;" f
|
||||||
|
prompt lua/navigator/workspace.lua 22;" f
|
||||||
|
prompt lua/navigator/workspace.lua 30;" f
|
||||||
|
quickfix_extract lua/navigator/util.lua 223;" f unknown:M
|
||||||
|
range_code_action lua/navigator/codeAction.lua 173;" f unknown:code_action
|
||||||
|
ref lua/navigator/reference.lua 202;" f
|
||||||
|
ref_hdlr lua/navigator/reference.lua 136;" f
|
||||||
|
ref_req lua/navigator/reference.lua 185;" f
|
||||||
|
ref_view lua/navigator/reference.lua 13;" f
|
||||||
|
refresh lua/navigator/codelens.lua 86;" f unknown:M
|
||||||
|
reload lua/navigator/util.lua 269;" f unknown:M
|
||||||
|
reload_lsp lua/navigator/lspclient/config.lua 7;" f unknown:M
|
||||||
|
remove_workspace_folder lua/navigator/workspace.lua 17;" f unknown:M
|
||||||
|
rename lua/navigator/rename.lua 6;" f unknown:M
|
||||||
|
render_action_virtual_text lua/navigator/codeAction.lua 79;" f unknown:code_action
|
||||||
|
request lua/navigator/lspwrapper.lua 464;" f unknown:M
|
||||||
|
root_dir lua/navigator/lspclient/clients.lua 120;" f
|
||||||
|
root_dir lua/navigator/lspclient/clients.lua 164;" f
|
||||||
|
root_dir lua/navigator/lspclient/clients.lua 187;" f
|
||||||
|
root_dir lua/navigator/lspclient/clients.lua 99;" f
|
||||||
|
round lua/navigator/util.lua 32;" f unknown:M
|
||||||
|
run_action lua/navigator/codelens.lua 105;" f unknown:M
|
||||||
|
select lua/navigator/gui.lua 59;" f unknown:M
|
||||||
|
set lua/navigator/lru.lua 122;" f
|
||||||
|
setNewest lua/navigator/lru.lua 84;" f
|
||||||
|
set_cmds lua/navigator/lspclient/mapping.lua 118;" f
|
||||||
|
set_diag_loclist lua/navigator/diagnostics.lua 383;" f unknown:M
|
||||||
|
set_event_handler lua/navigator/lspclient/mapping.lua 228;" f
|
||||||
|
set_keymap lua/navigator/lspclient/mapping.lua 135;" f
|
||||||
|
set_mapping lua/navigator/lspclient/mapping.lua 124;" f
|
||||||
|
set_virt_eol lua/navigator/util.lua 356;" f unknown:M
|
||||||
|
setup lua/navigator.lua 216;" f unknown:M
|
||||||
|
setup lua/navigator.lua.bak 51;" f unknown:M
|
||||||
|
setup lua/navigator/codelens.lua 64;" f unknown:M
|
||||||
|
setup lua/navigator/lspclient/clients.lua 19;" f
|
||||||
|
setup lua/navigator/lspclient/clients.lua 696;" f
|
||||||
|
setup lua/navigator/lspclient/mapping.lua 273;" f unknown:M
|
||||||
|
setup_fmt lua/navigator/lspclient/clients.lua 425;" f
|
||||||
|
setup_fold lua/navigator/foldts.lua 33;" f unknown:M
|
||||||
|
setup_plugin lua/navigator/foldlsp.lua 30;" f unknown:M
|
||||||
|
show lua/navigator/util.lua 283;" f unknown:M
|
||||||
|
show_buf_diagnostics lua/navigator/diagnostics.lua 351;" f unknown:M
|
||||||
|
show_diagnostics lua/navigator/diagnostics.lua 457;" f unknown:M
|
||||||
|
signature_handler lua/navigator/signature.lua 44;" f
|
||||||
|
slice_locations lua/navigator/lspwrapper.lua 280;" f
|
||||||
|
sort_select lua/navigator/codeAction.lua 154;" f
|
||||||
|
split lua/navigator/util.lua 212;" f unknown:M
|
||||||
|
split2 lua/navigator/util.lua 295;" f unknown:M
|
||||||
|
start_client lua/navigator.lua 243;" f unknown:vim.lsp
|
||||||
|
symbol_kind lua/navigator/lspclient/lspkind.lua 124;" f unknown:lspkind
|
||||||
|
symbol_to_items lua/navigator/lspwrapper.lua 425;" f unknown:M
|
||||||
|
symbols_to_items lua/navigator/lspwrapper.lua 75;" f unknown:M
|
||||||
|
testitem lua/navigator/ctags.lua 144;" f
|
||||||
|
throttle_leading lua/navigator/debounce.lua 14;" f unknown:M
|
||||||
|
title lua/navigator/protocal.txt 388;" f
|
||||||
|
title lua/navigator/protocal.txt 392;" f
|
||||||
|
toggle_diagnostics lua/navigator/diagnostics.lua 342;" f unknown:M
|
||||||
|
toggle_lspformat lua/navigator/lspclient/mapping.lua 254;" f unknown:M
|
||||||
|
trace lua/navigator/util.lua 200;" f unknown:M
|
||||||
|
trim_and_pad lua/navigator/util.lua 307;" f unknown:M
|
||||||
|
trim_level lua/navigator/foldts.lua 55;" f
|
||||||
|
ts_definition lua/navigator/lspwrapper.lua 207;" f
|
||||||
|
ts_functions lua/navigator/lspwrapper.lua 163;" f
|
||||||
|
type vim.toml 21;" f
|
||||||
|
type vim.toml 26;" f
|
||||||
|
type vim.toml 29;" f
|
||||||
|
type vim.toml 31;" f
|
||||||
|
unload lua/navigator/lspwrapper.lua 354;" f
|
||||||
|
update_capabilities lua/navigator/lspclient/clients.lua 442;" f
|
||||||
|
update_err_marker lua/navigator/diagnostics.lua 414;" f unknown:M
|
||||||
|
update_err_marker_async lua/navigator/diagnostics.lua 191;" f
|
||||||
|
update_folds lua/navigator/foldlsp.lua 62;" f unknown:M
|
||||||
|
warn lua/navigator.lua 3;" f
|
||||||
|
warn lua/navigator/util.lua 456;" f unknown:M
|
||||||
|
workspace_symbol lua/navigator/workspace.lua 28;" f unknown:M
|
||||||
|
workspace_symbol_handler lua/navigator/symbols.lua 103;" f unknown:M
|
||||||
|
workspace_symbol_live lua/navigator/workspace.lua 36;" f unknown:M
|
||||||
|
workspace_symbols lua/navigator/symbols.lua 9;" f unknown:M
|
||||||
|
~ lua/navigator/treesitter.lua 202;" f
|
||||||
|
~ lua/navigator/treesitter.lua 371;" f
|
@ -1,4 +1,4 @@
|
|||||||
function! folding#foldexpr()
|
function! folding#ngfoldexpr()
|
||||||
" return luaeval(printf('require"navigator.foldinglsp".get_fold_indic(%d)', v:lnum))
|
" return luaeval(printf('require"navigator.foldinglsp".get_fold_indic(%d)', v:lnum))
|
||||||
return luaeval(printf('require"navigator.foldts".get_fold_indic(%d)', v:lnum))
|
return luaeval(printf('require"navigator.foldts".get_fold_indic(%d)', v:lnum))
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
# Change Logs
|
||||||
|
## 2023-12-07
|
||||||
|
- [x] Changed key maps
|
||||||
|
- Add fallback to key maps e.g. if `gD` does not find a type declaraion, it will fallback to `gD`
|
||||||
|
which is default key map go to global declaration
|
||||||
|
- `gt`: removed `gt` mapping and prefer `<space>D`
|
||||||
|
|
||||||
|
- [ ] Changed key maps
|
||||||
|
I plan to change the mapping for following key maps as it conflicts with other vim default key maps
|
||||||
|
- `gp`: changed to `<Leader>gp`
|
||||||
|
- `gP`: changed to `<Leader>gP`
|
@ -0,0 +1,4 @@
|
|||||||
|
autocmd BufRead,BufNewFile *.tf,*.tfvars set filetype=terraform
|
||||||
|
autocmd BufRead,BufNewFile *.tfstate,*.tfstate.backup set filetype=json
|
||||||
|
autocmd BufRead,BufNewFile *.hcl set filetype=hcl
|
||||||
|
autocmd BufRead,BufNewFile .terraformrc,terraform.rc set filetype=hcl
|
@ -0,0 +1,191 @@
|
|||||||
|
local type_to_lspkind = { c = 5, m = 7, f = 6, s = 5 }
|
||||||
|
local util = require('navigator.util')
|
||||||
|
local log = util.log
|
||||||
|
local sep = util.path_sep()
|
||||||
|
local vfn = vim.fn
|
||||||
|
local cur_dir = vfn.getcwd()
|
||||||
|
|
||||||
|
-- convert ctags line to lsp entry
|
||||||
|
local function entry_to_item(entry)
|
||||||
|
local item = {}
|
||||||
|
item.name, item.filename, item.line, item.remain = string.match(entry, '(.*)\t(.*)\t(%d+);(.*)')
|
||||||
|
local type = 'combine'
|
||||||
|
item.remain = item.remain or ''
|
||||||
|
if item.remain:sub(1, 1) == [["]] then
|
||||||
|
type = 'number'
|
||||||
|
end
|
||||||
|
if item.name == nil or item.filename == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if type == 'combine' then
|
||||||
|
-- '/^type ServerResponse struct {$/;"\ts\tpackage:client'
|
||||||
|
item.inline, item.type, item.containerName, item.ref =
|
||||||
|
string.match(item.remain, '/^(.*)$/;"\t(%a)\t(.+)')
|
||||||
|
else
|
||||||
|
-- '"\tm\tstruct:store.Customer\ttyperef:typename:string'
|
||||||
|
item.type, item.containerName, item.ref = string.match(item.remain, '"\t(%a)\t(.+)')
|
||||||
|
end
|
||||||
|
item.kind = type_to_lspkind[item.type] or 13
|
||||||
|
item.lnum = tonumber(item.line) - 1
|
||||||
|
item.location = {
|
||||||
|
uri = 'file://' .. cur_dir .. sep .. item.filename,
|
||||||
|
range = {
|
||||||
|
start = { line = item.lnum, character = 0 },
|
||||||
|
['end'] = { line = item.lnum, character = 0 },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
item.uri = 'file://' .. cur_dir .. sep .. item.filename
|
||||||
|
item.range = {
|
||||||
|
start = { line = item.lnum, character = 0 },
|
||||||
|
['end'] = { line = item.lnum, character = 0 },
|
||||||
|
}
|
||||||
|
|
||||||
|
-- item.detail = (item.containerName or '') .. (item.ref or '')
|
||||||
|
-- item.text = '[' .. kind .. ']' .. item.name .. ' ' .. item.detail
|
||||||
|
|
||||||
|
if item.lnum == nil then
|
||||||
|
vim.notify('incorrect ctags format, need run ctag with "-excmd=number|combine" option')
|
||||||
|
end
|
||||||
|
item.remain = nil
|
||||||
|
return item
|
||||||
|
end
|
||||||
|
|
||||||
|
local function ctags_gen()
|
||||||
|
local cmd = 'ctags' -- -x -n -u -f - ' .. vfn.expand('%:p')
|
||||||
|
local output = _NgConfigValues.ctags.tagfile
|
||||||
|
-- rm file first
|
||||||
|
util.rm_file(output)
|
||||||
|
local options =
|
||||||
|
'-R --exclude=.git --exclude=node_modules --exclude=test --exclude=vendor --excmd=number '
|
||||||
|
if _NgConfigValues.ctags then
|
||||||
|
cmd = _NgConfigValues.ctags.cmd
|
||||||
|
options = _NgConfigValues.ctags.options or options
|
||||||
|
end
|
||||||
|
|
||||||
|
local lang = vim.o.ft
|
||||||
|
options = options .. '--language-force=' .. lang
|
||||||
|
cmd = cmd .. ' ' .. options
|
||||||
|
cmd = string.format('%s -f %s %s --language-force=%s', cmd, output, options, lang)
|
||||||
|
cmd = vim.split(cmd, ' ')
|
||||||
|
log(cmd)
|
||||||
|
vfn.jobstart(cmd, {
|
||||||
|
on_stdout = function(_, _, _)
|
||||||
|
vim.notify('ctags completed')
|
||||||
|
end,
|
||||||
|
|
||||||
|
on_exit = function(_, data, _) -- id, data, event
|
||||||
|
-- log(vim.inspect(data) .. "exit")
|
||||||
|
if data and data ~= 0 then
|
||||||
|
return vim.notify(cmd .. ' failed ' .. tostring(data), vim.log.levels.ERROR)
|
||||||
|
else
|
||||||
|
vim.notify('ctags generated')
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
local symbols_to_items = require('navigator.lspwrapper').symbols_to_items
|
||||||
|
local function ctags_symbols()
|
||||||
|
local height = _NgConfigValues.height or 0.4
|
||||||
|
local width = _NgConfigValues.width or 0.7
|
||||||
|
height = math.floor(height * vfn.winheight('%'))
|
||||||
|
width = math.floor(vim.api.nvim_get_option('columns') * width)
|
||||||
|
local items = {}
|
||||||
|
local ctags_file = _NgConfigValues.ctags.tagfile
|
||||||
|
-- the tagfile name can be either .tags or tags
|
||||||
|
if vim.fn.filereadable(ctags_file) == 0 then
|
||||||
|
if vim.fn.filereadable('tags') == 1 then -- for some config the default tagfile is tags
|
||||||
|
ctags_file = 'tags'
|
||||||
|
_NgConfigValues.ctags.tagfile = 'tags'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not util.file_exists(ctags_file) then
|
||||||
|
ctags_gen()
|
||||||
|
vim.cmd('sleep 400m')
|
||||||
|
end
|
||||||
|
local cnts = util.io_read(ctags_file)
|
||||||
|
if cnts == nil then
|
||||||
|
return vim.notify('ctags file ' .. ctags_file .. ' not found')
|
||||||
|
end
|
||||||
|
cnts = vfn.split(cnts, '\n')
|
||||||
|
for _, value in pairs(cnts) do
|
||||||
|
local it = entry_to_item(value)
|
||||||
|
if it then
|
||||||
|
table.insert(items, it)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
cnts = nil
|
||||||
|
|
||||||
|
local ft = vim.o.ft
|
||||||
|
local result = symbols_to_items(items)
|
||||||
|
if next(result) == nil then
|
||||||
|
return vim.notify('no symbols found')
|
||||||
|
end
|
||||||
|
log(result[1])
|
||||||
|
local opt = {
|
||||||
|
api = ' ',
|
||||||
|
ft = ft,
|
||||||
|
bg = 'GuihuaListDark',
|
||||||
|
data = result,
|
||||||
|
items = result,
|
||||||
|
enter = true,
|
||||||
|
loc = 'top_center',
|
||||||
|
transparency = 50,
|
||||||
|
prompt = true,
|
||||||
|
rawdata = true,
|
||||||
|
title = 'ctags',
|
||||||
|
rect = { height = height, pos_x = 0, pos_y = 0, width = width },
|
||||||
|
}
|
||||||
|
|
||||||
|
require('navigator.gui').new_list_view(opt)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- gen_ctags()
|
||||||
|
|
||||||
|
local function ctags(...)
|
||||||
|
local gen = select(1, ...)
|
||||||
|
log(gen)
|
||||||
|
if gen == '-g' then
|
||||||
|
ctags_gen()
|
||||||
|
vim.cmd('sleep 200m')
|
||||||
|
ctags_symbols()
|
||||||
|
else
|
||||||
|
ctags_symbols()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function testitem()
|
||||||
|
local e =
|
||||||
|
[[ServerResponse internal/clients/server.go /^type ServerResponse struct {$/;" s package:client]]
|
||||||
|
local ecombine =
|
||||||
|
[[ServerResponse internal/clients/server.go 5;/^type ServerResponse struct {$/;" s package:client]]
|
||||||
|
local enumber =
|
||||||
|
[[CustomerID internal/store/models.go 17;" m struct:store.Customer typeref:typename:string]]
|
||||||
|
local enumber2 =
|
||||||
|
[[CustomerDescription internal/controllers/customer.go 27;" c package:controllers]]
|
||||||
|
local enumber3 = [[add_servers lua/navigator/lspclient/clients.lua 680;" f]]
|
||||||
|
local i = entry_to_item(ecombine)
|
||||||
|
print(vim.inspect(i))
|
||||||
|
|
||||||
|
i = entry_to_item(enumber)
|
||||||
|
print(vim.inspect(i))
|
||||||
|
|
||||||
|
i = entry_to_item(enumber2)
|
||||||
|
print(vim.inspect(i))
|
||||||
|
|
||||||
|
i = entry_to_item(enumber3)
|
||||||
|
print(vim.inspect(i))
|
||||||
|
i = entry_to_item(e)
|
||||||
|
print(vim.inspect(i))
|
||||||
|
end
|
||||||
|
-- testitem()
|
||||||
|
-- gen_ctags()
|
||||||
|
-- ctags_symbols()
|
||||||
|
|
||||||
|
return {
|
||||||
|
ctags_gen = ctags_gen,
|
||||||
|
ctags = ctags,
|
||||||
|
ctags_symbols = ctags_symbols,
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
local M = {}
|
||||||
|
|
||||||
|
local util = require('navigator.util')
|
||||||
|
local log = util.log
|
||||||
|
local health = vim.health
|
||||||
|
if not vim.health then
|
||||||
|
health = require('health')
|
||||||
|
end
|
||||||
|
|
||||||
|
local nvim_09 = vim.fn.has('nvim-0.9') == 1
|
||||||
|
|
||||||
|
local start = nvim_09 and health.start or health.report_start
|
||||||
|
local ok = nvim_09 and health.ok or health.report_ok
|
||||||
|
local error = nvim_09 and health.error or health.report_error
|
||||||
|
local warn = nvim_09 and health.warn or health.report_warn
|
||||||
|
local info = nvim_09 and health.info or health.report_info
|
||||||
|
|
||||||
|
local vfn = vim.fn
|
||||||
|
|
||||||
|
local function plugin_check()
|
||||||
|
start('navigator Plugin Check')
|
||||||
|
|
||||||
|
local plugins = {
|
||||||
|
'lspconfig',
|
||||||
|
'nvim-treesitter',
|
||||||
|
'guihua',
|
||||||
|
}
|
||||||
|
local any_warn = false
|
||||||
|
local ts_installed = false
|
||||||
|
for _, plugin in ipairs(plugins) do
|
||||||
|
if pcall(require, plugin) then
|
||||||
|
ok(string.format('%s: plugin is installed', plugin))
|
||||||
|
if plugin == 'nvim-treesitter' then
|
||||||
|
ts_installed = true
|
||||||
|
end
|
||||||
|
else
|
||||||
|
any_warn = true
|
||||||
|
warn(string.format('%s: not installed/loaded', plugin))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if any_warn then
|
||||||
|
warn('Not all plugin installed')
|
||||||
|
else
|
||||||
|
ok('All plugin installed')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function M.check()
|
||||||
|
if vim.fn.has('nvim-0.9') == 0 then
|
||||||
|
warn('Suggested neovim version 0.9 or higher')
|
||||||
|
end
|
||||||
|
plugin_check()
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
@ -1,102 +1,314 @@
|
|||||||
local gui = require "navigator.gui"
|
local gui = require('navigator.gui')
|
||||||
local util = require "navigator.util"
|
local util = require('navigator.util')
|
||||||
local log = util.log
|
local log = util.log
|
||||||
local trace = util.trace
|
local trace = util.trace
|
||||||
local partial = util.partial
|
local partial = util.partial
|
||||||
local lsphelper = require "navigator.lspwrapper"
|
local lsphelper = require('navigator.lspwrapper')
|
||||||
|
|
||||||
|
local path_sep = require('navigator.util').path_sep()
|
||||||
|
local path_cur = require('navigator.util').path_cur()
|
||||||
|
local uv = vim.uv or vim.loop
|
||||||
|
local cwd = uv.cwd()
|
||||||
|
local in_method = 'callHierarchy/incomingCalls'
|
||||||
|
local out_method = 'callHierarchy/outgoingCalls'
|
||||||
|
|
||||||
|
local lsp_method = { to = out_method, from = in_method }
|
||||||
|
local panel_method = { to = out_method, from = in_method }
|
||||||
|
|
||||||
local path_sep = require"navigator.util".path_sep()
|
|
||||||
local path_cur = require"navigator.util".path_cur()
|
|
||||||
local cwd = vim.loop.cwd()
|
|
||||||
local M = {}
|
local M = {}
|
||||||
local function call_hierarchy_handler(direction, err, result, ctx, cfg, error_message)
|
local outgoing_calls_handler
|
||||||
|
local incoming_calls_handler
|
||||||
|
local hierarchy_handler
|
||||||
|
|
||||||
|
local call_hierarchy
|
||||||
|
|
||||||
|
local function pick_call_hierarchy_item(call_hierarchy_items)
|
||||||
|
if not call_hierarchy_items then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if #call_hierarchy_items == 1 then
|
||||||
|
return call_hierarchy_items[1]
|
||||||
|
end
|
||||||
|
local items = {}
|
||||||
|
for i, item in pairs(call_hierarchy_items) do
|
||||||
|
local entry = item.detail or item.name
|
||||||
|
table.insert(items, string.format('%d. %s', i, entry))
|
||||||
|
end
|
||||||
|
local choice = vim.fn.inputlist(items)
|
||||||
|
if choice < 1 or choice > #items then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return choice
|
||||||
|
end
|
||||||
|
|
||||||
|
-- convert lsp result to navigator items
|
||||||
|
local function call_hierarchy_result_procesor(direction, err, result, ctx, config)
|
||||||
|
math.randomseed(os.clock() * 100000000000)
|
||||||
|
trace(direction, err, ctx, config)
|
||||||
|
trace(result)
|
||||||
if not result then
|
if not result then
|
||||||
vim.notify ("No call hierarchy items found", vim.lsp.log_levels.WARN)
|
vim.notify('No call hierarchy items found', vim.log.levels.WARN)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
trace('call_hierarchy', result)
|
-- trace('call_hierarchy', result)
|
||||||
assert(#vim.lsp.buf_get_clients() > 0, "Must have a client running to use lsp_tags")
|
|
||||||
|
local bufnr = ctx.bufnr or vim.api.nvim_get_current_buf()
|
||||||
|
assert(next(vim.lsp.get_clients({buffer = bufnr})), 'Must have a client running to use call hierarchy')
|
||||||
if err ~= nil then
|
if err ~= nil then
|
||||||
log("dir", direction, "result", result, "err", err, ctx)
|
log('dir', direction, 'result', result, 'err', err, ctx)
|
||||||
vim.notify("ERROR: " .. error_message, vim.lsp.log_levels.WARN)
|
vim.notify('ERROR: ' .. err, vim.log.levels.WARN)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local items = {}
|
local items = ctx.items or {}
|
||||||
|
|
||||||
for _, call_hierarchy_call in pairs(result) do
|
local kind = ' '
|
||||||
local call_hierarchy_item = call_hierarchy_call[direction]
|
for _, call_hierarchy_result in pairs(result) do
|
||||||
local kind = ' '
|
local call_hierarchy_item = call_hierarchy_result[direction]
|
||||||
if call_hierarchy_item.kind then
|
if call_hierarchy_item.kind then
|
||||||
kind = require'navigator.lspclient.lspkind'.symbol_kind(call_hierarchy_item.kind) .. ' '
|
kind = require('navigator.lspclient.lspkind').symbol_kind(call_hierarchy_item.kind) .. ' '
|
||||||
end
|
end
|
||||||
-- for _, range in pairs(call_hierarchy_call.fromRanges) do
|
|
||||||
range = call_hierarchy_item.range or call_hierarchy_item.selectionRange
|
|
||||||
local filename = assert(vim.uri_to_fname(call_hierarchy_item.uri))
|
local filename = assert(vim.uri_to_fname(call_hierarchy_item.uri))
|
||||||
local display_filename = filename:gsub(cwd .. path_sep, path_cur, 1)
|
local display_filename = filename:gsub(cwd .. path_sep, path_cur, 1)
|
||||||
call_hierarchy_item.detail = call_hierarchy_item.detail or ""
|
call_hierarchy_item.detail = call_hierarchy_item.detail or ''
|
||||||
call_hierarchy_item.detail = call_hierarchy_item.detail:gsub("\n", " ↳ ")
|
call_hierarchy_item.detail = string.gsub(call_hierarchy_item.detail, '\n', ' ↳ ')
|
||||||
trace(range, call_hierarchy_item)
|
trace(call_hierarchy_item)
|
||||||
|
|
||||||
local disp_item = {
|
local disp_item = vim.tbl_deep_extend('force', {}, call_hierarchy_item)
|
||||||
uri = call_hierarchy_item.uri,
|
disp_item = vim.tbl_deep_extend('force', disp_item, {
|
||||||
filename = filename,
|
filename = filename,
|
||||||
display_filename = display_filename,
|
display_filename = display_filename,
|
||||||
|
indent_level = ctx.depth or 1,
|
||||||
|
method = lsp_method[direction],
|
||||||
|
node_text = call_hierarchy_item.name,
|
||||||
|
type = kind,
|
||||||
|
id = math.random(1, 100000),
|
||||||
text = kind .. call_hierarchy_item.name .. ' ﰲ ' .. call_hierarchy_item.detail,
|
text = kind .. call_hierarchy_item.name .. ' ﰲ ' .. call_hierarchy_item.detail,
|
||||||
range = range,
|
lnum = call_hierarchy_item.selectionRange.start.line + 1,
|
||||||
lnum = range.start.line + 1,
|
col = call_hierarchy_item.selectionRange.start.character,
|
||||||
col = range.start.character
|
})
|
||||||
}
|
|
||||||
|
|
||||||
table.insert(items, disp_item)
|
table.insert(items, disp_item)
|
||||||
-- end
|
|
||||||
end
|
end
|
||||||
|
trace(items)
|
||||||
return items
|
return items
|
||||||
end
|
end
|
||||||
|
|
||||||
local call_hierarchy_handler_from = partial(call_hierarchy_handler, "from")
|
local call_hierarchy_handler_from = partial(call_hierarchy_result_procesor, 'from')
|
||||||
local call_hierarchy_handler_to = partial(call_hierarchy_handler, "to")
|
local call_hierarchy_handler_to = partial(call_hierarchy_result_procesor, 'to')
|
||||||
|
|
||||||
local function incoming_calls_handler(bang, err, result, ctx, cfg)
|
-- the handler that deal all lsp request
|
||||||
assert(#vim.lsp.buf_get_clients() > 0, "Must have a client running to use lsp hierarchy")
|
hierarchy_handler = function(dir, handler, show, api, err, result, ctx, cfg)
|
||||||
local results = call_hierarchy_handler_from(err, result, ctx, cfg, "Incoming calls not found")
|
trace(dir, handler, api, show, err, result, ctx, cfg)
|
||||||
|
ctx = ctx or {} -- can be nil if it is async call
|
||||||
|
cfg = cfg or {}
|
||||||
|
local opts = ctx.opts or {}
|
||||||
|
vim.validate({ handler = { handler, 'function' }, show = { show, 'function' }, api = { api, 'string' } })
|
||||||
|
local bufnr = ctx.bufnr or vim.api.nvim_get_current_buf()
|
||||||
|
assert(next(vim.lsp.get_clients({buffer = bufnr})), 'Must have a client running to use lsp hierarchy')
|
||||||
|
|
||||||
local ft = vim.api.nvim_buf_get_option(ctx.bufnr, "ft")
|
local results = handler(err, result, ctx, cfg, 'Incoming calls not found')
|
||||||
gui.new_list_view({items = results, ft = ft, api = ' '})
|
|
||||||
|
local ft = vim.api.nvim_buf_get_option(ctx.bufnr or vim.api.nvim_get_current_buf(), 'ft')
|
||||||
|
if ctx.no_show then
|
||||||
|
return results
|
||||||
|
end
|
||||||
|
-- local panel = args.panel
|
||||||
|
-- local items = args.items
|
||||||
|
-- local parent_node = args.node
|
||||||
|
-- local section_id = args.section_id or 1
|
||||||
|
local show_args = {
|
||||||
|
items = results,
|
||||||
|
ft = ft,
|
||||||
|
api = api,
|
||||||
|
bufnr = bufnr,
|
||||||
|
panel = opts.panel,
|
||||||
|
parent_node = opts.parent_node,
|
||||||
|
title = 'Call Hierarchy',
|
||||||
|
}
|
||||||
|
local win = show(show_args)
|
||||||
|
return results, win
|
||||||
end
|
end
|
||||||
|
|
||||||
local function outgoing_calls_handler(bang, err, result, ctx, cfg)
|
local make_params = function(uri, pos)
|
||||||
local results = call_hierarchy_handler_to(err, result, ctx, cfg, "Outgoing calls not found")
|
return {
|
||||||
|
textDocument = {
|
||||||
|
uri = uri,
|
||||||
|
},
|
||||||
|
position = pos,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
local ft = vim.api.nvim_buf_get_option(ctx.bufnr, "ft")
|
local function display_panel(args)
|
||||||
gui.new_list_view({items = results, ft = ft, api = ' '})
|
-- args = {items=results, ft=ft, api=api}
|
||||||
-- fzf_locations(bang, "", "Outgoing Calls", results, false)
|
log(args)
|
||||||
|
|
||||||
|
local Panel = require('guihua.panel')
|
||||||
|
local bufnr = args.bufnr or vim.api.nvim_get_current_buf()
|
||||||
|
-- local ft = args.ft or vim.api.nvim_buf_get_option(bufnr, 'buftype')
|
||||||
|
local items = args.items
|
||||||
|
local p = Panel:new({
|
||||||
|
header = args.header or 'Call Hierarchy',
|
||||||
|
render = function(buf)
|
||||||
|
log(buf)
|
||||||
|
return items
|
||||||
|
end,
|
||||||
|
fold = function(panel, node)
|
||||||
|
if node.expanded ~= nil then
|
||||||
|
node.expanded = not node.expanded
|
||||||
|
vim.cmd('normal! za')
|
||||||
|
else
|
||||||
|
expand(panel, node)
|
||||||
|
node.expanded = true
|
||||||
|
end
|
||||||
|
log('fold')
|
||||||
|
return node
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
p:open(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.incoming_calls(bang, opts)
|
local function expand_item(args)
|
||||||
assert(#vim.lsp.buf_get_clients() > 0, "Must have a client running to use lsp hierarchy")
|
-- args = {items=results, ft=ft, api=api}
|
||||||
if not lsphelper.check_capabilities("call_hierarchy") then
|
print('dispaly panel')
|
||||||
return
|
trace(args, args.parent_node)
|
||||||
|
local panel = args.panel
|
||||||
|
local items = args.items
|
||||||
|
local parent_node = args.parent_node
|
||||||
|
local section_id = args.section_id or 1
|
||||||
|
|
||||||
|
local sect
|
||||||
|
local sectid = 1
|
||||||
|
for i, s in pairs(panel.sections) do
|
||||||
|
if s.id == section_id then
|
||||||
|
sectid = i
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
sect = panel.sections[sectid]
|
||||||
|
for i, node in pairs(sect.nodes) do
|
||||||
|
if node.id == parent_node.id then
|
||||||
|
for j in ipairs(items) do
|
||||||
|
items[j].indent_level = parent_node.indent_level + 1
|
||||||
|
table.insert(sect.nodes, i + j, args.items[j])
|
||||||
|
end
|
||||||
|
sect.nodes[i].expanded = true
|
||||||
|
sect.nodes[i].expandable = false
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
trace(panel.sections[sectid])
|
||||||
|
-- render the panel again
|
||||||
|
panel:redraw(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
incoming_calls_handler = util.partial4(
|
||||||
|
hierarchy_handler,
|
||||||
|
'from',
|
||||||
|
call_hierarchy_handler_from,
|
||||||
|
gui.new_list_view,
|
||||||
|
' '
|
||||||
|
)
|
||||||
|
outgoing_calls_handler = util.partial4(hierarchy_handler, 'to', call_hierarchy_handler_to, gui.new_list_view, ' ')
|
||||||
|
|
||||||
|
local incoming_calls_panel = util.partial4(
|
||||||
|
hierarchy_handler,
|
||||||
|
'from',
|
||||||
|
call_hierarchy_handler_from,
|
||||||
|
display_panel,
|
||||||
|
' '
|
||||||
|
)
|
||||||
|
local outgoing_calls_panel = util.partial4(hierarchy_handler, 'to', call_hierarchy_handler_to, display_panel, ' ')
|
||||||
|
|
||||||
|
local incoming_calls_expand = util.partial4(hierarchy_handler, 'from', call_hierarchy_handler_from, expand_item, ' ')
|
||||||
|
local outgoing_calls_expand = util.partial4(hierarchy_handler, 'to', call_hierarchy_handler_to, expand_item, ' ')
|
||||||
|
|
||||||
|
function expand(panel, node)
|
||||||
|
trace(panel, node)
|
||||||
|
local params = make_params(node.uri, {
|
||||||
|
line = node.range.start.line,
|
||||||
|
character = node.range.start.character,
|
||||||
|
})
|
||||||
|
local handler = incoming_calls_expand
|
||||||
|
if node.api == out_method then
|
||||||
|
handler = outgoing_calls_expand
|
||||||
end
|
end
|
||||||
|
|
||||||
local params = vim.lsp.util.make_position_params()
|
local bufnr = vim.uri_to_bufnr(node.uri)
|
||||||
lsphelper.call_sync("callHierarchy/incomingCalls", params, opts, partial(incoming_calls_handler, bang))
|
call_hierarchy(node.method, {
|
||||||
|
params = params,
|
||||||
|
panel = panel,
|
||||||
|
parent_node = node,
|
||||||
|
handler = handler,
|
||||||
|
bufnr = bufnr,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.outgoing_calls(bang, opts)
|
local request = vim.lsp.buf_request
|
||||||
assert(#vim.lsp.buf_get_clients() > 0, "Must have a client running to use lsp_tags")
|
|
||||||
if not lsphelper.check_capabilities("call_hierarchy") then
|
-- call_hierarchy with floating window
|
||||||
return
|
call_hierarchy = function(method, opts)
|
||||||
|
trace(method, opts)
|
||||||
|
opts = opts or {}
|
||||||
|
local params = opts.params or vim.lsp.util.make_position_params()
|
||||||
|
local bufnr = opts.bufnr
|
||||||
|
local handler = function(err, result, ctx, cfg)
|
||||||
|
ctx.opts = opts
|
||||||
|
return opts.handler(err, result, ctx, cfg)
|
||||||
end
|
end
|
||||||
|
-- log(opts, params)
|
||||||
|
return request(
|
||||||
|
bufnr,
|
||||||
|
'textDocument/prepareCallHierarchy',
|
||||||
|
params,
|
||||||
|
vim.lsp.with(function(err, result, ctx)
|
||||||
|
if err then
|
||||||
|
vim.notify(err.message, vim.log.levels.WARN)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local call_hierarchy_item = pick_call_hierarchy_item(result)
|
||||||
|
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
||||||
|
if client then
|
||||||
|
trace('result', result, 'items', call_hierarchy_item, method, ctx, client.name)
|
||||||
|
client.request(method, {
|
||||||
|
item = call_hierarchy_item,
|
||||||
|
args = {
|
||||||
|
method = method,
|
||||||
|
},
|
||||||
|
}, handler, ctx.bufnr)
|
||||||
|
else
|
||||||
|
vim.notify(string.format('Client with id=%d stopped', ctx.client_id), vim.log.levels.WARN)
|
||||||
|
end
|
||||||
|
end, { direction = method, depth = opts.depth })
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.incoming_calls(opts)
|
||||||
|
call_hierarchy(in_method, opts)
|
||||||
|
end
|
||||||
|
|
||||||
local params = vim.lsp.util.make_position_params()
|
function M.outgoing_calls(opts)
|
||||||
lsphelper.call_sync("callHierarchy/outgoingCalls", params, opts, partial(outgoing_calls_handler, bang))
|
call_hierarchy(out_method, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
M.incoming_calls_call = partial(M.incoming_calls, 0)
|
function M.incoming_calls_panel(opts)
|
||||||
M.outgoing_calls_call = partial(M.outgoing_calls, 0)
|
opts = vim.tbl_extend('force', { handler = incoming_calls_panel }, opts or {})
|
||||||
|
call_hierarchy(in_method, opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.outgoing_calls_panel(opts)
|
||||||
|
opts = vim.tbl_extend('force', { handler = outgoing_calls_panel }, opts or {})
|
||||||
|
call_hierarchy(out_method, opts)
|
||||||
|
end
|
||||||
|
|
||||||
M.incoming_calls_handler = partial(incoming_calls_handler, 0)
|
M.incoming_calls_handler = incoming_calls_handler
|
||||||
M.outgoing_calls_handler = partial(outgoing_calls_handler, 0)
|
M.outgoing_calls_handler = outgoing_calls_handler
|
||||||
|
-- for testing
|
||||||
|
M._call_hierarchy = call_hierarchy
|
||||||
|
|
||||||
|
function M.calltree(args)
|
||||||
|
if args == '-o' then
|
||||||
|
return M.outgoing_calls_panel()
|
||||||
|
end
|
||||||
|
M.incoming_calls_panel()
|
||||||
|
end
|
||||||
return M
|
return M
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
local lsp = vim.lsp
|
||||||
|
local util = lsp.util
|
||||||
|
local nutils = require('navigator.util')
|
||||||
|
local api = vim.api
|
||||||
|
local log = nutils.log
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
function M.handler(err, result, ctx, config)
|
||||||
|
config = config or {}
|
||||||
|
config.focus_id = ctx.method
|
||||||
|
if api.nvim_get_current_buf() ~= ctx.bufnr then
|
||||||
|
-- Ignore result since buffer changed. This happens for slow language servers.
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local failed = false
|
||||||
|
if err then
|
||||||
|
vim.notify('no hover info ' .. err)
|
||||||
|
failed = true
|
||||||
|
end
|
||||||
|
if not result or not result.contents then
|
||||||
|
if config.silent ~= true then
|
||||||
|
vim.notify('No hover information available')
|
||||||
|
end
|
||||||
|
failed = true
|
||||||
|
end
|
||||||
|
local bufnr = ctx.bufnr
|
||||||
|
-- get filetype for bufnr
|
||||||
|
local ft = api.nvim_buf_get_option(bufnr, 'filetype')
|
||||||
|
if failed then
|
||||||
|
if _NgConfigValues.lsp.hover.ft then
|
||||||
|
local fallback_fn = _NgConfigValues.hover.ft or ''
|
||||||
|
if type(fallback_fn) == 'function' then
|
||||||
|
fallback_fn(ctx, config)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return -- return early as no valid hover info lets fallback to other sources
|
||||||
|
end
|
||||||
|
local format = 'markdown'
|
||||||
|
local contents ---@type string[]
|
||||||
|
if type(result.contents) == 'table' and result.contents.kind == 'plaintext' then
|
||||||
|
format = 'plaintext'
|
||||||
|
contents = vim.split(result.contents.value or '', '\n', { trimempty = true })
|
||||||
|
else
|
||||||
|
contents = util.convert_input_to_markdown_lines(result.contents)
|
||||||
|
end
|
||||||
|
if vim.tbl_isempty(contents) then
|
||||||
|
if config.silent ~= true then
|
||||||
|
vim.notify('No information available')
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return util.open_floating_preview(contents, format, config)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
@ -1,64 +1,48 @@
|
|||||||
return {
|
return {
|
||||||
init = function()
|
init = function()
|
||||||
local loader = nil
|
local loader = nil
|
||||||
local packer_plugins = packer_plugins or nil -- suppress warnings
|
local log = require('navigator.util').log
|
||||||
local log = require'navigator.util'.log
|
|
||||||
-- packer only
|
-- packer only
|
||||||
if packer_plugins ~= nil then -- packer install
|
local lazy_plugins = {
|
||||||
local lazy_plugins = {
|
['nvim-lspconfig'] = 'neovim/nvim-lspconfig',
|
||||||
["nvim-lspconfig"] = "neovim/nvim-lspconfig",
|
['guihua.lua'] = 'ray-x/guihua.lua',
|
||||||
["guihua.lua"] = "ray-x/guihua.lua"
|
}
|
||||||
}
|
if pcall(require, 'lazy') then
|
||||||
|
require('lazy').load({ plugins = { 'nvim-lspconfig', 'guihua.lua' } })
|
||||||
if _NgConfigValues.lsp_installer == true then
|
elseif vim.fn.empty(packer_plugins) == 0 then -- packer install
|
||||||
lazy_plugins["nvim-lsp-installer"] = "williamboman/nvim-lsp-installer"
|
|
||||||
end
|
|
||||||
|
|
||||||
-- packer installed
|
-- packer installed
|
||||||
loader = require"packer".loader
|
loader = require('packer').loader
|
||||||
for plugin, url in pairs(lazy_plugins) do
|
for plugin, url in pairs(lazy_plugins) do
|
||||||
if not packer_plugins[url] or not packer_plugins[url].loaded then
|
if not packer_plugins[url] or not packer_plugins[url].loaded then
|
||||||
-- log("loading ", plugin)
|
-- log("loading ", plugin)
|
||||||
loader(plugin)
|
loader(plugin)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
else
|
||||||
end
|
loader = function(plugin)
|
||||||
|
local cmd = 'packadd ' .. plugin
|
||||||
if _NgConfigValues.lsp_installer == true then
|
vim.cmd(cmd)
|
||||||
local has_lspinst, lspinst = pcall(require, "lsp_installer")
|
|
||||||
log('lsp_installer installed', has_lspinst)
|
|
||||||
if has_lspinst then
|
|
||||||
lspinst.setup()
|
|
||||||
local configs = require "lspconfig/configs"
|
|
||||||
local servers = require'nvim-lsp-installer'.get_installed_servers()
|
|
||||||
for _, server in pairs(servers) do
|
|
||||||
local cfg = require'navigator.lspclient.clients'.get_cfg(server)
|
|
||||||
local lsp_inst_cfg = configs[server]
|
|
||||||
if lsp_inst_cfg and lsp_inst_cfg.document_config.default_config then
|
|
||||||
lsp_inst_cfg = lsp_inst_cfg.document_config.default_config
|
|
||||||
lsp_inst_cfg = vim.tbl_deep_extend('keep', lsp_inst_cfg, cfg)
|
|
||||||
require'lspconfig'[server].setup(lsp_inst_cfg)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
load = function(plugin_name, path)
|
load = function(plugin_name, path)
|
||||||
local loader = nil
|
local loader = nil
|
||||||
local packer_plugins = packer_plugins or nil -- suppress warnings
|
|
||||||
-- packer only
|
if pcall(require, 'lazy') then
|
||||||
if packer_plugins ~= nil then -- packer install
|
require('lazy').load({ plugins = { plugin_name } })
|
||||||
local lazy_plugins = {}
|
else
|
||||||
lazy_plugins[plugin_name] = path
|
packer_plugins = packer_plugins or nil -- suppress warnings
|
||||||
loader = require"packer".loader
|
-- packer only
|
||||||
for plugin, url in pairs(lazy_plugins) do
|
if packer_plugins ~= nil then -- packer install
|
||||||
if packer_plugins[plugin] and packer_plugins[plugin].loaded == false then
|
local lazy_plugins = {}
|
||||||
-- log("loading ", plugin)
|
lazy_plugins[plugin_name] = path
|
||||||
pcall(loader, plugin)
|
loader = require('packer').loader
|
||||||
|
for plugin, _ in pairs(lazy_plugins) do
|
||||||
|
if packer_plugins[plugin] and packer_plugins[plugin].loaded == false then
|
||||||
|
pcall(loader, plugin)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end,
|
||||||
end
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,215 @@
|
|||||||
|
local M = {}
|
||||||
|
local vfn = vim.fn
|
||||||
|
M.defaults = function()
|
||||||
|
local has_lsp, lspconfig = pcall(require, 'lspconfig')
|
||||||
|
local highlight = require('navigator.lspclient.highlight')
|
||||||
|
if not has_lsp then
|
||||||
|
return {
|
||||||
|
setup = function()
|
||||||
|
vim.notify('loading lsp config failed LSP may not working correctly', vim.log.levels.WARN)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
local util = lspconfig.util
|
||||||
|
local on_attach = require('navigator.lspclient.attach').on_attach
|
||||||
|
|
||||||
|
local setups = {
|
||||||
|
clojure_lsp = {
|
||||||
|
root_dir = function(fname)
|
||||||
|
return util.root_pattern(
|
||||||
|
'deps.edn',
|
||||||
|
'build.boot',
|
||||||
|
'project.clj',
|
||||||
|
'shadow-cljs.edn',
|
||||||
|
'bb.edn',
|
||||||
|
'.git'
|
||||||
|
)(fname) or util.path.dirname(fname)
|
||||||
|
end,
|
||||||
|
on_attach = on_attach,
|
||||||
|
filetypes = { 'clojure', 'edn' },
|
||||||
|
message_level = vim.lsp.protocol.MessageType.error,
|
||||||
|
cmd = { 'clojure-lsp' },
|
||||||
|
},
|
||||||
|
|
||||||
|
elixirls = {
|
||||||
|
on_attach = on_attach,
|
||||||
|
filetypes = { 'elixir', 'eelixir' },
|
||||||
|
cmd = { 'elixir-ls' },
|
||||||
|
message_level = vim.lsp.protocol.MessageType.error,
|
||||||
|
settings = {
|
||||||
|
elixirLS = {
|
||||||
|
dialyzerEnabled = true,
|
||||||
|
fetchDeps = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
root_dir = function(fname)
|
||||||
|
return util.root_pattern('mix.exs', '.git')(fname) or util.path.dirname(fname)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
|
||||||
|
gopls = {
|
||||||
|
-- capabilities = cap,
|
||||||
|
filetypes = { 'go', 'gomod', 'gohtmltmpl', 'gotexttmpl' },
|
||||||
|
message_level = vim.lsp.protocol.MessageType.Error,
|
||||||
|
cmd = {
|
||||||
|
'gopls', -- share the gopls instance if there is one already
|
||||||
|
'-remote=auto', --[[ debug options ]] --
|
||||||
|
-- "-logfile=auto",
|
||||||
|
-- "-debug=:0",
|
||||||
|
'-remote.debug=:0',
|
||||||
|
-- "-rpc.trace",
|
||||||
|
},
|
||||||
|
|
||||||
|
flags = { allow_incremental_sync = true, debounce_text_changes = 1000 },
|
||||||
|
settings = {
|
||||||
|
gopls = {
|
||||||
|
-- more settings: https://github.com/golang/tools/blob/master/gopls/doc/settings.md
|
||||||
|
-- flags = {allow_incremental_sync = true, debounce_text_changes = 500},
|
||||||
|
-- not supported
|
||||||
|
analyses = { unusedparams = true, unreachable = false },
|
||||||
|
codelenses = {
|
||||||
|
generate = true, -- show the `go generate` lens.
|
||||||
|
gc_details = true, -- // Show a code lens toggling the display of gc's choices.
|
||||||
|
test = true,
|
||||||
|
tidy = true,
|
||||||
|
},
|
||||||
|
usePlaceholders = true,
|
||||||
|
completeUnimported = true,
|
||||||
|
staticcheck = true,
|
||||||
|
matcher = 'fuzzy',
|
||||||
|
diagnosticsDelay = '500ms',
|
||||||
|
symbolMatcher = 'fuzzy',
|
||||||
|
gofumpt = false, -- true, -- turn on for new repos, gofmpt is good but also create code turmoils
|
||||||
|
buildFlags = { '-tags', 'integration' },
|
||||||
|
-- buildFlags = {"-tags", "functional"}
|
||||||
|
semanticTokens = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
on_attach(client, bufnr)
|
||||||
|
if
|
||||||
|
vim.fn.has('nvim-0.8.3') == 1
|
||||||
|
and not client.server_capabilities.semanticTokensProvider
|
||||||
|
then
|
||||||
|
local semantic = client.config.capabilities.textDocument.semanticTokens
|
||||||
|
if semantic then
|
||||||
|
client.server_capabilities.semanticTokensProvider = {
|
||||||
|
full = true,
|
||||||
|
legend = {
|
||||||
|
tokenModifiers = semantic.tokenModifiers,
|
||||||
|
tokenTypes = semantic.tokenTypes,
|
||||||
|
},
|
||||||
|
range = true,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
root_dir = function(fname)
|
||||||
|
return util.root_pattern('go.mod', '.git')(fname) or util.path.dirname(fname)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
clangd = {
|
||||||
|
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
|
||||||
|
cmd = {
|
||||||
|
'clangd',
|
||||||
|
'--background-index',
|
||||||
|
'--suggest-missing-includes',
|
||||||
|
'--clang-tidy',
|
||||||
|
'--header-insertion=iwyu',
|
||||||
|
'--enable-config',
|
||||||
|
'--offset-encoding=utf-16',
|
||||||
|
'--clang-tidy-checks=-*,llvm-*,clang-analyzer-*',
|
||||||
|
'--cross-file-rename',
|
||||||
|
},
|
||||||
|
filetypes = { 'c', 'cpp', 'objc', 'objcpp' },
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
client.server_capabilities.documentFormattingProvider = client.server_capabilities.documentFormattingProvider
|
||||||
|
or true
|
||||||
|
on_attach(client, bufnr)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
rust_analyzer = {
|
||||||
|
root_dir = function(fname)
|
||||||
|
return util.root_pattern('Cargo.toml', 'rust-project.json', '.git')(fname)
|
||||||
|
or util.path.dirname(fname)
|
||||||
|
end,
|
||||||
|
filetypes = { 'rust' },
|
||||||
|
message_level = vim.lsp.protocol.MessageType.error,
|
||||||
|
on_attach = on_attach,
|
||||||
|
settings = {
|
||||||
|
['rust-analyzer'] = {
|
||||||
|
cargo = { loadOutDirsFromCheck = true },
|
||||||
|
procMacro = { enable = true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
|
||||||
|
},
|
||||||
|
sqlls = {
|
||||||
|
cmd = { 'sql-language-server', 'up', '--method', 'stdio' },
|
||||||
|
filetypes = { 'sql', 'mysql' },
|
||||||
|
root_dir = util.root_pattern('.sqllsrc.json'),
|
||||||
|
on_attach = on_attach,
|
||||||
|
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
|
||||||
|
},
|
||||||
|
|
||||||
|
pyright = {
|
||||||
|
on_attach = on_attach,
|
||||||
|
-- on_init = require('navigator.lspclient.python').on_init,
|
||||||
|
on_init = function(client)
|
||||||
|
require('navigator.lspclient.python').on_init(client)
|
||||||
|
end,
|
||||||
|
on_new_config = function(new_config, new_root_dir)
|
||||||
|
local python_path = require('navigator.lspclient.python').pyenv_path(new_root_dir)
|
||||||
|
new_config.settings.python.pythonPath = python_path
|
||||||
|
end,
|
||||||
|
cmd = { 'pyright-langserver', '--stdio' },
|
||||||
|
filetypes = { 'python' },
|
||||||
|
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
|
||||||
|
settings = {
|
||||||
|
python = {
|
||||||
|
venvPath = '.',
|
||||||
|
formatting = { provider = 'black' },
|
||||||
|
analysis = {
|
||||||
|
autoSearchPaths = true,
|
||||||
|
useLibraryCodeForTypes = true,
|
||||||
|
diagnosticMode = 'workspace',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ccls = {
|
||||||
|
on_attach = on_attach,
|
||||||
|
init_options = {
|
||||||
|
compilationDatabaseDirectory = 'build',
|
||||||
|
root_dir = [[ util.root_pattern("compile_commands.json", "compile_flags.txt", "CMakeLists.txt", "Makefile", ".git") or util.path.dirname ]],
|
||||||
|
index = { threads = 2 },
|
||||||
|
clang = { excludeArgs = { '-frounding-math' } },
|
||||||
|
},
|
||||||
|
flags = { allow_incremental_sync = true },
|
||||||
|
},
|
||||||
|
jdtls = {
|
||||||
|
settings = {
|
||||||
|
java = {
|
||||||
|
signatureHelp = { enabled = true },
|
||||||
|
contentProvider = { preferred = 'fernflower' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
omnisharp = {
|
||||||
|
cmd = { 'omnisharp', '--languageserver', '--hostPID', tostring(vfn.getpid()) },
|
||||||
|
},
|
||||||
|
terraformls = {
|
||||||
|
filetypes = { 'terraform', 'tf' },
|
||||||
|
},
|
||||||
|
|
||||||
|
sourcekit = {
|
||||||
|
cmd = { 'sourcekit-lsp' },
|
||||||
|
filetypes = { 'swift' }, -- This is recommended if you have separate settings for clangd.
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
setups.lua_ls = require('navigator.lspclient.lua_ls').lua_ls()
|
||||||
|
return setups
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
@ -1,89 +1,67 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local log = require"navigator.util".log
|
-- local log = require('navigator.util').log
|
||||||
local api = vim.api
|
local api = vim.api
|
||||||
|
|
||||||
|
local cmd_group = api.nvim_create_augroup('NGHiGroup', {})
|
||||||
-- lsp sign ﮻ ﯭ ﳀ
|
-- lsp sign ﮻ ﯭ ﳀ
|
||||||
function M.diagnositc_config_sign()
|
function M.config_signs()
|
||||||
if M.configed then
|
if M.configed then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local icons = _NgConfigValues.icons
|
local icons = _NgConfigValues.icons
|
||||||
|
|
||||||
local sign_name = "NavigatorLightBulb"
|
local sign_name = 'NavigatorLightBulb'
|
||||||
if vim.fn.sign_getdefined(sign_name).text == nil then
|
if vim.fn.sign_getdefined(sign_name).text == nil then
|
||||||
|
vim.fn.sign_define(
|
||||||
|
sign_name,
|
||||||
|
{ text = icons.code_action_icon, texthl = 'LspDiagnosticsSignHint' }
|
||||||
|
)
|
||||||
|
|
||||||
vim.fn
|
sign_name = 'NavigatorCodeLensLightBulb'
|
||||||
.sign_define(sign_name, {text = icons.code_action_icon, texthl = "LspDiagnosticsSignHint"})
|
vim.fn.sign_define(
|
||||||
|
sign_name,
|
||||||
sign_name = "NavigatorCodeLensLightBulb"
|
{ text = icons.code_lens_action_icon, texthl = 'LspDiagnosticsSignHint' }
|
||||||
vim.fn.sign_define(sign_name,
|
)
|
||||||
{text = icons.code_lens_action_icon, texthl = "LspDiagnosticsSignHint"})
|
|
||||||
end
|
|
||||||
|
|
||||||
local e, w, i, h = icons.diagnostic_err, icons.diagnostic_warn, icons.diagnostic_info,
|
|
||||||
icons.diagnostic_hint
|
|
||||||
if vim.diagnostic ~= nil then
|
|
||||||
local t = vim.fn.sign_getdefined('DiagnosticSignWarn')
|
|
||||||
if vim.tbl_isempty(t) or t[1].text == "W " and icons.icons == true then
|
|
||||||
|
|
||||||
vim.fn.sign_define('DiagnosticSignError',
|
|
||||||
{text = e, texthl = 'DiagnosticError', linehl = '', numhl = ''})
|
|
||||||
vim.fn.sign_define('DiagnosticSignWarn',
|
|
||||||
{text = w, texthl = 'DiagnosticWarn', linehl = '', numhl = ''})
|
|
||||||
vim.fn.sign_define('DiagnosticSignInfo',
|
|
||||||
{text = i, texthl = 'DiagnosticInfo', linehl = '', numhl = ''})
|
|
||||||
vim.fn.sign_define('DiagnosticSignHint',
|
|
||||||
{text = h, texthl = 'DiagnosticHint', linehl = '', numhl = ''})
|
|
||||||
|
|
||||||
t = vim.fn.sign_getdefined('DiagnosticSignWarn')
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local t = vim.fn.sign_getdefined('LspDiagnosticSignWarn')
|
|
||||||
if vim.tbl_isempty(t) or t[1].text == "W " and icons.icons == true then
|
|
||||||
vim.fn.sign_define('LspDiagnosticsSignError',
|
|
||||||
{text = e, texthl = 'LspDiagnosticsSignError', linehl = '', numhl = ''})
|
|
||||||
vim.fn.sign_define('LspDiagnosticsSignWarning',
|
|
||||||
{text = w, texthl = 'LspDiagnosticsSignWarning', linehl = '', numhl = ''})
|
|
||||||
vim.fn.sign_define('LspDiagnosticsSignInformation', {
|
|
||||||
text = i,
|
|
||||||
texthl = 'LspDiagnosticsSignInformation',
|
|
||||||
linehl = '',
|
|
||||||
numhl = ''
|
|
||||||
})
|
|
||||||
vim.fn.sign_define('LspDiagnosticsSignHint',
|
|
||||||
{text = h, texthl = 'LspDiagnosticsSignHint', linehl = '', numhl = ''})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
M.configed = true
|
M.configed = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.add_highlight()
|
local colors = {
|
||||||
|
{ '#aefe00', '#aede00', '#aebe00', '#4e7efe' },
|
||||||
|
{ '#ff00e0', '#df00e0', '#af00e0', '#fedefe' },
|
||||||
|
{ '#1000ef', '#2000df', '#2000cf', '#f0f040' },
|
||||||
|
{ '#d8a8a3', '#c8a8a3', '#b8a8a3', '#4e2c33' },
|
||||||
|
{ '#ffa724', '#efa024', '#dfa724', '#0040ff' },
|
||||||
|
{ '#afdc2b', '#09dc4b', '#08d04b', '#ef4f8f' },
|
||||||
|
}
|
||||||
|
|
||||||
|
function M.add_highlight()
|
||||||
-- lsp system default
|
-- lsp system default
|
||||||
api.nvim_command("hi! link LspDiagnosticsUnderlineError SpellBad")
|
|
||||||
api.nvim_command("hi! link LspDiagnosticsUnderlineWarning SpellRare")
|
|
||||||
api.nvim_command("hi! link LspDiagnosticsUnderlineInformation SpellRare")
|
|
||||||
api.nvim_command("hi! link LspDiagnosticsUnderlineHint SpellRare")
|
|
||||||
|
|
||||||
api.nvim_command("hi! link DiagnosticUnderlineError SpellBad")
|
api.nvim_set_hl(0, 'DiagnosticUnderlineError', { link = 'SpellBad', default = true })
|
||||||
api.nvim_command("hi! link DiagnosticUnderlineWarning SpellRare")
|
api.nvim_set_hl(0, 'DiagnosticUnderlineWarn', { link = 'SpellRare', default = true })
|
||||||
api.nvim_command("hi! link DiagnosticUnderlineInformation SpellRare")
|
api.nvim_set_hl(0, 'DiagnosticUnderlineInfo', { link = 'SpellRare', default = true })
|
||||||
api.nvim_command("hi! link DiagnosticUnderlineHint SpellRare")
|
api.nvim_set_hl(0, 'DiagnosticUnderlineHint', { link = 'SpellRare', default = true })
|
||||||
api.nvim_command("hi def link NGPreviewTitle Title")
|
api.nvim_set_hl(0, 'NGPreviewTitle', { link = 'Title', default = true })
|
||||||
local colors = {
|
api.nvim_set_hl(0, 'LspReferenceRead', { default = true, link = 'IncSearch' })
|
||||||
{'#aefe00', '#aede00', '#aebe00', '#4e7efe'}, {'#ff00e0', '#df00e0', '#af00e0', '#fedefe'},
|
api.nvim_set_hl(0, 'LspReferenceText', { default = true, link = 'Visual' })
|
||||||
{'#1000ef', '#2000df', '#2000cf', '#f0f040'}, {'#d8a8a3', '#c8a8a3', '#b8a8a3', '#4e2c33'},
|
api.nvim_set_hl(0, 'LspReferenceWrite', { default = true, link = 'Search' })
|
||||||
{'#ffa724', '#efa024', '#dfa724', '#0040ff'}, {'#afdc2b', '#09dc4b', '#08d04b', '#ef4f8f'}
|
|
||||||
}
|
|
||||||
|
|
||||||
for i = 1, #colors do
|
for i = 1, #colors do
|
||||||
for j = 1, 3 do
|
for j = 1, 3 do
|
||||||
local cmd = string.format("hi! default NGHiReference_%i_%i guibg=%s guifg=%s ", i, j,
|
local hlg = string.format('NGHiReference_%i_%i', i, j) -- , colors[i][j], colors[i][4]
|
||||||
colors[i][j], colors[i][4])
|
api.nvim_set_hl(0, hlg, { fg = colors[i][j], bg = colors[i][4], default = true })
|
||||||
vim.cmd(cmd)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
api.nvim_create_autocmd('ColorScheme', {
|
||||||
|
group = cmd_group,
|
||||||
|
pattern = '*',
|
||||||
|
callback = function()
|
||||||
|
M.add_highlight()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
local log = require('vim.lsp.log')
|
||||||
|
local util = require('vim.lsp.util')
|
||||||
|
local api = vim.api
|
||||||
|
local bufstates = {}
|
||||||
|
return {
|
||||||
|
on_inlayhint = function(err, result, ctx, _)
|
||||||
|
if err then
|
||||||
|
if log.error() then
|
||||||
|
log.error('inlayhint', err)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local bufnr = assert(ctx.bufnr)
|
||||||
|
if util.buf_versions[bufnr] ~= ctx.version then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local client_id = ctx.client_id
|
||||||
|
if not result then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local bufstate = bufstates[bufnr]
|
||||||
|
if not bufstate or not bufstate.enabled then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if not (bufstate.client_hint and bufstate.version) then
|
||||||
|
bufstate.client_hint = vim.defaulttable()
|
||||||
|
bufstate.version = ctx.version
|
||||||
|
end
|
||||||
|
local hints_by_client = bufstate.client_hint
|
||||||
|
local client = assert(vim.lsp.get_client_by_id(client_id))
|
||||||
|
|
||||||
|
local new_hints_by_lnum = vim.defaulttable()
|
||||||
|
local num_unprocessed = #result
|
||||||
|
if num_unprocessed == 0 then
|
||||||
|
hints_by_client[client_id] = {}
|
||||||
|
bufstate.version = ctx.version
|
||||||
|
api.nvim__buf_redraw_range(bufnr, 0, -1)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local lines = api.nvim_buf_get_lines(bufnr, 0, -1, false)
|
||||||
|
---@param position lsp.Position
|
||||||
|
---@return integer
|
||||||
|
local function pos_to_byte(position)
|
||||||
|
local col = position.character
|
||||||
|
if col > 0 then
|
||||||
|
local line = lines[position.line + 1] or ''
|
||||||
|
local ok, convert_result
|
||||||
|
ok, convert_result = pcall(util._str_byteindex_enc, line, col, client.offset_encoding)
|
||||||
|
if ok then
|
||||||
|
return convert_result
|
||||||
|
end
|
||||||
|
return math.min(#line, col)
|
||||||
|
end
|
||||||
|
return col
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, hint in ipairs(result) do
|
||||||
|
local lnum = hint.position.line
|
||||||
|
hint.position.character = pos_to_byte(hint.position)
|
||||||
|
table.insert(new_hints_by_lnum[lnum], hint)
|
||||||
|
end
|
||||||
|
|
||||||
|
hints_by_client[client_id] = new_hints_by_lnum
|
||||||
|
bufstate.version = ctx.version
|
||||||
|
api.nvim__buf_redraw_range(bufnr, 0, -1)
|
||||||
|
end,
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
local vfn = vim.fn
|
||||||
|
|
||||||
|
local on_attach = require('navigator.lspclient.attach').on_attach
|
||||||
|
|
||||||
|
local library = {}
|
||||||
|
local function add(lib)
|
||||||
|
for _, p in pairs(vfn.expand(lib, false, true)) do
|
||||||
|
local uv = vim.uv or vim.loop
|
||||||
|
p = uv.fs_realpath(p)
|
||||||
|
if p then
|
||||||
|
library[p] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local function lua_ls()
|
||||||
|
-- add runtime
|
||||||
|
-- add plugins it may be very slow to add all in path
|
||||||
|
add('$VIMRUNTIME')
|
||||||
|
-- add your config
|
||||||
|
-- local home = vfn.expand("$HOME")
|
||||||
|
add(vfn.stdpath('config'))
|
||||||
|
|
||||||
|
library[vfn.expand('$VIMRUNTIME/lua')] = true
|
||||||
|
library[vfn.expand('$VIMRUNTIME/lua/vim')] = true
|
||||||
|
library[vfn.expand('$VIMRUNTIME/lua/vim/lsp')] = true
|
||||||
|
|
||||||
|
return {
|
||||||
|
cmd = { 'lua-language-server' },
|
||||||
|
filetypes = { 'lua' },
|
||||||
|
on_attach = on_attach,
|
||||||
|
flags = { allow_incremental_sync = true, debounce_text_changes = 500 },
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
runtime = {
|
||||||
|
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||||
|
version = 'LuaJIT',
|
||||||
|
},
|
||||||
|
hint = { enable = true, typeCoverage = true },
|
||||||
|
diagnostics = {
|
||||||
|
enable = true,
|
||||||
|
-- Get the language server to recognize the `vim` global
|
||||||
|
globals = { 'vim', 'describe', 'it', 'before_each', 'after_each', 'teardown', 'pending' },
|
||||||
|
},
|
||||||
|
completion = { callSnippet = 'Both' },
|
||||||
|
workspace = {
|
||||||
|
-- Make the server aware of Neovim runtime files
|
||||||
|
library = library,
|
||||||
|
checkThirdParty = false,
|
||||||
|
maxPreload = 1000,
|
||||||
|
preloadFileSize = 40000,
|
||||||
|
},
|
||||||
|
telemetry = { enable = false },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
on_new_config = function(cfg, root)
|
||||||
|
local libs = vim.schedule(function()
|
||||||
|
vim.tbl_deep_extend('force', {}, library)
|
||||||
|
end)
|
||||||
|
libs[root] = nil
|
||||||
|
cfg.settings.Lua.workspace.library = libs
|
||||||
|
return cfg
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
lua_ls = lua_ls,
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
local util = require('lspconfig/util')
|
||||||
|
local path = util.path
|
||||||
|
local M = {}
|
||||||
|
local shell = vim.o.shell
|
||||||
|
local exepath = vim.fn.exepath
|
||||||
|
-- https://github.com/ray-x/navigator.lua/issues/247#issue-1465308677
|
||||||
|
M.pyenv_path = function(workspace)
|
||||||
|
-- Use activated virtualenv.
|
||||||
|
if vim.env.VIRTUAL_ENV then
|
||||||
|
return path.join(vim.env.VIRTUAL_ENV, 'bin', 'python'), 'virtual env'
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Find and use virtualenv in workspace directory.
|
||||||
|
for _, pattern in ipairs({ '*', '.*' }) do
|
||||||
|
local match = vim.fn.glob(path.join(workspace, pattern, 'pyvenv.cfg'))
|
||||||
|
local sep = require('navigator.util').path_sep()
|
||||||
|
local py = 'bin' .. sep .. 'python'
|
||||||
|
if match ~= '' then
|
||||||
|
print('found', match)
|
||||||
|
print(vim.fn.glob(path.join(workspace, pattern)))
|
||||||
|
match = string.gsub(match, 'pyvenv.cfg', py)
|
||||||
|
return match, string.format('venv base folder: %s', match)
|
||||||
|
end
|
||||||
|
match = vim.fn.glob(path.join(workspace, pattern, 'poetry.lock'))
|
||||||
|
if match ~= '' then
|
||||||
|
local venv_base_folder = vim.fn.trim(vim.fn.system('poetry env info -p'))
|
||||||
|
return path.join(venv_base_folder, 'bin', 'python'), string.format('venv base folder: %s', venv_base_folder)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Fallback to system Python.
|
||||||
|
return exepath('python3') or exepath('python') or 'python', 'fallback to system python path'
|
||||||
|
end
|
||||||
|
M.on_init = function(client)
|
||||||
|
local python_path, msg = M.pyenv_path(client.config.root_dir)
|
||||||
|
vim.notify(string.format('%s \ncurrent python path: %s', msg, python_path))
|
||||||
|
client.config.settings.python.pythonPath = python_path
|
||||||
|
end
|
||||||
|
return M
|
@ -0,0 +1,50 @@
|
|||||||
|
return {
|
||||||
|
'angularls',
|
||||||
|
'gopls',
|
||||||
|
'tsserver',
|
||||||
|
'flow',
|
||||||
|
'bashls',
|
||||||
|
'dockerls',
|
||||||
|
'julials',
|
||||||
|
'pylsp',
|
||||||
|
'pyright',
|
||||||
|
'jedi_language_server',
|
||||||
|
'jdtls',
|
||||||
|
'lua_ls',
|
||||||
|
'vimls',
|
||||||
|
'html',
|
||||||
|
'jsonls',
|
||||||
|
'solargraph',
|
||||||
|
'cssls',
|
||||||
|
'tailwindcss',
|
||||||
|
'yamlls',
|
||||||
|
'clangd',
|
||||||
|
'ccls',
|
||||||
|
'sqlls',
|
||||||
|
'denols',
|
||||||
|
'graphql',
|
||||||
|
'dartls',
|
||||||
|
'dotls',
|
||||||
|
'kotlin_language_server',
|
||||||
|
'nimls',
|
||||||
|
'intelephense',
|
||||||
|
'vuels',
|
||||||
|
'volar',
|
||||||
|
'phpactor',
|
||||||
|
'omnisharp',
|
||||||
|
'r_language_server',
|
||||||
|
'rust_analyzer',
|
||||||
|
'terraformls',
|
||||||
|
'svelte',
|
||||||
|
'texlab',
|
||||||
|
'clojure_lsp',
|
||||||
|
'elixirls',
|
||||||
|
'ruff_lsp',
|
||||||
|
'sourcekit',
|
||||||
|
'fsautocomplete',
|
||||||
|
'vls',
|
||||||
|
'hls',
|
||||||
|
'tflint',
|
||||||
|
'terraform_lsp',
|
||||||
|
'zls',
|
||||||
|
}
|
@ -1,16 +1,557 @@
|
|||||||
-- https://github.com/lukas-reineke/dotfiles/blob/master/vim/lua/lsp/rename.lua
|
-- the preview and cache are copy from
|
||||||
local M = {}
|
-- smjonas/inc-renamer.nvim
|
||||||
|
-- https://github.com/smjonas/inc-rename.nvim/blob/main/lua/inc_rename/init.lua
|
||||||
|
-- inplace rename are from neovim vim.lsp.buf.rename
|
||||||
|
|
||||||
local util = require('navigator.util')
|
local util = require('navigator.util')
|
||||||
-- local rename_prompt = 'Rename -> '
|
local log = util.log
|
||||||
|
local api = vim.api
|
||||||
|
local vfn = vim.fn
|
||||||
|
|
||||||
|
local M = {
|
||||||
|
hl_group = 'Substitute',
|
||||||
|
}
|
||||||
|
local make_position_params = vim.lsp.util.make_position_params
|
||||||
|
local rename_group = api.nvim_create_augroup('nav-rename', {})
|
||||||
|
|
||||||
|
local state = {
|
||||||
|
should_fetch_references = true,
|
||||||
|
cached_lines = nil,
|
||||||
|
input_win_id = nil,
|
||||||
|
input_bufnr = nil,
|
||||||
|
confirm = nil,
|
||||||
|
oldname = nil,
|
||||||
|
newname = nil,
|
||||||
|
err = nil,
|
||||||
|
}
|
||||||
|
local backspace = api.nvim_replace_termcodes('<bs>', true, false, true)
|
||||||
|
|
||||||
|
local ns = api.nvim_create_namespace('nav-rename')
|
||||||
|
|
||||||
|
local function set_error(msg, level)
|
||||||
|
state.err = { msg = msg, level = level }
|
||||||
|
state.cached_lines = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local function ts_symbol()
|
||||||
|
local ok, _ = pcall(require, 'nvim-treesitter')
|
||||||
|
if not ok then
|
||||||
|
vim.notify('treesitter not installed')
|
||||||
|
-- try best
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
|
local bufnr = api.nvim_get_current_buf()
|
||||||
|
local queries = require('nvim-treesitter.query')
|
||||||
|
local ft_to_lang = require('nvim-treesitter.parsers').ft_to_lang
|
||||||
|
|
||||||
|
local lang = ft_to_lang(vim.bo[bufnr].filetype)
|
||||||
|
local query = (vim.fn.has('nvim-0.9') == 1) and vim.treesitter.query.get(lang, 'highlights')
|
||||||
|
or vim.treesitter.get_query(lang, 'highlights')
|
||||||
|
|
||||||
|
local ts_utils = require('nvim-treesitter.ts_utils')
|
||||||
|
local current_node = ts_utils.get_node_at_cursor()
|
||||||
|
if not current_node then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local start_row, _, end_row, _ = current_node:range()
|
||||||
|
for id, _, _ in query:iter_captures(current_node, 0, start_row, end_row) do
|
||||||
|
local name = query.captures[id]
|
||||||
|
if name:find('builtin') or name:find('keyword') then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return current_node
|
||||||
|
end
|
||||||
|
|
||||||
|
local function visible(bufnr)
|
||||||
|
if api.nvim_buf_is_loaded(bufnr) then
|
||||||
|
for _, win in ipairs(api.nvim_tabpage_list_wins(0)) do
|
||||||
|
if api.nvim_win_get_buf(win) == bufnr then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local function hash(a, b, c)
|
||||||
|
local cantor = function(x, y)
|
||||||
|
return (x + y + 1) * (x + y) / 2 + y
|
||||||
|
end
|
||||||
|
return cantor(a, cantor(b, c))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- a function from smjonas/inc-rename.nvim
|
||||||
|
local function cache_lines(result)
|
||||||
|
local cached_lines = {}
|
||||||
|
local exists = {}
|
||||||
|
for _, res in ipairs(result) do
|
||||||
|
local range = res.range
|
||||||
|
if range.start.line == range['end'].line then
|
||||||
|
local bufnr
|
||||||
|
if res.uri then
|
||||||
|
bufnr = vim.uri_to_bufnr(res.uri)
|
||||||
|
else
|
||||||
|
bufnr = vim.api.nvim_get_current_buf()
|
||||||
|
end
|
||||||
|
if visible(bufnr) then
|
||||||
|
if not cached_lines[bufnr] then
|
||||||
|
cached_lines[bufnr] = {}
|
||||||
|
end
|
||||||
|
if not exists[bufnr] then
|
||||||
|
exists[bufnr] = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
local line_nr = range.start.line
|
||||||
|
local line = api.nvim_buf_get_lines(bufnr, line_nr, line_nr + 1, false)[1]
|
||||||
|
local start_col, end_col = range.start.character, range['end'].character
|
||||||
|
local line_info = { text = line, start_col = start_col, end_col = end_col }
|
||||||
|
local h = hash(line_nr, start_col, end_col)
|
||||||
|
if not exists[bufnr][h] then
|
||||||
|
if cached_lines[bufnr][line_nr] then
|
||||||
|
table.insert(cached_lines[bufnr][line_nr], line_info)
|
||||||
|
else
|
||||||
|
cached_lines[bufnr][line_nr] = { line_info }
|
||||||
|
end
|
||||||
|
exists[bufnr][h] = true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- log(cached_lines[bufnr])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return cached_lines
|
||||||
|
end
|
||||||
|
|
||||||
|
local function fetch_lsp_references(bufnr, lsp_params, callback)
|
||||||
|
require('navigator.reference').fetch_lsp_references(
|
||||||
|
bufnr,
|
||||||
|
lsp_params,
|
||||||
|
function(err, result, ctx, cfg)
|
||||||
|
if err then
|
||||||
|
log('[nav-rename] Error while finding references: ' .. err.message, ctx, cfg)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if not result or vim.tbl_isempty(result) then
|
||||||
|
log('[nav-rename] Nothing to rename', result)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
state.total = #result
|
||||||
|
state.cached_lines = cache_lines(result)
|
||||||
|
state.should_fetch_references = false
|
||||||
|
if callback then
|
||||||
|
callback()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- inspired by smjonas/inc-rename.nvim
|
||||||
|
local function teardown(switch_buffer)
|
||||||
|
state.should_fetch_references = true
|
||||||
|
state.cached_lines = nil
|
||||||
|
state.oldname = nil
|
||||||
|
state.newname = nil
|
||||||
|
if state.input_win_id and api.nvim_win_is_valid(state.input_win_id) then
|
||||||
|
state.input_win_id = nil
|
||||||
|
if switch_buffer then
|
||||||
|
api.nvim_set_current_win(state.win_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function restore_buffer()
|
||||||
|
for bufnr, line_info_per_bufnr in pairs(state.cached_lines or {}) do
|
||||||
|
for line_nr, line_info in pairs(line_info_per_bufnr) do
|
||||||
|
log(line_nr, line_info[1].text)
|
||||||
|
api.nvim_buf_set_lines(bufnr, line_nr, line_nr + 1, false, { line_info[1].text })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Called when the user is still typing the command or the command arguments
|
||||||
|
-- inspired by smjonas/inc-rename.nvim
|
||||||
|
local function incremental_rename_preview(opts, preview_ns, preview_buf)
|
||||||
|
log(opts, preview_ns, preview_buf)
|
||||||
|
local new_name = opts.args
|
||||||
|
|
||||||
|
state.new_name = new_name
|
||||||
|
vim.v.errmsg = ''
|
||||||
|
|
||||||
|
if state.should_fetch_references then
|
||||||
|
fetch_lsp_references(preview_buf, state.lsp_params, function()
|
||||||
|
incremental_rename_preview(opts, preview_ns, preview_buf)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not state.cached_lines then
|
||||||
|
log('lsp references not fetched yet')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local function apply_highlights_fn(bufnr, line_nr, line_info)
|
||||||
|
local offset = 0
|
||||||
|
local updated_line = line_info[1].text
|
||||||
|
local highlight_positions = {}
|
||||||
|
|
||||||
|
for _, info in ipairs(line_info) do
|
||||||
|
updated_line = updated_line:sub(1, info.start_col + offset)
|
||||||
|
.. new_name
|
||||||
|
.. updated_line:sub(info.end_col + 1 + offset)
|
||||||
|
|
||||||
|
table.insert(highlight_positions, {
|
||||||
|
start_col = info.start_col + offset,
|
||||||
|
end_col = info.start_col + #new_name + offset,
|
||||||
|
})
|
||||||
|
-- Offset by the length difference between the new and old names
|
||||||
|
offset = offset + #new_name - (info.end_col - info.start_col)
|
||||||
|
end
|
||||||
|
|
||||||
|
api.nvim_buf_set_lines(bufnr or opts.bufnr, line_nr, line_nr + 1, false, { updated_line })
|
||||||
|
|
||||||
|
for _, hl_pos in ipairs(highlight_positions) do
|
||||||
|
api.nvim_buf_add_highlight(
|
||||||
|
bufnr or opts.bufnr,
|
||||||
|
preview_ns,
|
||||||
|
M.hl_group,
|
||||||
|
line_nr,
|
||||||
|
hl_pos.start_col,
|
||||||
|
hl_pos.end_col
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for bufnr, line_info_per_bufnr in pairs(state.cached_lines) do
|
||||||
|
for line_nr, line_info in pairs(line_info_per_bufnr) do
|
||||||
|
apply_highlights_fn(bufnr, line_nr, line_info)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
state.preview_ns = preview_ns
|
||||||
|
end
|
||||||
|
|
||||||
|
-- function rewrite from smjonas/inc-rename.nvim
|
||||||
|
local function perform_lsp_rename(new_name, params)
|
||||||
|
params = params or make_position_params()
|
||||||
|
params.newName = new_name
|
||||||
|
|
||||||
|
vim.lsp.buf_request(0, 'textDocument/rename', params, function(err, result, ctx, _)
|
||||||
|
if err and err.message then
|
||||||
|
vim.notify('[nav-rename] Error while renaming: ' .. err.message, vim.log.levels.ERROR)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if not result or vim.tbl_isempty(result) then
|
||||||
|
set_error('[nav-rename] Nothing renamed', vim.log.levels.INFO)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
||||||
|
vim.lsp.util.apply_workspace_edit(result, client.offset_encoding)
|
||||||
|
|
||||||
|
if _NgConfigValues.lsp.rename.show_result then
|
||||||
|
local changed_instances = 0
|
||||||
|
local changed_files = 0
|
||||||
|
|
||||||
|
local with_edits = result.documentChanges ~= nil
|
||||||
|
for _, change in pairs(result.documentChanges or result.changes) do
|
||||||
|
changed_instances = changed_instances + (with_edits and #change.edits or #change)
|
||||||
|
changed_files = changed_files + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
local message = string.format(
|
||||||
|
'Renamed %s instance%s %s in %s file%s \n to %s:',
|
||||||
|
changed_instances,
|
||||||
|
changed_instances == 1 and '' or 's',
|
||||||
|
state.oldname,
|
||||||
|
changed_files,
|
||||||
|
changed_files == 1 and '' or 's',
|
||||||
|
new_name
|
||||||
|
)
|
||||||
|
vim.notify(message)
|
||||||
|
end
|
||||||
|
if M.config and M.config.post_hook then
|
||||||
|
M.config.post_hook(result)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function inc_rename_execute(opts)
|
||||||
|
if vim.v.errmsg ~= '' then
|
||||||
|
log(
|
||||||
|
'[nav-rename] An error occurred in the preview function.' .. vim.v.errmsg,
|
||||||
|
vim.log.levels.ERROR
|
||||||
|
)
|
||||||
|
elseif state.err then
|
||||||
|
log(state.err.msg, state.err.level)
|
||||||
|
end
|
||||||
|
restore_buffer()
|
||||||
|
teardown(true)
|
||||||
|
perform_lsp_rename(opts.args, opts.params)
|
||||||
|
end
|
||||||
|
|
||||||
M.rename = function()
|
M.rename = function()
|
||||||
|
if _NgConfigValues.lsp.rename.style == 'floating-preview' then
|
||||||
|
return M.rename_preview()
|
||||||
|
end
|
||||||
|
if _NgConfigValues.lsp.rename.style == 'inplace-preview' then
|
||||||
|
return M.rename_inplace()
|
||||||
|
end
|
||||||
|
|
||||||
local input = vim.ui.input
|
local input = vim.ui.input
|
||||||
|
|
||||||
vim.ui.input = require('guihua.floating').input
|
local ghinput = require('guihua.input')
|
||||||
|
-- make sure everything was restored
|
||||||
|
ghinput.setup({
|
||||||
|
on_change = function(new_name) end,
|
||||||
|
on_concel = function(new_name) end,
|
||||||
|
title = 'lsp rename',
|
||||||
|
on_cancel = function() end,
|
||||||
|
})
|
||||||
|
vim.ui.input = ghinput.input
|
||||||
vim.lsp.buf.rename()
|
vim.lsp.buf.rename()
|
||||||
vim.defer_fn(function()
|
vim.defer_fn(function()
|
||||||
vim.ui.input = input
|
vim.ui.input = input
|
||||||
end, 1000)
|
end, 1000)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
M.rename_preview = function()
|
||||||
|
local input = vim.ui.input
|
||||||
|
state.cached_lines = {}
|
||||||
|
state.confrim = nil
|
||||||
|
state.should_fetch_references = true
|
||||||
|
state.lsp_params = make_position_params()
|
||||||
|
|
||||||
|
if not ts_symbol() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
rename_group = api.nvim_create_augroup('nav-rename', {})
|
||||||
|
if vim.fn.has('nvim-0.8.0') ~= 1 then
|
||||||
|
vim.ui.input = require('guihua.floating').input
|
||||||
|
vim.lsp.buf.rename()
|
||||||
|
return vim.defer_fn(function()
|
||||||
|
vim.ui.input = input
|
||||||
|
end, 1000)
|
||||||
|
end
|
||||||
|
|
||||||
|
local ghinput = require('guihua.input')
|
||||||
|
state.win_id = vim.fn.win_getid(0)
|
||||||
|
state.lsp_params = make_position_params()
|
||||||
|
state.preview_buf = vim.api.nvim_get_current_buf()
|
||||||
|
|
||||||
|
local inputopts = {
|
||||||
|
on_change = function(new_name)
|
||||||
|
incremental_rename_preview({ args = new_name }, ns, state.preview_buf)
|
||||||
|
end,
|
||||||
|
preview_buf = state.preview_buf,
|
||||||
|
on_confirm = function(new_name)
|
||||||
|
-- put back everything
|
||||||
|
log('on_confirm', new_name)
|
||||||
|
restore_buffer()
|
||||||
|
end,
|
||||||
|
on_cancel = function(new_name)
|
||||||
|
restore_buffer()
|
||||||
|
teardown(true)
|
||||||
|
log('cancel', new_name)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
if vim.fn.has('nvim-0.9.0') == 1 then
|
||||||
|
inputopts.title = 'symbol rename'
|
||||||
|
end
|
||||||
|
ghinput.setup(inputopts)
|
||||||
|
vim.ui.input = ghinput.input
|
||||||
|
|
||||||
|
vim.lsp.buf.rename()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- rename without floating window
|
||||||
|
-- a moodify version of neovim vim.lsp.buf.rename
|
||||||
|
function M.rename_inplace(new_name, options)
|
||||||
|
options = options or {}
|
||||||
|
state.confrim = nil
|
||||||
|
state.should_fetch_references = true
|
||||||
|
state.cached_lines = {}
|
||||||
|
state.lsp_params = make_position_params()
|
||||||
|
rename_group = api.nvim_create_augroup('nav-rename', {})
|
||||||
|
local bufnr = options.bufnr or api.nvim_get_current_buf()
|
||||||
|
local clients = vim.lsp.get_clients({
|
||||||
|
bufnr = bufnr,
|
||||||
|
name = options.name,
|
||||||
|
})
|
||||||
|
if options.filter then
|
||||||
|
clients = vim.tbl_filter(options.filter, clients)
|
||||||
|
end
|
||||||
|
|
||||||
|
if not ts_symbol() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Clients must at least support rename, prepareRename is optional
|
||||||
|
clients = vim.tbl_filter(function(client)
|
||||||
|
return client.supports_method('textDocument/rename')
|
||||||
|
end, clients)
|
||||||
|
|
||||||
|
if #clients == 0 then
|
||||||
|
vim.notify('[LSP] Rename, no matching language servers with rename capability.')
|
||||||
|
end
|
||||||
|
|
||||||
|
local confirm_key = _NgConfigValues.lsp.rename.confirm
|
||||||
|
local cancel_key = _NgConfigValues.lsp.rename.concel
|
||||||
|
local win = api.nvim_get_current_win()
|
||||||
|
|
||||||
|
-- Compute early to account for cursor movements after going async
|
||||||
|
local cword = vim.fn.expand('<cword>')
|
||||||
|
state.oldname = cword
|
||||||
|
|
||||||
|
---@private
|
||||||
|
local function get_text_at_range(range, offset_encoding)
|
||||||
|
return api.nvim_buf_get_text(
|
||||||
|
bufnr,
|
||||||
|
range.start.line,
|
||||||
|
util._get_line_byte_from_position(bufnr, range.start, offset_encoding),
|
||||||
|
range['end'].line,
|
||||||
|
util._get_line_byte_from_position(bufnr, range['end'], offset_encoding),
|
||||||
|
{}
|
||||||
|
)[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
local on_finish_cb = function()
|
||||||
|
log('leave insert')
|
||||||
|
|
||||||
|
api.nvim_buf_clear_namespace(bufnr, ns, 0, -1)
|
||||||
|
api.nvim_del_augroup_by_name('nav-rename')
|
||||||
|
vim.keymap.del({ 'i', 'n' }, confirm_key, { buffer = bufnr })
|
||||||
|
vim.keymap.del({ 'i', 'n' }, cancel_key, { buffer = bufnr })
|
||||||
|
restore_buffer()
|
||||||
|
if state.confirm then
|
||||||
|
-- lets put back
|
||||||
|
log('execute rename')
|
||||||
|
inc_rename_execute({ args = state.new_name or vim.fn.expand('<cword>'), params = {} })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local try_use_client
|
||||||
|
try_use_client = function(idx, client)
|
||||||
|
if not client then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local params = make_position_params(win, client.offset_encoding)
|
||||||
|
---@private
|
||||||
|
local function rename(name)
|
||||||
|
params.newName = name
|
||||||
|
local handler = client.handlers['textDocument/rename']
|
||||||
|
or vim.lsp.handlers['textDocument/rename']
|
||||||
|
client.request('textDocument/rename', params, function(...)
|
||||||
|
handler(...)
|
||||||
|
try_use_client(next(clients, idx))
|
||||||
|
end, bufnr)
|
||||||
|
end
|
||||||
|
|
||||||
|
if client.supports_method('textDocument/prepareRename') then
|
||||||
|
-- log(params)
|
||||||
|
client.request('textDocument/prepareRename', params, function(err, result)
|
||||||
|
if err or result == nil then
|
||||||
|
if next(clients, idx) then
|
||||||
|
try_use_client(next(clients, idx))
|
||||||
|
else
|
||||||
|
local msg = err and ('Error on prepareRename: ' .. (err.message or ''))
|
||||||
|
or 'Nothing to rename'
|
||||||
|
vim.notify(msg, vim.log.levels.INFO)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
incremental_rename_preview({ args = cword, floating = false }, 0, bufnr)
|
||||||
|
if new_name then
|
||||||
|
return rename(new_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ 'TextChangedI', 'TextChanged' }, {
|
||||||
|
group = rename_group,
|
||||||
|
callback = function()
|
||||||
|
local w = vim.fn.expand('<cword>')
|
||||||
|
local curl = vfn.getline('.')
|
||||||
|
local curc = curl:sub(vfn.col('.'), vfn.col('.'))
|
||||||
|
local node = ts_symbol()
|
||||||
|
if node and node:type():find('identifier') then
|
||||||
|
w = vim.treesitter.get_node_text(node, bufnr)
|
||||||
|
log(node:range(), node:type())
|
||||||
|
else
|
||||||
|
-- log(curc, node:type(), vim.treesitter.get_node_text(node, bufnr))
|
||||||
|
-- cursor at end of symbol
|
||||||
|
if curc:match('%W') and curc ~= '_' then
|
||||||
|
local cur_pos = vim.fn.getpos('.')
|
||||||
|
cur_pos[3] = cur_pos[3] - 1
|
||||||
|
vfn.setpos('.', cur_pos)
|
||||||
|
log('move back')
|
||||||
|
|
||||||
|
node = ts_symbol()
|
||||||
|
if node and node:type():find('identifier') then
|
||||||
|
w = vim.treesitter.get_node_text(node, bufnr)
|
||||||
|
else
|
||||||
|
w = vim.fn.expand('<cword>')
|
||||||
|
end
|
||||||
|
cur_pos[3] = cur_pos[3] + 1
|
||||||
|
vfn.setpos('.', cur_pos)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
log(curc, w)
|
||||||
|
incremental_rename_preview({ args = w, floating = false }, ns, bufnr)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
vim.keymap.set({ 'i', 'n' }, confirm_key, function()
|
||||||
|
print('done rename')
|
||||||
|
local input = vim.fn.expand('<cword>')
|
||||||
|
log('newname', input)
|
||||||
|
state.confirm = true
|
||||||
|
vim.cmd('stopinsert')
|
||||||
|
on_finish_cb()
|
||||||
|
end, { buffer = bufnr })
|
||||||
|
|
||||||
|
if cancel_key == nil or cancel_key == '' then
|
||||||
|
vim.api.nvim_create_autocmd({ 'InsertLeave' }, {
|
||||||
|
group = rename_group,
|
||||||
|
callback = function()
|
||||||
|
state.confirm = nil
|
||||||
|
on_finish_cb()
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
else
|
||||||
|
vim.keymap.set({ 'i', 'n' }, cancel_key, function()
|
||||||
|
print('cancel rename')
|
||||||
|
state.confirm = nil
|
||||||
|
on_finish_cb()
|
||||||
|
end, { buffer = bufnr })
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.cmd('noautocmd startinsert')
|
||||||
|
end, bufnr)
|
||||||
|
else
|
||||||
|
assert(
|
||||||
|
client.supports_method('textDocument/rename'),
|
||||||
|
'Client must support textDocument/rename'
|
||||||
|
)
|
||||||
|
if new_name then
|
||||||
|
rename(new_name)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local prompt_opts = {
|
||||||
|
prompt = 'New Name: ',
|
||||||
|
default = cword,
|
||||||
|
}
|
||||||
|
vim.ui.input(prompt_opts, function(input)
|
||||||
|
if not input or #input == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
rename(input)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
try_use_client(next(clients))
|
||||||
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
@ -0,0 +1,110 @@
|
|||||||
|
local diagnostic = vim.diagnostic or vim.lsp.diagnostic
|
||||||
|
local util = require('navigator.util')
|
||||||
|
local log = util.log
|
||||||
|
local api = vim.api
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
function M.treesitter_and_diag_panel()
|
||||||
|
local Panel = require('guihua.panel')
|
||||||
|
|
||||||
|
local diag = require('navigator.diagnostics')
|
||||||
|
local ft = vim.bo.filetype
|
||||||
|
local results = diag.diagnostic_list[ft]
|
||||||
|
log(diag.diagnostic_list, ft)
|
||||||
|
|
||||||
|
local bufnr = api.nvim_get_current_buf()
|
||||||
|
local p = Panel:new({
|
||||||
|
header = 'treesitter',
|
||||||
|
render = function(b)
|
||||||
|
log('render for ', bufnr, b)
|
||||||
|
return require('navigator.treesitter').all_ts_nodes(b)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
p:add_section({
|
||||||
|
header = 'diagnostic',
|
||||||
|
render = function(buf)
|
||||||
|
log(buf, diagnostic)
|
||||||
|
if diag.diagnostic_list[ft] ~= nil then
|
||||||
|
local display_items = {}
|
||||||
|
for _, client_items in pairs(results) do
|
||||||
|
for _, items in pairs(client_items) do
|
||||||
|
for _, it in pairs(items) do
|
||||||
|
log(it)
|
||||||
|
table.insert(display_items, it)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return display_items
|
||||||
|
else
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
p:open(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.lsp_and_diag_panel()
|
||||||
|
local Panel = require('guihua.panel')
|
||||||
|
|
||||||
|
local ft = vim.bo.filetype
|
||||||
|
local diag = require('navigator.diagnostics')
|
||||||
|
local results = diag.diagnostic_list[ft]
|
||||||
|
log(diag.diagnostic_list, ft)
|
||||||
|
|
||||||
|
local bf = api.nvim_get_current_buf()
|
||||||
|
ft = vim.api.nvim_buf_get_option(bf, 'buftype') or vim.bo.filetype
|
||||||
|
if ft == 'nofile' or ft == 'guihua' or ft == 'prompt' then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local lsp
|
||||||
|
local p = Panel:new({
|
||||||
|
header = 'symbols',
|
||||||
|
render = function(bufnr)
|
||||||
|
bufnr = bufnr or api.nvim_get_current_buf()
|
||||||
|
local params = vim.lsp.util.make_range_params()
|
||||||
|
local lsp_call = require('navigator.lspwrapper').call_sync
|
||||||
|
if not Panel:is_open() or vim.fn.empty(lsp) == 1 then
|
||||||
|
lsp = lsp_call(
|
||||||
|
'textDocument/documentSymbol',
|
||||||
|
params,
|
||||||
|
{ timeout = 2000, bufnr = bufnr, no_show = true },
|
||||||
|
vim.lsp.with(require('navigator.symbols').document_symbol_handler, { no_show = true })
|
||||||
|
)
|
||||||
|
else
|
||||||
|
lsp_call = require('navigator.lspwrapper').call_async
|
||||||
|
local f = function(err, result, ctx)
|
||||||
|
-- log(result, ctx)
|
||||||
|
ctx = ctx or {}
|
||||||
|
ctx.no_show = true
|
||||||
|
lsp = require('navigator.symbols').document_symbol_handler(err, result, ctx)
|
||||||
|
return lsp
|
||||||
|
end
|
||||||
|
lsp_call('textDocument/documentSymbol', params, f, bufnr)
|
||||||
|
end
|
||||||
|
return lsp
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
p:add_section({
|
||||||
|
header = 'diagnostic',
|
||||||
|
render = function(buf)
|
||||||
|
log(buf, diagnostic)
|
||||||
|
if results ~= nil then
|
||||||
|
local display_items = {}
|
||||||
|
for _, client_items in pairs(results) do
|
||||||
|
for _, items in pairs(client_items) do
|
||||||
|
for _, it in pairs(items) do
|
||||||
|
log(it)
|
||||||
|
table.insert(display_items, it)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return display_items
|
||||||
|
else
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
p:open(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
@ -1,75 +0,0 @@
|
|||||||
local gui = require "navigator.gui"
|
|
||||||
local util = require "navigator.util"
|
|
||||||
local mk_handler = util.mk_handler
|
|
||||||
local log = util.log
|
|
||||||
local partial = util.partial
|
|
||||||
local lsphelper = require "navigator.lspwrapper"
|
|
||||||
local cwd = vim.loop.cwd()
|
|
||||||
local M = {}
|
|
||||||
|
|
||||||
--- navigator signature
|
|
||||||
local match_parameter = function(result)
|
|
||||||
local signatures = result.signatures
|
|
||||||
if #signatures < 1 then
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
local signature = signatures[1]
|
|
||||||
local activeParameter = result.activeParameter or signature.activeParameter
|
|
||||||
if activeParameter == nil then
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
if signature.parameters == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if #signature.parameters < 2 or activeParameter + 1 > #signature.parameters then
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
local nextParameter = signature.parameters[activeParameter + 1]
|
|
||||||
|
|
||||||
local label = signature.label
|
|
||||||
if type(nextParameter.label) == "table" then -- label = {2, 4} c style
|
|
||||||
local range = nextParameter.label
|
|
||||||
label = label:sub(1, range[1]) .. [[`]] .. label:sub(range[1] + 1, range[2]) .. [[`]]
|
|
||||||
.. label:sub(range[2] + 1, #label + 1)
|
|
||||||
signature.label = label
|
|
||||||
else
|
|
||||||
if type(nextParameter.label) == "string" then -- label = 'par1 int'
|
|
||||||
local i, j = label:find(nextParameter.label, 1, true)
|
|
||||||
if i ~= nil then
|
|
||||||
label = label:sub(1, i - 1) .. [[`]] .. label:sub(i, j) .. [[`]] .. label:sub(j + 1, #label + 1)
|
|
||||||
signature.label = label
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local signature_handler = mk_handler(function(err, result, ctx, config)
|
|
||||||
if config == nil then
|
|
||||||
log("config nil")
|
|
||||||
end
|
|
||||||
if err then
|
|
||||||
vim.notify("signature help error: ".. vim.inspect(err) .. vim.inspect(result), ctx, config, vim.lsp.log_levels.WARN)
|
|
||||||
end
|
|
||||||
config = config or {}
|
|
||||||
if config.border == nil then
|
|
||||||
config.border = _NgConfigValues.border
|
|
||||||
end
|
|
||||||
|
|
||||||
if not (result and result.signatures and result.signatures[1]) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
match_parameter(result)
|
|
||||||
local lines = vim.lsp.util.convert_signature_help_to_markdown_lines(result)
|
|
||||||
if vim.tbl_isempty(lines) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local syntax = vim.lsp.util.try_trim_markdown_code_blocks(lines)
|
|
||||||
config.focus_id = ctx.bufnr .. "lsp_signature"
|
|
||||||
vim.lsp.util.open_floating_preview(lines, syntax, config)
|
|
||||||
end)
|
|
||||||
return {signature_handler = signature_handler}
|
|
@ -0,0 +1,43 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
// Create an unordered_map of three strings (that map to strings)
|
||||||
|
std::unordered_map<std::string, std::string> u =
|
||||||
|
{
|
||||||
|
{"RED", "#FF0000"},
|
||||||
|
{"GREEN", "#00FF00"},
|
||||||
|
{"BLUE", "#0000FF"}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helper lambda function to print key-value pairs
|
||||||
|
auto print_key_value = [](const auto& key, const auto& value)
|
||||||
|
{
|
||||||
|
std::cout << "Key:[" << key << "] Value:[" << value << "]\n";
|
||||||
|
};
|
||||||
|
std::cout << "Iterate and print key-value pairs of unordered_map, being\n"
|
||||||
|
"explicit with their types:\n";
|
||||||
|
for (const std::pair<const std::string, std::string>& n : u)
|
||||||
|
print_key_value(n.first, n.second);
|
||||||
|
std::cout << "\nIterate and print key-value pairs using C++17 structured binding:\n";
|
||||||
|
for (const auto& [key, value] : u)
|
||||||
|
print_key_value(key, value);
|
||||||
|
|
||||||
|
// Add two new entries to the unordered_map
|
||||||
|
u["BLACK"] = "#000000";
|
||||||
|
u["WHITE"] = "#FFFFFF";
|
||||||
|
|
||||||
|
std::cout << "\nOutput values by key:\n"
|
||||||
|
"The HEX of color RED is:[" << u["RED"] << "]\n"
|
||||||
|
"The HEX of color BLACK is:[" << u["BLACK"] << "]\n\n";
|
||||||
|
|
||||||
|
std::cout << "Use operator[] with non-existent key to insert a new key-value pair:\n";
|
||||||
|
print_key_value("new_key", u["new_key"]);
|
||||||
|
|
||||||
|
std::cout << "\nIterate and print key-value pairs, using `auto`;\n"
|
||||||
|
"new_key is now one of the keys in the map:\n";
|
||||||
|
for (const auto& n : u)
|
||||||
|
print_key_value(n.first, n.second);
|
||||||
|
}
|
@ -1,117 +1,157 @@
|
|||||||
vim.cmd([[set runtimepath=$VIMRUNTIME]])
|
vim.cmd([[set runtimepath=$VIMRUNTIME]])
|
||||||
vim.cmd([[set packpath=/tmp/nvim/site]])
|
local uv = vim.uv or vim.loop
|
||||||
|
local os_name = uv.os_uname().sysname
|
||||||
|
|
||||||
local package_root = '/tmp/nvim/site/pack'
|
local is_windows = os_name == 'Windows' or os_name == 'Windows_NT'
|
||||||
local install_path = package_root .. '/packer/start/packer.nvim'
|
|
||||||
|
|
||||||
-- IMPORTANT: update the sumneko setup if you need lua language server
|
local package_root = '/tmp/nvim/lazy'
|
||||||
-- I installed it in '/github/sumneko/lua-language-server'
|
local sep = '/'
|
||||||
local sumneko_root_path = vim.fn.expand('$HOME') .. '/github/sumneko/lua-language-server'
|
if is_windows then
|
||||||
local sumneko_binary = vim.fn.expand('$HOME') .. '/github/sumneko/lua-language-server/bin/macOS/lua-language-server'
|
local tmp = os.getenv('TEMP')
|
||||||
|
vim.cmd('set packpath=' .. tmp .. '\\nvim\\lazy')
|
||||||
local lua_cfg = {
|
package_root = tmp .. '\\nvim\\lazy'
|
||||||
cmd = { sumneko_binary, '-E', sumneko_root_path .. '/main.lua' },
|
sep = '\\'
|
||||||
settings = {
|
else
|
||||||
Lua = {
|
vim.cmd([[set packpath=/tmp/nvim/lazy]])
|
||||||
runtime = { version = 'LuaJIT', path = vim.split(package.path, ';') },
|
end
|
||||||
diagnostics = { enable = true },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
local function load_plugins()
|
|
||||||
require('packer').startup({
|
|
||||||
function(use)
|
|
||||||
use({ 'wbthomason/packer.nvim' })
|
|
||||||
use({
|
|
||||||
'nvim-treesitter/nvim-treesitter',
|
|
||||||
config = function()
|
|
||||||
require('nvim-treesitter.configs').setup({
|
|
||||||
ensure_installed = { 'python', 'go', 'javascript' },
|
|
||||||
highlight = { enable = true },
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
run = ':TSUpdate',
|
|
||||||
})
|
|
||||||
use({ 'neovim/nvim-lspconfig' })
|
|
||||||
use({ 'ray-x/lsp_signature.nvim' })
|
|
||||||
use({ 'ray-x/aurora' })
|
|
||||||
use({
|
|
||||||
'ray-x/navigator.lua',
|
|
||||||
-- '~/github/navigator.lua',
|
|
||||||
requires = { 'ray-x/guihua.lua', run = 'cd lua/fzy && make' },
|
|
||||||
config = function()
|
|
||||||
require('navigator').setup({
|
|
||||||
lsp_signature_help = true,
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
use({ 'L3MON4D3/LuaSnip' })
|
|
||||||
use({
|
|
||||||
'hrsh7th/nvim-cmp',
|
|
||||||
requires = {
|
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
|
||||||
'saadparwaiz1/cmp_luasnip',
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
local cmp = require('cmp')
|
|
||||||
local luasnip = require('luasnip')
|
|
||||||
cmp.setup({
|
|
||||||
snippet = {
|
|
||||||
expand = function(args)
|
|
||||||
require('luasnip').lsp_expand(args.body)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
|
|
||||||
mapping = {
|
|
||||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
|
||||||
['<Tab>'] = cmp.mapping(function(fallback)
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.confirm({ select = true })
|
|
||||||
elseif luasnip.expand_or_locally_jumpable() then
|
|
||||||
luasnip.expand_or_jump()
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { 'i', 's' }),
|
|
||||||
},
|
|
||||||
|
|
||||||
sources = {
|
local plugin_folder = function()
|
||||||
{ name = 'nvim_lsp' },
|
local host = os.getenv('HOST_NAME')
|
||||||
{ name = 'buffer' },
|
if host and (host:find('Ray') or host:find('ray')) then
|
||||||
},
|
return [[~/github/ray-x]] -- vim.fn.expand("$HOME") .. '/github/'
|
||||||
})
|
else
|
||||||
require('cmp').setup.cmdline(':', {
|
return ''
|
||||||
sources = {
|
end
|
||||||
{ name = 'cmdline' },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
require('cmp').setup.cmdline('/', {
|
|
||||||
sources = {
|
|
||||||
{ name = 'buffer' },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
config = {
|
|
||||||
package_root = package_root,
|
|
||||||
compile_path = install_path .. '/plugin/packer_compiled.lua',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if vim.fn.isdirectory(install_path) == 0 then
|
local lazypath = package_root .. sep .. 'lazy.nvim'
|
||||||
|
if not uv.fs_stat(lazypath) then
|
||||||
vim.fn.system({
|
vim.fn.system({
|
||||||
'git',
|
'git',
|
||||||
'clone',
|
'clone',
|
||||||
'https://github.com/wbthomason/packer.nvim',
|
'--filter=blob:none',
|
||||||
install_path,
|
'https://github.com/folke/lazy.nvim.git',
|
||||||
|
'--branch=stable', -- latest stable release
|
||||||
|
lazypath,
|
||||||
})
|
})
|
||||||
load_plugins()
|
|
||||||
require('packer').sync()
|
|
||||||
vim.cmd('colorscheme aurora')
|
|
||||||
else
|
|
||||||
load_plugins()
|
|
||||||
vim.cmd('colorscheme aurora')
|
|
||||||
end
|
end
|
||||||
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
local function load_plugins()
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
'nvim-treesitter/nvim-treesitter',
|
||||||
|
config = function()
|
||||||
|
require('nvim-treesitter.configs').setup({
|
||||||
|
ensure_installed = { 'go' },
|
||||||
|
highlight = { enable = true },
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
build = ':TSUpdate',
|
||||||
|
},
|
||||||
|
{ 'neovim/nvim-lspconfig' },
|
||||||
|
-- {
|
||||||
|
-- 'simrat39/rust-tools.nvim',
|
||||||
|
-- config = function()
|
||||||
|
-- require('rust-tools').setup({
|
||||||
|
-- server = {
|
||||||
|
-- on_attach = function(client, bufnr)
|
||||||
|
-- require('navigator.lspclient.mapping').setup({ client = client, bufnr = bufnr }) -- setup navigator keymaps here,
|
||||||
|
-- -- otherwise, you can define your own commands to call navigator functions
|
||||||
|
-- end,
|
||||||
|
-- },
|
||||||
|
-- })
|
||||||
|
-- end,
|
||||||
|
-- },
|
||||||
|
{ 'ray-x/lsp_signature.nvim', dev = (plugin_folder() ~= '') },
|
||||||
|
{
|
||||||
|
'ray-x/navigator.lua',
|
||||||
|
dev = (plugin_folder() ~= ''),
|
||||||
|
-- '~/github/ray-x/navigator.lua',
|
||||||
|
dependencies = { 'ray-x/guihua.lua', build = 'cd lua/fzy && make' },
|
||||||
|
config = function()
|
||||||
|
require('navigator').setup({
|
||||||
|
keymaps = {
|
||||||
|
{
|
||||||
|
key = '<Leader>rn',
|
||||||
|
func = require('navigator.rename').rename,
|
||||||
|
desc = 'rename',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lsp = {
|
||||||
|
-- disable_lsp = { 'rust_analyzer', 'clangd' },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'hrsh7th/nvim-cmp',
|
||||||
|
dependencies = {
|
||||||
|
'neovim/nvim-lspconfig',
|
||||||
|
'hrsh7th/cmp-nvim-lsp',
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
-- Add additional capabilities supported by nvim-cmp
|
||||||
|
local cmp = require('cmp')
|
||||||
|
cmp.setup({
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
luasnip.lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
['<C-u>'] = cmp.mapping.scroll_docs(-4), -- Up
|
||||||
|
['<C-d>'] = cmp.mapping.scroll_docs(4), -- Down
|
||||||
|
-- C-b (back) C-f (forward) for snippet placeholder navigation.
|
||||||
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
|
['<CR>'] = cmp.mapping.confirm({
|
||||||
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
|
select = true,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
sources = {
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'ray-x/go.nvim',
|
||||||
|
dev = (plugin_folder() ~= ''),
|
||||||
|
-- dev = true,
|
||||||
|
ft = 'go',
|
||||||
|
dependencies = {
|
||||||
|
'mfussenegger/nvim-dap', -- Debug Adapter Protocol
|
||||||
|
'rcarriga/nvim-dap-ui',
|
||||||
|
'theHamsta/nvim-dap-virtual-text',
|
||||||
|
'ray-x/guihua.lua',
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
require('go').setup({
|
||||||
|
verbose = true,
|
||||||
|
lsp_cfg = {
|
||||||
|
handlers = {
|
||||||
|
['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { border = 'double' }),
|
||||||
|
['textDocument/signatureHelp'] = vim.lsp.with(
|
||||||
|
vim.lsp.handlers.signature_help,
|
||||||
|
{ border = 'round' }
|
||||||
|
),
|
||||||
|
},
|
||||||
|
}, -- false: do nothing
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local opts = {
|
||||||
|
root = package_root, -- directory where plugins will be installed
|
||||||
|
default = { lazy = true },
|
||||||
|
dev = {
|
||||||
|
-- directory where you store your local plugin projects
|
||||||
|
path = plugin_folder(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
require('lazy').setup(load_plugins(), opts)
|
||||||
|
|
||||||
|
vim.cmd('colorscheme murphy')
|
||||||
|
@ -0,0 +1,61 @@
|
|||||||
|
vim.cmd([[set runtimepath=$VIMRUNTIME]])
|
||||||
|
vim.cmd([[set packpath=/tmp/nvim/site]])
|
||||||
|
|
||||||
|
local package_root = '/tmp/nvim/site/pack'
|
||||||
|
local install_path = package_root .. '/packer/start/packer.nvim'
|
||||||
|
vim.g.coq_settings = {
|
||||||
|
['auto_start'] = 'shut-up',
|
||||||
|
}
|
||||||
|
|
||||||
|
local function load_plugins()
|
||||||
|
require('packer').startup({
|
||||||
|
function(use)
|
||||||
|
use('wbthomason/packer.nvim')
|
||||||
|
use('neovim/nvim-lspconfig')
|
||||||
|
use({
|
||||||
|
'williamboman/nvim-lsp-installer',
|
||||||
|
config = function()
|
||||||
|
local lsp_installer = require('nvim-lsp-installer')
|
||||||
|
lsp_installer.setup{}
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
use({
|
||||||
|
'ray-x/navigator.lua',
|
||||||
|
config = function()
|
||||||
|
require('navigator').setup({
|
||||||
|
debug = true,
|
||||||
|
lsp_installer = true,
|
||||||
|
keymaps = { { key = 'gR', func = "require('navigator.reference').async_ref()" } },
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
use('ray-x/guihua.lua')
|
||||||
|
-- -- COQ (Autocompletion)
|
||||||
|
use('ms-jpq/coq_nvim')
|
||||||
|
use('ms-jpq/coq.artifacts')
|
||||||
|
use('ms-jpq/coq.thirdparty')
|
||||||
|
use('ray-x/aurora')
|
||||||
|
end,
|
||||||
|
config = {
|
||||||
|
package_root = package_root,
|
||||||
|
compile_path = install_path .. '/plugin/packer_compiled.lua',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
-- navigator/LSP setup
|
||||||
|
end
|
||||||
|
|
||||||
|
if vim.fn.isdirectory(install_path) == 0 then
|
||||||
|
print('install packer')
|
||||||
|
vim.fn.system({
|
||||||
|
'git',
|
||||||
|
'clone',
|
||||||
|
'https://github.com/wbthomason/packer.nvim',
|
||||||
|
install_path,
|
||||||
|
})
|
||||||
|
load_plugins()
|
||||||
|
require('packer').sync()
|
||||||
|
vim.cmd('colorscheme aurora')
|
||||||
|
else
|
||||||
|
load_plugins()
|
||||||
|
vim.cmd('colorscheme aurora')
|
||||||
|
end
|
@ -0,0 +1,79 @@
|
|||||||
|
vim.cmd([[set runtimepath=$VIMRUNTIME]])
|
||||||
|
vim.cmd([[set packpath=/tmp/nvim/site]])
|
||||||
|
|
||||||
|
local package_root = '/tmp/nvim/site/pack'
|
||||||
|
local install_path = package_root .. '/packer/start/packer.nvim'
|
||||||
|
|
||||||
|
local function load_plugins()
|
||||||
|
require('packer').startup({
|
||||||
|
function(use)
|
||||||
|
use('wbthomason/packer.nvim')
|
||||||
|
use('neovim/nvim-lspconfig')
|
||||||
|
use({
|
||||||
|
'williamboman/nvim-lsp-installer',
|
||||||
|
config = function()
|
||||||
|
require('nvim-lsp-installer').setup({})
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
use({
|
||||||
|
'ray-x/navigator.lua',
|
||||||
|
-- '~/github/ray-x/navigator.lua',
|
||||||
|
config = function()
|
||||||
|
require('navigator').setup({
|
||||||
|
debug = true,
|
||||||
|
lsp_installer = true,
|
||||||
|
keymaps = { { key = 'gR', func = "require('navigator.reference').async_ref()" } },
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
use('ray-x/guihua.lua')
|
||||||
|
|
||||||
|
use({
|
||||||
|
'hrsh7th/nvim-cmp',
|
||||||
|
requires = {
|
||||||
|
'hrsh7th/cmp-nvim-lsp',
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
local cmp = require('cmp')
|
||||||
|
cmp.setup({
|
||||||
|
mapping = {
|
||||||
|
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||||
|
['<Tab>'] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.confirm({ select = true })
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end, { 'i', 's' }),
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
use('ray-x/aurora')
|
||||||
|
end,
|
||||||
|
config = {
|
||||||
|
package_root = package_root,
|
||||||
|
compile_path = install_path .. '/plugin/packer_compiled.lua',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
-- navigator/LSP setup
|
||||||
|
end
|
||||||
|
|
||||||
|
if vim.fn.isdirectory(install_path) == 0 then
|
||||||
|
print('install packer')
|
||||||
|
vim.fn.system({
|
||||||
|
'git',
|
||||||
|
'clone',
|
||||||
|
'https://github.com/wbthomason/packer.nvim',
|
||||||
|
install_path,
|
||||||
|
})
|
||||||
|
load_plugins()
|
||||||
|
require('packer').sync()
|
||||||
|
vim.cmd('colorscheme aurora')
|
||||||
|
else
|
||||||
|
load_plugins()
|
||||||
|
vim.cmd('colorscheme aurora')
|
||||||
|
end
|
@ -0,0 +1,14 @@
|
|||||||
|
from random import shuffle
|
||||||
|
a = list(range(5))
|
||||||
|
|
||||||
|
def go(beg, c, b):
|
||||||
|
if beg >= len(a):
|
||||||
|
print(a )
|
||||||
|
for i in range(beg, len(a)):
|
||||||
|
a[beg], a[i] = a[i], a[beg]
|
||||||
|
go(beg + 1)
|
||||||
|
a[beg], a[i] = a[i], a[beg]
|
||||||
|
print(a, b)
|
||||||
|
|
||||||
|
go(0, 1, 4)
|
||||||
|
shuffle([1, 2,3 ])
|
@ -0,0 +1,9 @@
|
|||||||
|
[package]
|
||||||
|
name = "hello"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Ray-X <rayx.cn@gmail.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
@ -0,0 +1,89 @@
|
|||||||
|
use std::io;
|
||||||
|
|
||||||
|
trait Show {
|
||||||
|
fn show(&self) -> String;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Show for i32 {
|
||||||
|
fn show(&self) -> String {
|
||||||
|
format!("four-byte signed {}", self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Show for f64 {
|
||||||
|
fn show(&self) -> String {
|
||||||
|
format!("eight-byte float {}", self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fn another_function(x: i32, y: i32) {
|
||||||
|
println!("The value of x is: {}, y {}", x, y);
|
||||||
|
}
|
||||||
|
fn fun1(x: i32, y: i32) {
|
||||||
|
println!("The value of x is: {}, y {}", x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<Iter> Iterator for Iter
|
||||||
|
where Iter: Iterator,
|
||||||
|
{
|
||||||
|
type Item = i32;
|
||||||
|
fn next(&mut self) -> Option<i32> {
|
||||||
|
Some(42)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn add(left: i32, right: i32) -> i32 {
|
||||||
|
return left + right;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add4(left: i32, right: i32, t: i32, f: i32) -> i32 {
|
||||||
|
return left + right + t + f;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Foo<'a> {
|
||||||
|
x: &'a i32,
|
||||||
|
}
|
||||||
|
struct Boo<'b> {
|
||||||
|
x: &'b i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
const CAMEL_CASE: i32 = 42;
|
||||||
|
|
||||||
|
fn bug(left: i32, rigth: i32) -> i32 {
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_signature(a: i32, b: i32, c: i32) -> i32 {
|
||||||
|
a + b - c
|
||||||
|
}
|
||||||
|
fn test(a: i32) {}
|
||||||
|
fn test2() {
|
||||||
|
test(1)
|
||||||
|
}
|
||||||
|
fn test3() {
|
||||||
|
test(1);
|
||||||
|
test2()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
test_signature(1, 2, 3);
|
||||||
|
let x = || 42;
|
||||||
|
bug(x(), 32);
|
||||||
|
bug(x(), 32);
|
||||||
|
|
||||||
|
add(add(1, 2), 3);
|
||||||
|
add(add(1, 2), 3);
|
||||||
|
let answer = 42;
|
||||||
|
let maybe_pi = 3.14;
|
||||||
|
let v: Vec<&Show> = vec![&answer, &maybe_pi];
|
||||||
|
for d in v.iter() {
|
||||||
|
println!("show {}", d.show());
|
||||||
|
}
|
||||||
|
add4(1, 2, 3, add(1, 2));
|
||||||
|
add4(add(1, 2), 3, add(3, 4), 4);
|
||||||
|
let y = &5; // this is the same as `let _y = 5; let y = &_y;`
|
||||||
|
let f = Foo { x: y };
|
||||||
|
let z = &5; // this is the same as `let _y = 5; let y = &_y;`
|
||||||
|
let f22 = Boo { x: z };
|
||||||
|
another_function(11, 2);
|
||||||
|
}
|
@ -1 +1,6 @@
|
|||||||
std="vim"
|
std="lua52+vim"
|
||||||
|
|
||||||
|
[rules]
|
||||||
|
global_usage = "allow"
|
||||||
|
multiple_statements = "allow"
|
||||||
|
unused_variable = "allow"
|
||||||
|
@ -0,0 +1,69 @@
|
|||||||
|
local busted = require('plenary/busted')
|
||||||
|
|
||||||
|
local eq = assert.are.same
|
||||||
|
local cur_dir = vim.fn.expand('%:p:h')
|
||||||
|
-- local status = require("plenary.reload").reload_module("go.nvim")
|
||||||
|
-- status = require("plenary.reload").reload_module("nvim-treesitter")
|
||||||
|
|
||||||
|
-- local ulog = require('go.utils').log
|
||||||
|
describe('should run lsp call hierarchy', function()
|
||||||
|
vim.cmd([[packadd navigator.lua]])
|
||||||
|
vim.cmd([[packadd guihua.lua]])
|
||||||
|
local status = require('plenary.reload').reload_module('navigator')
|
||||||
|
status = require('plenary.reload').reload_module('guihua')
|
||||||
|
status = require('plenary.reload').reload_module('lspconfig')
|
||||||
|
|
||||||
|
local path = cur_dir .. '/tests/fixtures/interface.go' -- %:p:h ? %:p
|
||||||
|
local cmd = " silent exe 'e " .. path .. "'"
|
||||||
|
vim.cmd(cmd)
|
||||||
|
vim.cmd([[cd %:p:h]])
|
||||||
|
local bufn = vim.fn.bufnr('')
|
||||||
|
require('navigator').setup({
|
||||||
|
debug = true, -- log output, set to true and log path: ~/.local/share/nvim/gh.log
|
||||||
|
width = 0.75, -- max width ratio (number of cols for the floating window) / (window width)
|
||||||
|
height = 0.3, -- max list window height, 0.3 by default
|
||||||
|
preview_height = 0.35, -- max height of preview windows
|
||||||
|
border = 'none',
|
||||||
|
})
|
||||||
|
|
||||||
|
-- allow gopls start
|
||||||
|
for _ = 1, 20 do
|
||||||
|
vim.wait(400, function() end)
|
||||||
|
local found = false
|
||||||
|
for _, client in ipairs(vim.lsp.get_clients()) do
|
||||||
|
if client.name == 'gopls' then
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if found then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it('should show panel', function()
|
||||||
|
vim.fn.setpos('.', { bufn, 24, 15, 0 })
|
||||||
|
require('navigator.hierarchy').incoming_calls_panel()
|
||||||
|
|
||||||
|
vim.wait(300, function() end)
|
||||||
|
|
||||||
|
local panel = require('guihua.panel').debug()
|
||||||
|
eq(panel.name, 'Panel')
|
||||||
|
|
||||||
|
vim.wait(500, function() end)
|
||||||
|
panel = require('guihua.panel').debug()
|
||||||
|
print(vim.inspect(panel))
|
||||||
|
-- eq(
|
||||||
|
-- panel.activePanel.sections[1].header[1],
|
||||||
|
-- '──────────Call Hierarchy──────────'
|
||||||
|
-- )
|
||||||
|
-- eq(panel.activePanel.sections[1].nodes[1].name, 'measure')
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('should not crash and show hierarchy', function()
|
||||||
|
vim.fn.setpos('.', { bufn, 24, 15, 0 })
|
||||||
|
local ret = require('navigator.hierarchy')._call_hierarchy()
|
||||||
|
vim.wait(400, function() end)
|
||||||
|
eq(ret, ret) -- make sure doesn't crash the result
|
||||||
|
end)
|
||||||
|
end)
|
@ -0,0 +1,217 @@
|
|||||||
|
local golden_result = {
|
||||||
|
{
|
||||||
|
col = 9,
|
||||||
|
display_filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
||||||
|
filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
||||||
|
full_text = 'package main',
|
||||||
|
kind = '🚀',
|
||||||
|
lnum = 1,
|
||||||
|
node_scope = {
|
||||||
|
['end'] = {
|
||||||
|
character = 0,
|
||||||
|
line = 12,
|
||||||
|
},
|
||||||
|
start = {
|
||||||
|
character = 0,
|
||||||
|
line = 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
node_text = 'main',
|
||||||
|
indent = '',
|
||||||
|
range = {
|
||||||
|
['end'] = {
|
||||||
|
character = 12,
|
||||||
|
line = 0,
|
||||||
|
},
|
||||||
|
start = {
|
||||||
|
character = 8,
|
||||||
|
line = 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
text = ' 🚀 main \t package main',
|
||||||
|
type = 'namespace',
|
||||||
|
uri = 'file:///tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
col = 6,
|
||||||
|
display_filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
||||||
|
filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
||||||
|
full_text = 'func interfaceTest()',
|
||||||
|
kind = ' ',
|
||||||
|
lnum = 5,
|
||||||
|
indent = '',
|
||||||
|
node_scope = {
|
||||||
|
['end'] = {
|
||||||
|
character = 1,
|
||||||
|
line = 11,
|
||||||
|
},
|
||||||
|
start = {
|
||||||
|
character = 0,
|
||||||
|
line = 4,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
node_text = 'interfaceTest',
|
||||||
|
range = {
|
||||||
|
['end'] = {
|
||||||
|
character = 18,
|
||||||
|
line = 4,
|
||||||
|
},
|
||||||
|
start = {
|
||||||
|
character = 5,
|
||||||
|
line = 4,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
text = ' interfaceTest\t func interfaceTest()',
|
||||||
|
type = 'function',
|
||||||
|
uri = 'file:///tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
col = 2,
|
||||||
|
display_filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
||||||
|
filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
||||||
|
full_text = 'r := rect{width: 3, height: 4}',
|
||||||
|
kind = ' ',
|
||||||
|
lnum = 6,
|
||||||
|
node_scope = {
|
||||||
|
['end'] = {
|
||||||
|
character = 1,
|
||||||
|
line = 11,
|
||||||
|
},
|
||||||
|
start = {
|
||||||
|
character = 21,
|
||||||
|
line = 4,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
indent = ' ',
|
||||||
|
node_text = 'r',
|
||||||
|
range = {
|
||||||
|
['end'] = {
|
||||||
|
character = 2,
|
||||||
|
line = 5,
|
||||||
|
},
|
||||||
|
start = {
|
||||||
|
character = 1,
|
||||||
|
line = 5,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
text = ' r \t r := rect{width: 3, height: 4}',
|
||||||
|
type = 'var',
|
||||||
|
uri = 'file:///tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
col = 2,
|
||||||
|
display_filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
||||||
|
filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
||||||
|
full_text = 'c := circle{radius: 5}',
|
||||||
|
kind = ' ',
|
||||||
|
lnum = 7,
|
||||||
|
node_scope = {
|
||||||
|
['end'] = {
|
||||||
|
character = 1,
|
||||||
|
line = 11,
|
||||||
|
},
|
||||||
|
start = {
|
||||||
|
character = 21,
|
||||||
|
line = 4,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
node_text = 'c',
|
||||||
|
indent = ' ',
|
||||||
|
range = {
|
||||||
|
['end'] = {
|
||||||
|
character = 2,
|
||||||
|
line = 6,
|
||||||
|
},
|
||||||
|
start = {
|
||||||
|
character = 1,
|
||||||
|
line = 6,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
text = ' c \t c := circle{radius: 5}',
|
||||||
|
type = 'var',
|
||||||
|
uri = 'file:///tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
col = 2,
|
||||||
|
display_filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
||||||
|
filename = '/tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
||||||
|
full_text = 'd := circle{radius: 10}',
|
||||||
|
kind = ' ',
|
||||||
|
lnum = 10,
|
||||||
|
indent = ' ',
|
||||||
|
node_scope = {
|
||||||
|
['end'] = {
|
||||||
|
character = 1,
|
||||||
|
line = 11,
|
||||||
|
},
|
||||||
|
start = {
|
||||||
|
character = 21,
|
||||||
|
line = 4,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
node_text = 'd',
|
||||||
|
range = {
|
||||||
|
['end'] = {
|
||||||
|
character = 2,
|
||||||
|
line = 9,
|
||||||
|
},
|
||||||
|
start = {
|
||||||
|
character = 1,
|
||||||
|
line = 9,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
text = ' d \t d := circle{radius: 10}',
|
||||||
|
type = 'var',
|
||||||
|
uri = 'file:///tmp/github/ray-x/navigator.lua/tests/fixtures/interface_test.go',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
print(golden_result[1].node_text)
|
||||||
|
|
||||||
|
local busted = require('plenary/busted')
|
||||||
|
|
||||||
|
local eq = assert.are.same
|
||||||
|
local cur_dir = vim.fn.expand('%:p:h')
|
||||||
|
-- local status = require("plenary.reload").reload_module("go.nvim")
|
||||||
|
-- status = require("plenary.reload").reload_module("nvim-treesitter")
|
||||||
|
|
||||||
|
-- local ulog = require('go.utils').log
|
||||||
|
describe('should run lsp reference', function()
|
||||||
|
-- vim.fn.readfile('minimal.vim')
|
||||||
|
it('should show ts nodes', function()
|
||||||
|
local status = require('plenary.reload').reload_module('navigator')
|
||||||
|
local status = require('plenary.reload').reload_module('guihua')
|
||||||
|
local status = require('plenary.reload').reload_module('lspconfig')
|
||||||
|
|
||||||
|
vim.cmd([[packadd nvim-lspconfig]])
|
||||||
|
vim.cmd([[packadd navigator.lua]])
|
||||||
|
vim.cmd([[packadd guihua.lua]])
|
||||||
|
local path = cur_dir .. '/tests/fixtures/interface_test.go' -- %:p:h ? %:p
|
||||||
|
local cmd = " silent exe 'e " .. path .. "'"
|
||||||
|
vim.cmd(cmd)
|
||||||
|
vim.cmd([[cd %:p:h]])
|
||||||
|
local bufn = vim.fn.bufnr('')
|
||||||
|
-- require'lspconfig'.gopls.setup {}
|
||||||
|
require('navigator').setup({
|
||||||
|
debug = true, -- log output, set to true and log path: ~/.local/share/nvim/gh.log
|
||||||
|
})
|
||||||
|
|
||||||
|
-- allow gopls start
|
||||||
|
for i = 1, 10 do
|
||||||
|
vim.wait(400, function() end)
|
||||||
|
local clients = vim.lsp.get_clients()
|
||||||
|
print('lsp clients: ', #clients)
|
||||||
|
if #clients > 0 then
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.fn.setpos('.', { bufn, 15, 4, 0 }) -- width
|
||||||
|
|
||||||
|
vim.bo.filetype = 'go'
|
||||||
|
local view, items, w = require('navigator.treesitter').buf_ts()
|
||||||
|
eq(items[1].node_text, golden_result[1].node_text)
|
||||||
|
eq(items[2].node_text, golden_result[2].node_text)
|
||||||
|
end)
|
||||||
|
end)
|
@ -0,0 +1,47 @@
|
|||||||
|
---
|
||||||
|
base: lua52
|
||||||
|
name: vim
|
||||||
|
globals:
|
||||||
|
_G:
|
||||||
|
property: new-fields
|
||||||
|
_NgConfigValues:
|
||||||
|
any: true
|
||||||
|
after_each:
|
||||||
|
args:
|
||||||
|
- type: function
|
||||||
|
assert.equals:
|
||||||
|
args:
|
||||||
|
- type: any
|
||||||
|
- type: any
|
||||||
|
- required: false
|
||||||
|
type: any
|
||||||
|
assert.is_not:
|
||||||
|
any: true
|
||||||
|
assert.same:
|
||||||
|
args:
|
||||||
|
- type: any
|
||||||
|
- type: any
|
||||||
|
assert.spy:
|
||||||
|
args:
|
||||||
|
- type: any
|
||||||
|
assert.stub:
|
||||||
|
args:
|
||||||
|
- type: any
|
||||||
|
assert.truthy:
|
||||||
|
args:
|
||||||
|
- type: any
|
||||||
|
before_each:
|
||||||
|
args:
|
||||||
|
- type: function
|
||||||
|
debug:
|
||||||
|
property: read-only
|
||||||
|
describe:
|
||||||
|
args:
|
||||||
|
- type: string
|
||||||
|
- type: function
|
||||||
|
it:
|
||||||
|
args:
|
||||||
|
- type: string
|
||||||
|
- type: function
|
||||||
|
vim:
|
||||||
|
any: true
|
Loading…
Reference in New Issue