Skip to content

Commit

Permalink
Merge branch 'master' into refactor-diagnostics-state
Browse files Browse the repository at this point in the history
  • Loading branch information
prabirshrestha authored Sep 23, 2024
2 parents a622a0b + 04428c9 commit 515964f
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 49 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/mac_neovim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,11 @@ jobs:
repository: thinca/vim-themis
path: ./vim-themis
ref: v1.5.5
- name: Cache gopls
id: cache-gopls
uses: actions/cache@v4
with:
path: bin/gopls
key: ${{ runner.os }}-${{ env.VIM_LSP_GO_VERSION }}-${{ env.VIM_LSP_GOPLS_VERSION }}-${{ env.VIM_LSP_GOPLS_CACHE_VER }}-gopls
- name: Install Go for gopls
if: steps.cache-gopls.outputs.cache-hit != 'true'
uses: actions/setup-go@v5
with:
go-version: ${{ env.VIM_LSP_GO_VERSION }}
- name: Install gopls
if: steps.cache-gopls.outputs.cache-hit != 'true'
shell: bash
run: |
go install golang.org/x/tools/gopls@v${{ env.VIM_LSP_GOPLS_VERSION }}
Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/mac_vim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,11 @@ jobs:
repository: thinca/vim-themis
path: ./vim-themis
ref: v1.5.5
- name: Cache gopls
id: cache-gopls
uses: actions/cache@v4
with:
path: bin/gopls
key: ${{ runner.os }}-${{ env.VIM_LSP_GO_VERSION }}-${{ env.VIM_LSP_GOPLS_VERSION }}-${{ env.VIM_LSP_GOPLS_CACHE_VER }}-gopls
- name: Install Go for gopls
if: steps.cache-gopls.outputs.cache-hit != 'true'
uses: actions/setup-go@v5
with:
go-version: ${{ env.VIM_LSP_GO_VERSION }}
- name: Install gopls
if: steps.cache-gopls.outputs.cache-hit != 'true'
shell: bash
run: |
go install golang.org/x/tools/gopls@v${{ env.VIM_LSP_GOPLS_VERSION }}
Expand Down
39 changes: 31 additions & 8 deletions autoload/health/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ endf


function! health#lsp#check() abort
call health#report_start('server status')
call s:report_start('server status')
let l:server_status = lsp#collect_server_status()

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

let l:status_msg = printf('%s: %s', l:k, l:report.status)
if l:report.status == 'running'
call health#report_ok(l:status_msg)
call s:report_ok(l:status_msg)
elseif l:report.status == 'failed'
call health#report_error(l:status_msg, 'See :help g:lsp_log_verbose to debug server failure.')
else
call health#report_warn(l:status_msg)
call s:report_warn(l:status_msg)
endif
let l:has_printed = v:true
endfor

if !l:has_printed
call health#report_warn('no servers connected')
call s:report_warn('no servers connected')
endif

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

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

call health#report_start('Performance')
call s:report_start('Performance')
if lsp#utils#has_lua() && g:lsp_use_lua
call health#report_ok('Using lua for faster performance.')
call s:report_ok('Using lua for faster performance.')
else
call health#report_warn('Missing requirements to enable lua for faster performance.')
call s:report_warn('Missing requirements to enable lua for faster performance.')
endif

endf

function! s:report_start(report) abort
if has('nvim-0.10')
call v:lua.vim.health.start(a:report)
else
call health#report_start(a:report)
endif
endf

function! s:report_warn(report) abort
if has('nvim-0.10')
call v:lua.vim.health.warn(a:report)
else
call health#report_warn(a:report)
endif
endf

function! s:report_ok(report) abort
if has('nvim-0.10')
call v:lua.vim.health.ok(a:report)
else
call health#report_ok(a:report)
endif
endf
2 changes: 1 addition & 1 deletion autoload/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ function! s:text_changes(buf, server_name) abort
endif

" When syncKind is Incremental and previous content is saved.
if l:sync_kind == 2 && has_key(s:file_content, a:buf)
if l:sync_kind == 2 && has_key(s:file_content, a:buf) && has_key(s:file_content[a:buf], a:server_name)
" compute diff
let l:old_content = s:get_last_file_content(a:buf, a:server_name)
let l:new_content = lsp#utils#buffer#_get_lines(a:buf)
Expand Down
4 changes: 4 additions & 0 deletions autoload/lsp/capabilities.vim
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ function! lsp#capabilities#get_code_action_kinds(server_name) abort
return []
endfunction

function! lsp#capabilities#has_completion_provider(server_name) abort
return s:has_provider(a:server_name, 'completionProvider')
endfunction

