All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
2 call ale#test#SetDirectory('/testplugin/test')
3 call ale#test#SetFilename('dummy.txt')
7 let g:message_list = []
8 let g:preview_called = 0
11 let g:capability_checked = ''
12 let g:conn_id = v:null
13 let g:InitCallback = v:null
15 runtime autoload/ale/lsp_linter.vim
16 runtime autoload/ale/lsp.vim
17 runtime autoload/ale/util.vim
18 runtime autoload/ale/preview.vim
20 function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
21 let g:conn_id = ale#lsp#Register('executable', '/foo/bar', '', {})
22 call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer)
25 \ 'connection_id': g:conn_id,
26 \ 'project_root': '/foo/bar',
27 \ 'language_id': 'python',
30 let g:InitCallback = {-> a:Callback(a:linter, l:details)}
33 function! ale#lsp#HasCapability(conn_id, capability) abort
34 let g:capability_checked = a:capability
39 function! ale#lsp#RegisterCallback(conn_id, callback) abort
40 let g:Callback = a:callback
43 function! ale#lsp#Send(conn_id, message) abort
44 call add(g:message_list, a:message)
49 function! ale#util#Execute(expr) abort
50 call add(g:expr_list, a:expr)
53 function! ale#preview#ShowSelection(item_list, options) abort
54 let g:preview_called = 1
55 let g:item_list = a:item_list
56 let g:options = a:options
60 call ale#test#RestoreDirectory()
61 call ale#linter#Reset()
63 unlet! g:capability_checked
72 unlet! g:preview_called
74 runtime autoload/ale/lsp_linter.vim
75 runtime autoload/ale/lsp.vim
76 runtime autoload/ale/util.vim
77 runtime autoload/ale/preview.vim
79 Execute(Other messages for the LSP handler should be ignored):
80 call ale#symbol#HandleLSPResponse(1, {'command': 'foo'})
82 Execute(Failed symbol responses should be handled correctly):
83 call ale#symbol#SetMap({3: {}})
84 call ale#symbol#HandleLSPResponse(1, {'id': 3})
85 AssertEqual {}, ale#symbol#GetMap()
87 Execute(LSP symbol responses should be handled):
88 call ale#symbol#SetMap({3: {}})
89 call ale#symbol#HandleLSPResponse(
97 \ 'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/completion_dummy_file')),
99 \ 'start': {'line': 2, 'character': 7},
106 \ 'uri': ale#path#ToFileURI(ale#path#Simplify(g:dir . '/other_file')),
108 \ 'start': {'line': 7, 'character': 15},
119 \ 'filename': ale#path#Simplify(g:dir . '/completion_dummy_file'),
125 \ 'filename': ale#path#Simplify(g:dir . '/other_file'),
132 AssertEqual {}, ale#symbol#GetMap()
134 Execute(Preview windows should not be opened for empty LSP symbol responses):
135 call ale#symbol#SetMap({3: {}})
136 call ale#symbol#HandleLSPResponse(
145 Assert !g:preview_called
146 AssertEqual {}, ale#symbol#GetMap()
147 AssertEqual ['echom ''No symbols found.'''], g:expr_list
149 Given python(Some Python file):
154 Execute(LSP symbol requests should be sent):
155 runtime ale_linters/python/pylsp.vim
156 let b:ale_linters = ['pylsp']
157 call setpos('.', [bufnr(''), 1, 5, 0])
159 ALESymbolSearch foo bar
161 " We shouldn't register the callback yet.
162 AssertEqual '''''', string(g:Callback)
164 AssertEqual type(function('type')), type(g:InitCallback)
165 call g:InitCallback()
167 AssertEqual 'symbol_search', g:capability_checked
169 \ 'function(''ale#symbol#HandleLSPResponse'')',
174 \ [0, 'workspace/symbol', {'query': 'foo bar'}],
178 AssertEqual {'42': {'buffer': bufnr(''), 'use_relative_paths': 0}}, ale#symbol#GetMap()
180 Execute('-relative' argument should enable 'use_relative_paths' in HandleLSPResponse):
181 runtime ale_linters/python/pylsp.vim
182 let b:ale_linters = ['pylsp']
183 call setpos('.', [bufnr(''), 1, 5, 0])
185 ALESymbolSearch -relative foo bar
187 call g:InitCallback()
189 AssertEqual {'42': {'buffer': bufnr(''), 'use_relative_paths': 1}}, ale#symbol#GetMap()