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')
5 let g:old_filename = expand('%:p')
8 let g:message_list = []
9 let g:handle_code_action_called = 0
10 let g:code_actions = []
12 let g:capability_checked = ''
13 let g:conn_id = v:null
14 let g:InitCallback = v:null
16 runtime autoload/ale/lsp_linter.vim
17 runtime autoload/ale/lsp.vim
18 runtime autoload/ale/util.vim
19 runtime autoload/ale/organize_imports.vim
20 runtime autoload/ale/code_action.vim
22 function! ale#lsp_linter#StartLSP(buffer, linter, Callback) abort
23 let g:conn_id = ale#lsp#Register('executable', '/foo/bar', '', {})
24 call ale#lsp#MarkDocumentAsOpen(g:conn_id, a:buffer)
26 if a:linter.lsp is# 'tsserver'
27 call ale#lsp#MarkConnectionAsTsserver(g:conn_id)
31 \ 'command': 'foobar',
33 \ 'connection_id': g:conn_id,
34 \ 'project_root': '/foo/bar',
37 let g:InitCallback = {-> ale#lsp_linter#OnInit(a:linter, l:details, a:Callback)}
40 function! ale#lsp#HasCapability(conn_id, capability) abort
41 let g:capability_checked = a:capability
46 function! ale#lsp#RegisterCallback(conn_id, callback) abort
47 let g:Callback = a:callback
50 function! ale#lsp#Send(conn_id, message) abort
51 call add(g:message_list, a:message)
56 function! ale#util#Execute(expr) abort
57 call add(g:expr_list, a:expr)
60 function! ale#code_action#HandleCodeAction(code_action, options) abort
61 let g:handle_code_action_called = 1
62 AssertEqual g:ale_save_hidden || !&hidden, get(a:options, 'should_save')
63 call add(g:code_actions, a:code_action)
67 if g:conn_id isnot v:null
68 call ale#lsp#RemoveConnectionWithID(g:conn_id)
71 call ale#references#SetMap({})
72 call ale#test#RestoreDirectory()
73 call ale#linter#Reset()
75 unlet! g:capability_checked
85 unlet! g:handle_code_action_called
87 runtime autoload/ale/lsp_linter.vim
88 runtime autoload/ale/lsp.vim
89 runtime autoload/ale/util.vim
90 runtime autoload/ale/organize_imports.vim
91 runtime autoload/ale/code_action.vim
93 Execute(Other messages for the tsserver handler should be ignored):
94 call ale#organize_imports#HandleTSServerResponse(1, {'command': 'foo'})
95 AssertEqual g:handle_code_action_called, 0
97 Execute(Failed organizeImports responses should be handled correctly):
98 call ale#organize_imports#HandleTSServerResponse(
100 \ {'command': 'organizeImports', 'request_seq': 3}
102 AssertEqual g:handle_code_action_called, 0
104 Execute(Code actions from tsserver should be handled):
105 call ale#organize_imports#HandleTSServerResponse(1, {
106 \ 'command': 'organizeImports',
111 AssertEqual g:handle_code_action_called, 1
113 \ 'description': 'Organize Imports',
117 Given typescript(Some typescript file):
122 Execute(tsserver organize imports requests should be sent):
123 call ale#linter#Reset()
124 runtime ale_linters/typescript/tsserver.vim
128 " We shouldn't register the callback yet.
129 AssertEqual '''''', string(g:Callback)
131 AssertEqual type(function('type')), type(g:InitCallback)
132 call g:InitCallback()
135 \ 'function(''ale#organize_imports#HandleTSServerResponse'')',
140 \ ale#lsp#tsserver_message#Change(bufnr('')),
141 \ [0, 'ts@organizeImports', {
145 \ 'file': expand('%:p'),
152 Given python(Some Python file):
157 Execute(Should result in error message for LSP):
158 call ale#linter#Reset()
159 runtime ale_linters/python/pylsp.vim
160 let b:ale_linters = ['pylsp']
164 " We shouldn't register the callback yet.
165 AssertEqual '''''', string(g:Callback)
167 AssertEqual type(function('type')), type(g:InitCallback)
168 call g:InitCallback()
171 \ 'echom ''OrganizeImports currently only works with tsserver''',