function! lsp#capabilities#has_completion_resolve_provider(server_name) abort
return s:has_provider(a:server_name, 'completionProvider', 'resolveProvider')
endfunction
Expand Down
3 changes: 1 addition & 2 deletions autoload/lsp/omni.vim
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ endfunction
function! s:find_complete_servers() abort
let l:server_names = []
for l:server_name in lsp#get_allowed_servers()
let l:init_capabilities = lsp#get_server_capabilities(l:server_name)
if has_key(l:init_capabilities, 'completionProvider')
if lsp#capabilities#has_completion_provider(l:server_name)
" TODO: support triggerCharacters
call add(l:server_names, l:server_name)
endif
Expand Down
6 changes: 1 addition & 5 deletions autoload/lsp/ui/vim/completion.vim
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,7 @@ function! s:resolve_completion_item(completion_item, server_name) abort
endif

" check server capabilities.
let l:capabilities = lsp#get_server_capabilities(a:server_name)
if !has_key(l:capabilities, 'completionProvider')
\ || type(l:capabilities['completionProvider']) != v:t_dict
\ || !has_key(l:capabilities['completionProvider'], 'resolveProvider')
\ || !l:capabilities['completionProvider']['resolveProvider']
if !lsp#capabilities#has_completion_resolve_provider(a:server_name)
return a:completion_item
endif

Expand Down
2 changes: 2 additions & 0 deletions autoload/lsp/ui/vim/output.vim
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ function! s:get_float_positioning(height, width) abort
let l:height = min([l:height, max([&lines - &cmdheight - l:row, &previewheight])])

let l:style = 'minimal'
let l:border = 'double'
" Positioning is not window but screen relative
let l:opts = {
\ 'relative': 'editor',
Expand All @@ -110,6 +111,7 @@ function! s:get_float_positioning(height, width) abort
\ 'width': l:width,
\ 'height': l:height,
\ 'style': l:style,
\ 'border': l:border,
\ }
return l:opts
endfunction
Expand Down
11 changes: 5 additions & 6 deletions autoload/lsp/utils/text_edit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -200,18 +200,17 @@ function! s:_compare(text_edit1, text_edit2) abort
return a:text_edit1.range.start.character - a:text_edit2.range.start.character
endif
return l:diff
endfunction
endfunction

"
" _switch
"
function! s:_switch(path) abort
if bufnr(a:path) >= 0
execute printf('keepalt keepjumps %sbuffer!', bufnr(a:path))
else
execute printf('keepalt keepjumps edit! %s', fnameescape(a:path))
if bufnr(a:path) == -1
execute printf('badd %s', fnameescape(a:path))
endif
endfunction
execute printf('keepalt keepjumps %sbuffer!', bufnr(a:path))
endfunction

"
" delete
Expand Down
52 changes: 51 additions & 1 deletion autoload/vital/_lsp/VS/Vim/Window.vim
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,55 @@ endfunction
if has('nvim')
function! s:info(winid) abort
let l:info = getwininfo(a:winid)[0]

if s:is_floating(a:winid)
let l:config = nvim_win_get_config(a:winid)
let l:config.border = get(l:config, 'border', 'none')
if type(l:config.border) !=# type([])
if index(['rounded', 'single', 'double', 'solid'], l:config.border) >= 0
let l:width_off = 2
let l:height_off = 2
elseif l:config.border ==# 'shadow'
let l:width_off = 1
let l:height_off = 1
else
let l:width_off = 0
let l:height_off = 0
endif
else
let l:has_top = v:false
let l:has_top = l:has_top || get(l:config.border, 0, '') !=# ''
let l:has_top = l:has_top || get(l:config.border, 1, '') !=# ''
let l:has_top = l:has_top || get(l:config.border, 2, '') !=# ''
let l:has_right = v:false
let l:has_right = l:has_right || get(l:config.border, 2, '') !=# ''
let l:has_right = l:has_right || get(l:config.border, 3, '') !=# ''
let l:has_right = l:has_right || get(l:config.border, 4, '') !=# ''
let l:has_bottom = v:false
let l:has_bottom = l:has_bottom || get(l:config.border, 4, '') !=# ''
let l:has_bottom = l:has_bottom || get(l:config.border, 5, '') !=# ''
let l:has_bottom = l:has_bottom || get(l:config.border, 6, '') !=# ''
let l:has_left = v:false
let l:has_left = l:has_left || get(l:config.border, 6, '') !=# ''
let l:has_left = l:has_left || get(l:config.border, 7, '') !=# ''
let l:has_left = l:has_left || get(l:config.border, 0, '') !=# ''

let l:width_off = (l:has_left ? 1 : 0) + (l:has_right ? 1 : 0)
let l:height_off = (l:has_top ? 1 : 0) + (l:has_bottom ? 1 : 0)
endif
let l:left = get(l:config, '')
let l:info.core_width = l:config.width - l:width_off
let l:info.core_height = l:config.height - l:height_off
else
let l:info.core_width = l:info.width
let l:info.core_height = l:info.height
endif

