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.
1 " Author: w0rp <devw0rp@gmail.com>
2 " Description: tsserver message implementations
4 " Messages in this movie will be returned in the format
5 " [is_notification, command_name, params?]
7 " Every command must begin with the string 'ts@', which will be used to
8 " detect the different message format for tsserver, and this string will
9 " be removed from the actual command name,
11 function! ale#lsp#tsserver_message#Open(buffer) abort
12 return [1, 'ts@open', {'file': expand('#' . a:buffer . ':p')}]
15 function! ale#lsp#tsserver_message#Close(buffer) abort
16 return [1, 'ts@close', {'file': expand('#' . a:buffer . ':p')}]
19 function! ale#lsp#tsserver_message#Change(buffer) abort
20 let l:lines = getbufline(a:buffer, 1, '$')
22 " We will always use a very high endLine number, so we can delete
23 " lines from files. tsserver will gladly accept line numbers beyond the
25 return [1, 'ts@change', {
26 \ 'file': expand('#' . a:buffer . ':p'),
29 \ 'endLine': 1073741824,
31 \ 'insertString': join(l:lines, "\n") . "\n",
35 function! ale#lsp#tsserver_message#Geterr(buffer) abort
36 return [1, 'ts@geterr', {'files': [expand('#' . a:buffer . ':p')]}]
39 function! ale#lsp#tsserver_message#Completions(
40 \ buffer, line, column, prefix, include_external) abort
41 return [0, 'ts@completions', {
44 \ 'file': expand('#' . a:buffer . ':p'),
46 \ 'includeExternalModuleExports': a:include_external,
50 function! ale#lsp#tsserver_message#CompletionEntryDetails(buffer, line, column, entry_names) abort
51 return [0, 'ts@completionEntryDetails', {
54 \ 'file': expand('#' . a:buffer . ':p'),
55 \ 'entryNames': a:entry_names,
59 function! ale#lsp#tsserver_message#Definition(buffer, line, column) abort
60 return [0, 'ts@definition', {
63 \ 'file': expand('#' . a:buffer . ':p'),
67 function! ale#lsp#tsserver_message#TypeDefinition(buffer, line, column) abort
68 return [0, 'ts@typeDefinition', {
71 \ 'file': expand('#' . a:buffer . ':p'),
75 function! ale#lsp#tsserver_message#Implementation(buffer, line, column) abort
76 return [0, 'ts@implementation', {
79 \ 'file': expand('#' . a:buffer . ':p'),
83 function! ale#lsp#tsserver_message#References(buffer, line, column) abort
84 return [0, 'ts@references', {
87 \ 'file': expand('#' . a:buffer . ':p'),
91 function! ale#lsp#tsserver_message#Quickinfo(buffer, line, column) abort
92 return [0, 'ts@quickinfo', {
95 \ 'file': expand('#' . a:buffer . ':p'),
99 function! ale#lsp#tsserver_message#Rename(
100 \ buffer, line, column, find_in_comments, find_in_strings) abort
101 return [0, 'ts@rename', {
103 \ 'offset': a:column,
104 \ 'file': expand('#' . a:buffer . ':p'),
106 \ 'findInComments': a:find_in_comments,
107 \ 'findInStrings': a:find_in_strings,
112 function! ale#lsp#tsserver_message#GetEditsForFileRename(
113 \ oldFilePath, newFilePath) abort
114 return [0, 'ts@getEditsForFileRename', {
115 \ 'oldFilePath': a:oldFilePath,
116 \ 'newFilePath': a:newFilePath,
120 function! ale#lsp#tsserver_message#OrganizeImports(buffer) abort
121 return [0, 'ts@organizeImports', {
125 \ 'file': expand('#' . a:buffer . ':p'),
131 function! ale#lsp#tsserver_message#GetCodeFixes(buffer, line, column, end_line, end_column, error_codes) abort
132 " The lines and columns are 1-based.
133 " The errors codes must be a list of tsserver error codes to fix.
134 return [0, 'ts@getCodeFixes', {
135 \ 'startLine': a:line,
136 \ 'startOffset': a:column,
137 \ 'endLine': a:end_line,
138 \ 'endOffset': a:end_column + 1,
139 \ 'file': expand('#' . a:buffer . ':p'),
140 \ 'errorCodes': a:error_codes,
144 function! ale#lsp#tsserver_message#GetApplicableRefactors(buffer, line, column, end_line, end_column) abort
145 " The arguments for this request can also be just 'line' and 'offset'
146 return [0, 'ts@getApplicableRefactors', {
147 \ 'startLine': a:line,
148 \ 'startOffset': a:column,
149 \ 'endLine': a:end_line,
150 \ 'endOffset': a:end_column + 1,
151 \ 'file': expand('#' . a:buffer . ':p'),
155 function! ale#lsp#tsserver_message#GetEditsForRefactor(buffer, line, column, end_line, end_column, refactor, action) abort
156 return [0, 'ts@getEditsForRefactor', {
157 \ 'startLine': a:line,
158 \ 'startOffset': a:column,
159 \ 'endLine': a:end_line,
160 \ 'endOffset': a:end_column + 1,
161 \ 'file': expand('#' . a:buffer . ':p'),
162 \ 'refactor': a:refactor,
163 \ 'action': a:action,