Skip to content

Commit 515964f

Browse files
Merge branch 'master' into refactor-diagnostics-state
2 parents a622a0b + 04428c9 commit 515964f

File tree

14 files changed

+154
-49
lines changed

14 files changed

+154
-49
lines changed

.github/workflows/mac_neovim.yml

-8
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,11 @@ jobs:
5151
repository: thinca/vim-themis
5252
path: ./vim-themis
5353
ref: v1.5.5
54-
- name: Cache gopls
55-
id: cache-gopls
56-
uses: actions/cache@v4
57-
with:
58-
path: bin/gopls
59-
key: ${{ runner.os }}-${{ env.VIM_LSP_GO_VERSION }}-${{ env.VIM_LSP_GOPLS_VERSION }}-${{ env.VIM_LSP_GOPLS_CACHE_VER }}-gopls
6054
- name: Install Go for gopls
61-
if: steps.cache-gopls.outputs.cache-hit != 'true'
6255
uses: actions/setup-go@v5
6356
with:
6457
go-version: ${{ env.VIM_LSP_GO_VERSION }}
6558
- name: Install gopls
66-
if: steps.cache-gopls.outputs.cache-hit != 'true'
6759
shell: bash
6860
run: |
6961
go install golang.org/x/tools/gopls@v${{ env.VIM_LSP_GOPLS_VERSION }}

.github/workflows/mac_vim.yml

-8
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,11 @@ jobs:
2727
repository: thinca/vim-themis
2828
path: ./vim-themis
2929
ref: v1.5.5
30-
- name: Cache gopls
31-
id: cache-gopls
32-
uses: actions/cache@v4
33-
with:
34-
path: bin/gopls
35-
key: ${{ runner.os }}-${{ env.VIM_LSP_GO_VERSION }}-${{ env.VIM_LSP_GOPLS_VERSION }}-${{ env.VIM_LSP_GOPLS_CACHE_VER }}-gopls
3630
- name: Install Go for gopls
37-
if: steps.cache-gopls.outputs.cache-hit != 'true'
3831
uses: actions/setup-go@v5
3932
with:
4033
go-version: ${{ env.VIM_LSP_GO_VERSION }}
4134
- name: Install gopls
42-
if: steps.cache-gopls.outputs.cache-hit != 'true'
4335
shell: bash
4436
run: |
4537
go install golang.org/x/tools/gopls@v${{ env.VIM_LSP_GOPLS_VERSION }}

autoload/health/lsp.vim

+31-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ endf
88

99

1010
function! health#lsp#check() abort
11-
call health#report_start('server status')
11+
call s:report_start('server status')
1212
let l:server_status = lsp#collect_server_status()
1313

1414
let l:has_printed = v:false
@@ -17,21 +17,21 @@ function! health#lsp#check() abort
1717

1818
let l:status_msg = printf('%s: %s', l:k, l:report.status)
1919
if l:report.status == 'running'
20-
call health#report_ok(l:status_msg)
20+
call s:report_ok(l:status_msg)
2121
elseif l:report.status == 'failed'
2222
call health#report_error(l:status_msg, 'See :help g:lsp_log_verbose to debug server failure.')
2323
else
24-
call health#report_warn(l:status_msg)
24+
call s:report_warn(l:status_msg)
2525
endif
2626
let l:has_printed = v:true
2727
endfor
2828

2929
if !l:has_printed
30-
call health#report_warn('no servers connected')
30+
call s:report_warn('no servers connected')
3131
endif
3232

3333
for l:k in sort(keys(l:server_status))
34-
call health#report_start(printf('server configuration: %s', l:k))
34+
call s:report_start(printf('server configuration: %s', l:k))
3535
let l:report = l:server_status[l:k]
3636

3737
let l:msg = "\t\n"
@@ -54,12 +54,35 @@ function! health#lsp#check() abort
5454
call health#report_info(l:msg)
5555
endfor
5656

57-
call health#report_start('Performance')
57+
call s:report_start('Performance')
5858
if lsp#utils#has_lua() && g:lsp_use_lua
59-
call health#report_ok('Using lua for faster performance.')
59+
call s:report_ok('Using lua for faster performance.')
6060
else
61-
call health#report_warn('Missing requirements to enable lua for faster performance.')
61+
call s:report_warn('Missing requirements to enable lua for faster performance.')
6262
endif
6363