return {
\ 'width': l:info.width,
\ 'height': l:info.height,
\ 'core_width': l:info.core_width,
\ 'core_height': l:info.core_height,
\ 'topline': l:info.topline,
\ }
endfunction
Expand All @@ -58,6 +104,8 @@ else
return {
\ 'width': l:info.width,
\ 'height': l:info.height,
\ 'core_width': l:info.core_width,
\ 'core_height': l:info.core_height,
\ 'topline': l:info.firstline
\ }
endif
Expand All @@ -67,6 +115,8 @@ else
function! l:ctx.callback() abort
let self.info.width = winwidth(0)
let self.info.height = winheight(0)
let self.info.core_width = self.info.width
let self.info.core_height = self.info.height
let self.info.topline = line('w0')
endfunction
call s:do(a:winid, { -> l:ctx.callback() })
Expand Down Expand Up @@ -106,7 +156,7 @@ function! s:scroll(winid, topline) abort
function! l:ctx.callback(winid, topline) abort
let l:wininfo = s:info(a:winid)
let l:topline = a:topline
let l:topline = min([l:topline, line('$') - l:wininfo.height + 1])
let l:topline = min([l:topline, line('$') - l:wininfo.core_height + 1])
let l:topline = max([l:topline, 1])

if l:topline == l:wininfo.topline
Expand Down
2 changes: 1 addition & 1 deletion autoload/vital/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ endfunction
" @vimlint(EVL102, 0, l:__)
" @vimlint(EVL102, 0, l:_)

" s:_get_module() returns module object wihch has all script local functions.
" s:_get_module() returns module object which has all script local functions.
function! s:_get_module(name) abort dict
let funcname = s:_import_func_name(self.plugin_name(), a:name)
try
Expand Down
7 changes: 4 additions & 3 deletions autoload/vital/lsp.vital
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
lsp
b1e91b41f5028d65fa3d31a425ff21591d5d957f
969a97cb6b3e634490ba168db0f2606c410cf9a7

VS.LSP.MarkupContent
VS.Vim.Window.FloatingWindow
VS.Vim.Syntax.Markdown
VS.LSP.Text
VS.Vim.Buffer
VS.Vim.Syntax.Markdown
VS.Vim.Window
VS.Vim.Window.FloatingWindow
19 changes: 13 additions & 6 deletions doc/vim-lsp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ CONTENTS *vim-lsp-contents*
g:lsp_diagnostics_virtual_text_wrap
|g:lsp_diagnostics_virtual_text_wrap|
g:lsp_document_code_action_signs_enabled
|g:lsp_document_code_actions_signs_enabled|
|g:lsp_document_code_action_signs_enabled|
g:lsp_document_code_action_signs_delay
|g:lsp_document_code_actions_signs_delay|
|g:lsp_document_code_action_signs_delay|
g:lsp_inlay_hints_enabled
|g:lsp_inlay_hints_enabled|
g:lsp_inlay_hints_delay
Expand Down Expand Up @@ -271,7 +271,7 @@ You can use tcp to connect to LSP servers that don't support stdio. Set host
and port to tcp. The Godot game engine uses 6008 as its LSP port and godot
ftplugins define gdscript or gdscript3 filetype: >
au User lsp_setup
au User lsp_setup
\ call lsp#register_server({
\ 'name': 'godot',
\ 'tcp': "localhost:6008",
Expand All @@ -290,7 +290,7 @@ vim-lsp supports the |:CheckHealth| command which can be useful when debugging
lsp configuration issues.

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

WIKI *vim-lsp-configure-wiki*
For documentation on how to configure other language servers refer
Expand Down Expand Up @@ -905,7 +905,7 @@ g:lsp_max_buffer_size *g:lsp_max_buffer_size*
`g:lsp_max_buffer_size` (measured in bytes), the following features
are disabled:
* Semantic highlighting

This functionality can be disabled by setting `g:lsp_max_buffer_size`
to a negative value.

Expand Down Expand Up @@ -1402,6 +1402,13 @@ The vim |dict| containing information about the server.
Example: >
'config': { 'diagnostics': v:false }
<
* env:
optional vim |dict|
Used to pass environment variables to the cmd.
Example: >
'env': { 'GOFLAGS': '-tags=wireinject' }
<

refresh_pattern *vim-lsp-refresh_pattern*
Type: |String| (|pattern|)
Default: `'\k*$'`
Expand Down Expand Up @@ -2245,7 +2252,7 @@ Popup Formatting *vim-lsp-popup-format*

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

For customization, see
For customization, see
|formatprg|.

==============================================================================
Expand Down
Loading

0 comments on commit 515964f

Please sign in to comment.