Skip to content

Commit

Permalink
Merge branch 'master' into scroll-border
Browse files Browse the repository at this point in the history
  • Loading branch information
prabirshrestha authored Aug 5, 2024
2 parents c544ccd + 396d248 commit 0235b1d
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 37 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
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
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
40 changes: 40 additions & 0 deletions test/lsp/utils/text_edit.vimspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ function! s:set_text(lines)
% delete _
put =a:lines
execute 'normal ggdd'
execute 'file my-file'
endfunction

function! s:get_text()
Expand Down Expand Up @@ -642,6 +643,45 @@ Describe lsp#utils#text_edit

Assert Equals(getbufline(l:target, 1), ['aiueo'])
End

It should apply edits to buffer and unloaded file
let l:text = ['plop']
call s:set_text(l:text)
let l:buffer_text = s:get_text()
Assert Equals(l:buffer_text, ['plop', ''])
let l:target = globpath(&runtimepath, 'test/lsp/utils/text_edit.vimspec')
call lsp#utils#text_edit#apply_text_edits(
\ lsp#utils#path_to_uri(expand('%')),
\ [{
\ 'range': {
\ 'start': {
\ 'line': 0,
\ 'character': 0,
\ },
\ 'end': {
\ 'line': 1,
\ 'character': 0,
\ }
\ },
\ 'newText': "buffer\n"
\ }])
call lsp#utils#text_edit#apply_text_edits(lsp#utils#path_to_uri(l:target), [{
\ 'range': {
\ 'start': {
\ 'line': 0,
\ 'character': 0,
\ },
\ 'end': {
\ 'line': 1,
\ 'character': 0,
\ }
\ },
\ 'newText': "unloaded\n"
\ }])

Assert Equals(getbufline(l:target, 1), ['unloaded'])
Assert Equals(getbufline(expand('%'), 1), ['buffer'])
End
End
End

0 comments on commit 0235b1d

Please sign in to comment.