6464
endf
6565

66+
function! s:report_start(report) abort
67+
if has('nvim-0.10')
68+
call v:lua.vim.health.start(a:report)
69+
else
70+
call health#report_start(a:report)
71+
endif
72+
endf
73+
74+
function! s:report_warn(report) abort
75+
if has('nvim-0.10')
76+
call v:lua.vim.health.warn(a:report)
77+
else
78+
call health#report_warn(a:report)
79+
endif
80+
endf
81+
82+
function! s:report_ok(report) abort
83+
if has('nvim-0.10')
84+
call v:lua.vim.health.ok(a:report)
85+
else
86+
call health#report_ok(a:report)
87+
endif
88+
endf

autoload/lsp.vim

+1-1
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ function! s:text_changes(buf, server_name) abort
750750
endif
751751

752752
" When syncKind is Incremental and previous content is saved.
753-
if l:sync_kind == 2 && has_key(s:file_content, a:buf)
753+
if l:sync_kind == 2 && has_key(s:file_content, a:buf) && has_key(s:file_content[a:buf], a:server_name)
754754
" compute diff
755755
let l:old_content = s:get_last_file_content(a:buf, a:server_name)
756756
let l:new_content = lsp#utils#buffer#_get_lines(a:buf)

autoload/lsp/capabilities.vim

+4
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ function! lsp#capabilities#get_code_action_kinds(server_name) abort
189189
return []
190190
endfunction
191191

192+
function! lsp#capabilities#has_completion_provider(server_name) abort
193+
return s:has_provider(a:server_name, 'completionProvider')
194+
endfunction
195+
192196
function! lsp#capabilities#has_completion_resolve_provider(server_name) abort
193197
return s:has_provider(a:server_name, 'completionProvider', 'resolveProvider')
194198
endfunction

autoload/lsp/omni.vim

+1-2
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ endfunction
204204
function! s:find_complete_servers() abort
205205
let l:server_names = []
206206
for l:server_name in lsp#get_allowed_servers()
207-
let l:init_capabilities = lsp#get_server_capabilities(l:server_name)
208-
if has_key(l:init_capabilities, 'completionProvider')
207+
if lsp#capabilities#has_completion_provider(l:server_name)
209208
" TODO: support triggerCharacters
210209
call add(l:server_names, l:server_name)
211210
endif

autoload/lsp/ui/vim/completion.vim

+1-5
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,7 @@ function! s:resolve_completion_item(completion_item, server_name) abort
197197
endif
198198

199199
" check server capabilities.
200-
let l:capabilities = lsp#get_server_capabilities(a:server_name)
201-
if !has_key(l:capabilities, 'completionProvider')
202-
\ || type(l:capabilities['completionProvider']) != v:t_dict
203-
\ || !has_key(l:capabilities['completionProvider'], 'resolveProvider')
204-
\ || !l:capabilities['completionProvider']['resolveProvider']
200+
if !lsp#capabilities#has_completion_resolve_provider(a:server_name)
205201
return a:completion_item
206202
endif
207203

autoload/lsp/ui/vim/output.vim

+2
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ function! s:get_float_positioning(height, width) abort
102102
let l:height = min([l:height, max([&lines - &cmdheight - l:row, &previewheight])])
103103

104104
let l:style = 'minimal'
105+
let l:border = 'double'
105106
" Positioning is not window but screen relative
106107
let l:opts = {
107108
\ 'relative': 'editor',
@@ -110,6 +111,7 @@ function! s:get_float_positioning(height, width) abort
110111
\ 'width': l:width,
111112
\ 'height': l:height,
112113
\ 'style': l:style,
114+
\ 'border': l:border,
113115
\ }
114116
return l:opts
115117
endfunction

autoload/lsp/utils/text_edit.vim

+5-6
Original file line numberDiff line numberDiff line change
@@ -200,18 +200,17 @@ function! s:_compare(text_edit1, text_edit2) abort
200200
return a:text_edit1.range.start.character - a:text_edit2.range.start.character
201201
endif
202202
return l:diff
203-
endfunction
203+
endfunction
204204

