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 let s:default_symbol_kinds = {
23 \ '22': 'enum member',
27 \ '26': 'type parameter',
30 let s:symbol_kinds = {}
32 let s:diagnostic_severity = {
39 function! s:symbols_to_loc_list_children(server, path, list, symbols, depth) abort
40 for l:symbol in a:symbols
41 let [l:line, l:col] = lsp#utils#position#lsp_to_vim(a:path, l:symbol['range']['start'])
47 \ 'text': lsp#ui#vim#utils#_get_symbol_text_from_kind(a:server, l:symbol['kind']) . ' : ' . printf('%' . a:depth. 's', ' ') . l:symbol['name'],
49 if has_key(l:symbol, 'children') && !empty(l:symbol['children'])
50 call s:symbols_to_loc_list_children(a:server, a:path, a:list, l:symbol['children'], a:depth + 1)
55 function! lsp#ui#vim#utils#symbols_to_loc_list(server, result) abort
56 if !has_key(a:result['response'], 'result')
62 let l:locations = type(a:result['response']['result']) == type({}) ? [a:result['response']['result']] : a:result['response']['result']
64 if !empty(l:locations) " some servers also return null so check to make sure it isn't empty
65 for l:symbol in a:result['response']['result']
66 if has_key(l:symbol, 'location')
67 let l:location = l:symbol['location']
68 if lsp#utils#is_file_uri(l:location['uri'])
69 let l:path = lsp#utils#uri_to_path(l:location['uri'])
70 let [l:line, l:col] = lsp#utils#position#lsp_to_vim(l:path, l:location['range']['start'])
75 \ 'text': lsp#ui#vim#utils#_get_symbol_text_from_kind(a:server, l:symbol['kind']) . ' : ' . (g:lsp_document_symbol_detail ? l:symbol['detail'] : l:symbol['name']),
79 let l:location = a:result['request']['params']['textDocument']['uri']
80 if lsp#utils#is_file_uri(l:location)
81 let l:path = lsp#utils#uri_to_path(l:location)
82 let [l:line, l:col] = lsp#utils#position#lsp_to_vim(l:path, l:symbol['range']['start'])
87 \ 'text': lsp#ui#vim#utils#_get_symbol_text_from_kind(a:server, l:symbol['kind']) . ' : ' . (g:lsp_document_symbol_detail ? l:symbol['detail'] : l:symbol['name']),
89 if has_key(l:symbol, 'children') && !empty(l:symbol['children'])
90 call s:symbols_to_loc_list_children(a:server, l:path, l:list, l:symbol['children'], 1)
100 function! lsp#ui#vim#utils#diagnostics_to_loc_list(result) abort
101 if !has_key(a:result['response'], 'params')
105 let l:uri = a:result['response']['params']['uri']
106 let l:diagnostics = lsp#utils#iteratable(a:result['response']['params']['diagnostics'])
110 if !empty(l:diagnostics) && lsp#utils#is_file_uri(l:uri)
111 let l:path = lsp#utils#uri_to_path(l:uri)
112 for l:item in l:diagnostics
113 let l:severity_text = ''
114 if has_key(l:item, 'severity') && !empty(l:item['severity'])
115 let l:severity_text = s:get_diagnostic_severity_text(l:item['severity'])
118 if has_key(l:item, 'source') && !empty(l:item['source'])
119 let l:text .= l:item['source'] . ':'
121 if l:severity_text !=# ''
122 let l:text .= l:severity_text . ':'
124 if has_key(l:item, 'code') && !empty(l:item['code'])
125 let l:text .= l:item['code'] . ':'
127 let l:text .= l:item['message']
128 let [l:line, l:col] = lsp#utils#position#lsp_to_vim(l:path, l:item['range']['start'])
129 let l:location_item = {
130 \ 'filename': l:path,
135 if l:severity_text !=# ''
136 " 'E' for error, 'W' for warning, 'I' for information, 'H' for hint
137 let l:location_item['type'] = l:severity_text[0]
139 call add(l:list, l:location_item)
146 function! lsp#ui#vim#utils#_get_symbol_text_from_kind(server, kind) abort
147 if !has_key(s:symbol_kinds, a:server)
148 let l:server_info = lsp#get_server_info(a:server)
149 if has_key (l:server_info, 'config') && has_key(l:server_info['config'], 'symbol_kinds')
150 let s:symbol_kinds[a:server] = extend(copy(s:default_symbol_kinds), l:server_info['config']['symbol_kinds'])
152 let s:symbol_kinds[a:server] = s:default_symbol_kinds
155 return get(s:symbol_kinds[a:server], a:kind, 'unknown symbol ' . a:kind)
158 function! lsp#ui#vim#utils#get_symbol_kinds() abort
159 return map(keys(s:default_symbol_kinds), {idx, key -> str2nr(key)})
162 function! s:get_diagnostic_severity_text(severity) abort
163 return s:diagnostic_severity[a:severity]
166 function! lsp#ui#vim#utils#setqflist(list, type) abort
167 if has('patch-8.2.2147')
168 call setqflist(a:list)
169 call setqflist([], 'a', {'title': a:type})
172 call setqflist(a:list)