@@ -12,25 +12,33 @@ function! spacevim#lang#util#InferExecutable() abort
12
12
return executable (l: exe ) ? l: exe : ' '
13
13
endfunction
14
14
15
+ " coc or LCN
16
+ function ! s: dispatch (... ) abort
17
+ if a: 0 == 2
18
+ let cmd = s: coc ?
19
+ \ printf (' call CocAction("%s")' , a: 1 ) :
20
+ \ printf (' call LanguageClient#%s()' , a: 2 )
21
+ execute cmd
22
+ endif
23
+ endfunction
24
+
15
25
" ================================================
16
26
" LSP
17
27
" ================================================
18
28
function ! spacevim#lang#util#FindReferences () abort
19
- if s: coc
20
- call CocAction (' jumpReferences' )
21
- return
22
- endif
23
-
24
- call LanguageClient#textDocument_references ()
29
+ call s: dispatch (' jumpReferences' , ' textDocument_references' )
25
30
endfunction
26
31
27
32
function ! spacevim#lang#util#Rename () abort
28
- if s: coc
29
- call CocAction (' rename' )
30
- return
31
- endif
33
+ call s: dispatch (' rename' , ' textDocument_rename' )
34
+ endfunction
35
+
36
+ function ! spacevim#lang#util#DocumentSymbol () abort
37
+ call s: dispatch (' documentSymbols' , ' textDocument_documentSymbol' )
38
+ endfunction
32
39
33
- call LanguageClient#textDocument_rename ()
40
+ function ! spacevim#lang#util#WorkspaceSymbol () abort
41
+ call s: dispatch (' workspaceSymbols' , ' workspace_symbol' )
34
42
endfunction
35
43
36
44
function ! spacevim#lang#util#Format () abort
@@ -45,20 +53,6 @@ function! spacevim#lang#util#Format() abort
45
53
endif
46
54
endfunction
47
55
48
- function ! spacevim#lang#util#DocumentSymbol () abort
49
- if s: coc
50
- call CocAction (' documentSymbols' )
51
- endif
52
- call LanguageClient#textDocument_documentSymbol ()
53
- endfunction
54
-
55
- function ! spacevim#lang#util#WorkspaceSymbol () abort
56
- if s: coc
57
- call CocAction (' workspaceSymbols' )
58
- endif
59
- call LanguageClient#workspace_symbol ()
60
- endfunction
61
-
62
56
function ! spacevim#lang#util#CodeAction () abort
63
57
if s: coc
64
58
call CocAction (' codeAction' , ' ' )
@@ -110,15 +104,9 @@ function! spacevim#lang#util#Definition() abort
110
104
endfunction
111
105
112
106
function ! spacevim#lang#util#TypeDefinition () abort
113
- if s: coc
114
- call CocAction (' jumpTypeDefinition' )
115
- return
116
- endif
107
+ call s: dispatch (' jumpTypeDefinition' , ' textDocument_typeDefinition' )
117
108
endfunction
118
109
119
110
function ! spacevim#lang#util#Implementation () abort
120
- if s: coc
121
- call CocAction (' jumpImplementation' )
122
- return
123
- endif
111
+ call s: dispatch (' jumpImplementation' , ' textDocument_implementation' )
124
112
endfunction
0 commit comments