205205
"
206206
" _switch
207207
"
208208
function! s:_switch(path) abort
209-
if bufnr(a:path) >= 0
210-
execute printf('keepalt keepjumps %sbuffer!', bufnr(a:path))
211-
else
212-
execute printf('keepalt keepjumps edit! %s', fnameescape(a:path))
209+
if bufnr(a:path) == -1
210+
execute printf('badd %s', fnameescape(a:path))
213211
endif
214-
endfunction
212+
execute printf('keepalt keepjumps %sbuffer!', bufnr(a:path))
213+
endfunction
215214

216215
"
217216
" delete

autoload/vital/_lsp/VS/Vim/Window.vim

+51-1
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,55 @@ endfunction
4545
if has('nvim')
4646
function! s:info(winid) abort
4747
let l:info = getwininfo(a:winid)[0]
48+
49+
if s:is_floating(a:winid)
50+
let l:config = nvim_win_get_config(a:winid)
51+
let l:config.border = get(l:config, 'border', 'none')
52+
if type(l:config.border) !=# type([])
53+
if index(['rounded', 'single', 'double', 'solid'], l:config.border) >= 0
54+
let l:width_off = 2
55+
let l:height_off = 2
56+
elseif l:config.border ==# 'shadow'
57+
let l:width_off = 1
58+
let l:height_off = 1
59+
else
60+
let l:width_off = 0
61+
let l:height_off = 0
62+
endif
63+
else
64+
let l:has_top = v:false
65+
let l:has_top = l:has_top || get(l:config.border, 0, '') !=# ''
66+
let l:has_top = l:has_top || get(l:config.border, 1, '') !=# ''
67+
let l:has_top = l:has_top || get(l:config.border, 2, '') !=# ''
68+
let l:has_right = v:false
69+
let l:has_right = l:has_right || get(l:config.border, 2, '') !=# ''
70+
let l:has_right = l:has_right || get(l:config.border, 3, '') !=# ''
71+
let l:has_right = l:has_right || get(l:config.border, 4, '') !=# ''
72+
let l:has_bottom = v:false
73+
let l:has_bottom = l:has_bottom || get(l:config.border, 4, '') !=# ''
74+
let l:has_bottom = l:has_bottom || get(l:config.border, 5, '') !=# ''
75+
let l:has_bottom = l:has_bottom || get(l:config.border, 6, '') !=# ''
76+
let l:has_left = v:false
77+
let l:has_left = l:has_left || get(l:config.border, 6, '') !=# ''
78+
let l:has_left = l:has_left || get(l:config.border, 7, '') !=# ''
79+
let l:has_left = l:has_left || get(l:config.border, 0, '') !=# ''
80+
81+
let l:width_off = (l:has_left ? 1 : 0) + (l:has_right ? 1 : 0)
82+
let l:height_off = (l:has_top ? 1 : 0) + (l:has_bottom ? 1 : 0)
83+
endif
84+
let l:left = get(l:config, '')
85+
let l:info.core_width = l:config.width - l:width_off
86+
let l:info.core_height = l:config.height - l:height_off
87+
else
88+
let l:info.core_width = l:info.width
89+
let l:info.core_height = l:info.height
90+
endif
91+
4892
return {
4993
\ 'width': l:info.width,
5094
\ 'height': l:info.height,
95+
\ 'core_width': l:info.core_width,
96+
\ 'core_height': l:info.core_height,
5197
\ 'topline': l:info.topline,
5298
\ }
5399
endfunction
@@ -58,6 +104,8 @@ else
58104
return {
59105
\ 'width': l:info.width,
60106
\ 'height': l:info.height,
107+
\ 'core_width': l:info.core_width,
108+
\ 'core_height': l:info.core_height,
61109
\ 'topline': l:info.firstline
62110
\ }
63111
endif
@@ -67,6 +115,8 @@ else
67115
function! l:ctx.callback() abort
68116
let self.info.width = winwidth(0)
69117
let self.info.height = winheight(0)
118+
let self.info.core_width = self.info.width
119+
let self.info.core_height = self.info.height
70120
let self.info.topline = line('w0')
71121
endfunction
72122
call s:do(a:winid, { -> l:ctx.callback() })
@@ -106,7 +156,7 @@ function! s:scroll(winid, topline) abort
106156
function! l:ctx.callback(winid, topline) abort
107157
let l:wininfo = s:info(a:winid)
108158
let l:topline = a:topline
109-
let l:topline = min([l:topline, line('$') - l:wininfo.height + 1])
159+
let l:topline = min([l:topline, line('$') - l:wininfo.core_height + 1])
110160
let l:topline = max([l:topline, 1])
111161

112162
if l:topline == l:wininfo.topline

autoload/vital/lsp.vim

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ endfunction
218218
" @vimlint(EVL102, 0, l:__)
219219
" @vimlint(EVL102, 0, l:_)
220220

221-
" s:_get_module() returns module object wihch has all script local functions.
221+
" s:_get_module() returns module object which has all script local functions.
222222
function! s:_get_module(name) abort dict
223223
let funcname = s:_import_func_name(self.plugin_name(), a:name)
224224
try

autoload/vital/lsp.vital

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
lsp
2-
b1e91b41f5028d65fa3d31a425ff21591d5d957f
2+
969a97cb6b3e634490ba168db0f2606c410cf9a7
33

44
VS.LSP.MarkupContent
5-
VS.Vim.Window.FloatingWindow
6-
VS.Vim.Syntax.Markdown
5+
VS.LSP.Text
76
VS.Vim.Buffer
7+
VS.Vim.Syntax.Markdown
88
VS.Vim.Window
9+
VS.Vim.Window.FloatingWindow

doc/vim-lsp.txt

+13-6
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ CONTENTS *vim-lsp-contents*
5858
g:lsp_diagnostics_virtual_text_wrap
5959
|g:lsp_diagnostics_virtual_text_wrap|
6060
g:lsp_document_code_action_signs_enabled
61-
|g:lsp_document_code_actions_signs_enabled|
61+
|g:lsp_document_code_action_signs_enabled|
6262
g:lsp_document_code_action_signs_delay
63-
|g:lsp_document_code_actions_signs_delay|
63+
|g:lsp_document_code_action_signs_delay|
6464
g:lsp_inlay_hints_enabled
6565
|g:lsp_inlay_hints_enabled|
6666
g:lsp_inlay_hints_delay
@@ -271,7 +271,7 @@ You can use tcp to connect to LSP servers that don't support stdio. Set host
271271
and port to tcp. The Godot game engine uses 6008 as its LSP port and godot
272272
ftplugins define gdscript or gdscript3 filetype: >
273273
274-
au User lsp_setup
274+
au User lsp_setup
275275
\ call lsp#register_server({
276276
\ 'name': 'godot',
277277
\ 'tcp': "localhost:6008",
@@ -290,7 +290,7 @@ vim-lsp supports the |:CheckHealth| command which can be useful when debugging
290290
lsp configuration issues.
291291

292292
This command is implemented in vim with the
293-
[vim-healthcheck](https://github.com/rhysd/vim-healthcheck) plugin.
293+
[vim-healthcheck](https://github.com/rhysd/vim-healthcheck) plugin.
294294

295295
WIKI *vim-lsp-configure-wiki*
296296
For documentation on how to configure other language servers refer
@@ -905,7 +905,7 @@ g:lsp_max_buffer_size *g:lsp_max_buffer_size*
905905
`g:lsp_max_buffer_size` (measured in bytes), the following features
906906
are disabled:
907907
* Semantic highlighting
908-
908+
909909
This functionality can be disabled by setting `g:lsp_max_buffer_size`
910910
to a negative value.
911911

@@ -1402,6 +1402,13 @@ The vim |dict| containing information about the server.
14021402
Example: >
14031403
'config': { 'diagnostics': v:false }
14041404
<
1405+
* env:
1406+
optional vim |dict|
1407+
Used to pass environment variables to the cmd.
1408+
Example: >
1409+
'env': { 'GOFLAGS': '-tags=wireinject' }
1410+
<
1411+
14051412
refresh_pattern *vim-lsp-refresh_pattern*
14061413
Type: |String| (|pattern|)
14071414
Default: `'\k*$'`
@@ -2245,7 +2252,7 @@ Popup Formatting *vim-lsp-popup-format*
22452252

22462253
Popup windows use the |gq| operator for formatting content to the window.
22472254

2248-
For customization, see
2255+
For customization, see
22492256
|formatprg|.
22502257

22512258
==============================================================================

0 commit comments

Comments
 (0)