mirror of
https://github.com/prabirshrestha/vim-lsp.git
synced 2026-06-09 15:37:30 +02:00
Add an option to fixup vim popup with conceal problems (#1376)
* Fix vim's popup and conceals * Add lsp_preview_fixup_conceal * Fix CI
This commit is contained in:
@@ -36,6 +36,11 @@ jobs:
|
||||
runs-on: ${{matrix.os}}
|
||||
continue-on-error: ${{matrix.allow_failure}}
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
# https://github.com/Zettlr/Zettlr/issues/3517
|
||||
sudo apt-get install libfuse2
|
||||
- uses: actions/checkout@v2
|
||||
- name: Download neovim
|
||||
shell: bash
|
||||
|
||||
@@ -31,6 +31,11 @@ jobs:
|
||||
glibc_version: 2.15
|
||||
runs-on: ${{matrix.os}}
|
||||
steps:
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
# https://github.com/Zettlr/Zettlr/issues/3517
|
||||
sudo apt-get install libfuse2
|
||||
- uses: actions/checkout@v2
|
||||
- name: Download vim
|
||||
shell: bash
|
||||
@@ -72,5 +77,8 @@ jobs:
|
||||
export PATH=./vim-themis/bin:$PATH
|
||||
export PATH=./bin:$PATH
|
||||
export THEMIS_VIM=vim
|
||||
vim --version
|
||||
themis
|
||||
# https://github.com/project-slippi/Ishiiruka/issues/323
|
||||
# It was needed to detect the actual path of `libgmodule` via `ldconfig -p | grep libg`.
|
||||
LD_PRELOAD=/lib/x86_64-linux-gnu/libgmodule-2.0.so vim --version
|
||||
LD_PRELOAD=/lib/x86_64-linux-gnu/libgmodule-2.0.so themis
|
||||
|
||||
|
||||
@@ -83,13 +83,17 @@ function! s:show_floating_window(event, managed_user_data) abort
|
||||
let l:detail = s:MarkupContent.normalize({
|
||||
\ 'language': &filetype,
|
||||
\ 'value': l:completion_item['detail'],
|
||||
\ }, {
|
||||
\ 'compact': !g:lsp_preview_fixup_conceal
|
||||
\ })
|
||||
let l:contents += [l:detail]
|
||||
endif
|
||||
endif
|
||||
|
||||
" Add documentation filed if provided.
|
||||
let l:documentation = s:MarkupContent.normalize(get(l:completion_item, 'documentation', ''))
|
||||
let l:documentation = s:MarkupContent.normalize(get(l:completion_item, 'documentation', ''), {
|
||||
\ 'compact': !g:lsp_preview_fixup_conceal
|
||||
\ })
|
||||
if !empty(l:documentation)
|
||||
let l:contents += [l:documentation]
|
||||
endif
|
||||
|
||||
@@ -189,13 +189,17 @@ function! s:get_contents(contents) abort
|
||||
if has_key(a:contents, 'value')
|
||||
if has_key(a:contents, 'kind')
|
||||
if a:contents['kind'] ==? 'markdown'
|
||||
let l:detail = s:MarkupContent.normalize(a:contents['value'])
|
||||
let l:detail = s:MarkupContent.normalize(a:contents['value'], {
|
||||
\ 'compact': !g:lsp_preview_fixup_conceal
|
||||
\ })
|
||||
return [l:detail]
|
||||
else
|
||||
return [a:contents['value']]
|
||||
endif
|
||||
elseif has_key(a:contents, 'language')
|
||||
let l:detail = s:MarkupContent.normalize(a:contents)
|
||||
let l:detail = s:MarkupContent.normalize(a:contents, {
|
||||
\ 'compact': !g:lsp_preview_fixup_conceal
|
||||
\ })
|
||||
return [l:detail]
|
||||
else
|
||||
return ''
|
||||
|
||||
@@ -434,7 +434,9 @@ function! lsp#ui#vim#output#append(data, lines, syntax_lines) abort
|
||||
elseif type(a:data) ==# type({}) && has_key(a:data, 'kind')
|
||||
if a:data.kind ==? 'markdown'
|
||||
call s:import_modules()
|
||||
let l:detail = s:MarkupContent.normalize(a:data.value)
|
||||
let l:detail = s:MarkupContent.normalize(a:data.value, {
|
||||
\ 'compact': !g:lsp_preview_fixup_conceal
|
||||
\ })
|
||||
call extend(a:lines, s:Text.split_by_eol(l:detail))
|
||||
else
|
||||
call extend(a:lines, split(s:escape_string_for_display(a:data.value), '\n', v:true))
|
||||
|
||||
@@ -36,27 +36,31 @@ function! s:normalize(markup_content, ...) abort
|
||||
elseif type(a:markup_content) == type({})
|
||||
let l:normalized = a:markup_content.value
|
||||
if has_key(a:markup_content, 'language')
|
||||
let l:normalized = '```' . a:markup_content.language . ' ' . l:normalized . ' ```'
|
||||
let l:normalized = join([
|
||||
\ '```' . a:markup_content.language,
|
||||
\ l:normalized,
|
||||
\ '```'
|
||||
\ ], "\n")
|
||||
endif
|
||||
endif
|
||||
if l:option.compact
|
||||
return s:_compact(l:normalized)
|
||||
endif
|
||||
let l:normalized = s:Text.normalize_eol(l:normalized)
|
||||
let l:normalized = s:_format(l:normalized, l:option.compact)
|
||||
return l:normalized
|
||||
endfunction
|
||||
|
||||
"
|
||||
" _compact
|
||||
" _format
|
||||
"
|
||||
function! s:_compact(string) abort
|
||||
" normalize eol.
|
||||
let l:string = s:Text.normalize_eol(a:string)
|
||||
|
||||
let l:string = substitute(l:string, "\\%(\\s\\|\n\\)*```\\s*\\(\\w\\+\\)\\%(\\s\\|\n\\)\\+", "\n\n```\\1 ", 'g')
|
||||
let l:string = substitute(l:string, "\\%(\\s\\|\n\\)\\+```\\%(\\s*\\%(\\%$\\|\n\\)\\)\\+", " ```\n\n", 'g')
|
||||
function! s:_format(string, compact) abort
|
||||
let l:string = a:string
|
||||
if a:compact
|
||||
let l:string = substitute(l:string, "\\%(\\s\\|\n\\)*```\\s*\\(\\w\\+\\)\\%(\\s\\|\n\\)\\+", "\n\n```\\1 ", 'g')
|
||||
let l:string = substitute(l:string, "\\%(\\s\\|\n\\)\\+```\\%(\\s*\\%(\\%$\\|\n\\)\\)\\+", " ```\n\n", 'g')
|
||||
else
|
||||
let l:string = substitute(l:string, "```\n\\zs\\%(\\s\\|\n\\)\\+", "", 'g')
|
||||
endif
|
||||
let l:string = substitute(l:string, "\\%^\\%(\\s\\|\n\\)*", '', 'g')
|
||||
let l:string = substitute(l:string, "\\%(\\s\\|\n\\)*\\%$", '', 'g')
|
||||
|
||||
return l:string
|
||||
endfunction
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
function! s:_SID() abort
|
||||
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
|
||||
endfunction
|
||||
execute join(['function! vital#_lsp#VS#Vim#Buffer#import() abort', printf("return map({'get_line_count': '', 'do': '', 'create': '', 'pseudo': '', 'ensure': '', 'load': ''}, \"vital#_lsp#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
|
||||
execute join(['function! vital#_lsp#VS#Vim#Buffer#import() abort', printf("return map({'add': '', 'do': '', 'create': '', 'get_line_count': '', 'pseudo': '', 'ensure': '', 'load': ''}, \"vital#_lsp#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
|
||||
delfunction s:_SID
|
||||
" ___vital___
|
||||
let s:Do = { -> {} }
|
||||
@@ -51,11 +51,25 @@ function! s:ensure(expr) abort
|
||||
if type(a:expr) == type(0)
|
||||
throw printf('VS.Vim.Buffer: `%s` is not valid expr.', a:expr)
|
||||
endif
|
||||
badd `=a:expr`
|
||||
call s:add(a:expr)
|
||||
endif
|
||||
return bufnr(a:expr)
|
||||
endfunction
|
||||
|
||||
"
|
||||
" add
|
||||
"
|
||||
if exists('*bufadd')
|
||||
function! s:add(name) abort
|
||||
let l:bufnr = bufadd(a:name)
|
||||
call setbufvar(l:bufnr, '&buflisted', 1)
|
||||
endfunction
|
||||
else
|
||||
function! s:add(name) abort
|
||||
badd `=a:name`
|
||||
endfunction
|
||||
endif
|
||||
|
||||
"
|
||||
" load
|
||||
"
|
||||
|
||||
@@ -74,7 +74,7 @@ function! s:apply(...) abort
|
||||
\ l:filetype_group
|
||||
\ )
|
||||
catch /.*/
|
||||
unsilent echomsg string({ 'exception': v:exception, 'throwpoint': v:throwpoint })
|
||||
unsilent echomsg printf('Fail to apply "syntax/%s.vim". Add "let g:markdown_fenced_languages = ["%s=$FILETYPE"]" to enable syntax', l:filetype, l:filetype)
|
||||
endtry
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
@@ -106,7 +106,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 + 3])
|
||||
let l:topline = min([l:topline, line('$') - l:wininfo.height + 1])
|
||||
let l:topline = max([l:topline, 1])
|
||||
|
||||
if l:topline == l:wininfo.topline
|
||||
|
||||
@@ -198,7 +198,8 @@ endfunction
|
||||
" @param {number} args.col 0-based indexing
|
||||
" @param {number} args.width
|
||||
" @param {number} args.height
|
||||
" @param {boolean?} args.border
|
||||
" @param {boolean|[string]?} args.border - boolean, or list of characters
|
||||
" clockwise from top-left (same as nvim_open_win() in neovim)
|
||||
" @param {number?} args.topline
|
||||
" @param {string?} args.origin - topleft/topright/botleft/botright
|
||||
"
|
||||
@@ -450,11 +451,14 @@ endfunction
|
||||
|
||||
if has('nvim')
|
||||
function! s:_resolve_border(style) abort
|
||||
if !empty(get(a:style, 'border', v:null))
|
||||
if &ambiwidth ==# 'single'
|
||||
let a:style.border = ['┌', '─', '┐', '│', '┘', '─', '└', '│']
|
||||
else
|
||||
let a:style.border = ['+', '-', '+', '|', '+', '-', '+', '|']
|
||||
let l:border = get(a:style, 'border', v:null)
|
||||
if !empty(l:border)
|
||||
if type(l:border) != type([])
|
||||
if &ambiwidth ==# 'single'
|
||||
let a:style.border = ['┌', '─', '┐', '│', '┘', '─', '└', '│']
|
||||
else
|
||||
let a:style.border = ['+', '-', '+', '|', '+', '-', '+', '|']
|
||||
endif
|
||||
endif
|
||||
elseif has_key(a:style, 'border')
|
||||
unlet a:style.border
|
||||
@@ -463,11 +467,28 @@ if has('nvim')
|
||||
endfunction
|
||||
else
|
||||
function! s:_resolve_border(style) abort
|
||||
let l:border = get(a:style, 'border', v:null)
|
||||
if !empty(get(a:style, 'border', v:null))
|
||||
if &ambiwidth ==# 'single'
|
||||
let a:style.border = ['─', '│', '─', '│', '┌', '┐', '┘', '└']
|
||||
if type(l:border) != type([])
|
||||
if &ambiwidth ==# 'single'
|
||||
let a:style.border = ['─', '│', '─', '│', '┌', '┐', '┘', '└']
|
||||
else
|
||||
let a:style.border = ['-', '|', '-', '|', '+', '+', '+', '+']
|
||||
endif
|
||||
else
|
||||
let a:style.border = ['-', '|', '-', '|', '+', '+', '+', '+']
|
||||
" Emulate nvim behavior for lists of 1/2/4 elements
|
||||
let l:topleft = l:border[0]
|
||||
let l:top = get(l:border, 1, l:topleft)
|
||||
let l:topright = get(l:border, 2, l:topleft)
|
||||
let l:right = get(l:border, 3, l:top)
|
||||
let l:bottomright = get(l:border, 4, l:topleft)
|
||||
let l:bottom = get(l:border, 5, l:top)
|
||||
let l:bottomleft = get(l:border, 6, l:topright)
|
||||
let l:left = get(l:border, 7, l:right)
|
||||
let a:style.border = [
|
||||
\ l:top, l:right, l:bottom, l:left,
|
||||
\ l:topleft, l:topright, l:bottomright, l:bottomleft,
|
||||
\ ]
|
||||
endif
|
||||
elseif has_key(a:style, 'border')
|
||||
unlet a:style.border
|
||||
|
||||
@@ -190,6 +190,8 @@ function! s:_format_throwpoint(throwpoint) abort
|
||||
return join(funcs, "\n")
|
||||
endfunction
|
||||
|
||||
" @vimlint(EVL102, 1, l:_)
|
||||
" @vimlint(EVL102, 1, l:__)
|
||||
function! s:_get_func_info(name) abort
|
||||
let name = a:name
|
||||
if a:name =~# '^\d\+$' " is anonymous-function
|
||||
@@ -213,6 +215,8 @@ function! s:_get_func_info(name) abort
|
||||
\ 'attrs': filter(['dict', 'abort', 'range', 'closure'], 'signature =~# (").*" . v:val)'),
|
||||
\ }
|
||||
endfunction
|
||||
" @vimlint(EVL102, 0, l:__)
|
||||
" @vimlint(EVL102, 0, l:_)
|
||||
|
||||
" s:_get_module() returns module object wihch has all script local functions.
|
||||
function! s:_get_module(name) abort dict
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
lsp
|
||||
2755f0c8fbd3442bcb7f567832e4d1455b57f9a2
|
||||
b1e91b41f5028d65fa3d31a425ff21591d5d957f
|
||||
|
||||
VS.LSP.MarkupContent
|
||||
VS.Vim.Window.FloatingWindow
|
||||
|
||||
@@ -70,6 +70,7 @@ CONTENTS *vim-lsp-contents*
|
||||
g:lsp_peek_alignment |g:lsp_peek_alignment|
|
||||
g:lsp_preview_max_width |g:lsp_preview_max_width|
|
||||
g:lsp_preview_max_height |g:lsp_preview_max_height|
|
||||
g:lsp_preview_fixup_conceal |g:lsp_preview_fixup_conceal|
|
||||
g:lsp_signature_help_enabled |g:lsp_signature_help_enabled|
|
||||
g:lsp_fold_enabled |g:lsp_fold_enabled|
|
||||
g:lsp_hover_conceal |g:lsp_hover_conceal|
|
||||
@@ -894,6 +895,14 @@ g:lsp_preview_max_height *g:lsp_preview_max_height*
|
||||
If positive, determines the maximum height of the preview window in
|
||||
characters. Use a value of `-1` to disable setting a maximum height.
|
||||
|
||||
g:lsp_preview_fixup_conceal *g:lsp_preview_fixup_conceal*
|
||||
Type: |Number|
|
||||
Default: `0`
|
||||
|
||||
If negative, all markdown documents are not converted as compact format.
|
||||
That's useful in vim. vim's popup doesn't shrink correctly if the
|
||||
buffer content uses conceals.
|
||||
|
||||
g:lsp_signature_help_enabled *g:lsp_signature_help_enabled*
|
||||
Type: |Number|
|
||||
Default: `1`
|
||||
|
||||
@@ -53,6 +53,7 @@ let g:lsp_document_highlight_delay = get(g:, 'lsp_document_highlight_delay', 350
|
||||
let g:lsp_preview_float = get(g:, 'lsp_preview_float', 1)
|
||||
let g:lsp_preview_autoclose = get(g:, 'lsp_preview_autoclose', 1)
|
||||
let g:lsp_preview_doubletap = get(g:, 'lsp_preview_doubletap', [function('lsp#ui#vim#output#focuspreview')])
|
||||
let g:lsp_preview_fixup_conceal = get(g:, 'lsp_preview_fixup_conceal', 0)
|
||||
let g:lsp_peek_alignment = get(g:, 'lsp_peek_alignment', 'center')
|
||||
let g:lsp_preview_max_width = get(g:, 'lsp_preview_max_width', -1)
|
||||
let g:lsp_preview_max_height = get(g:, 'lsp_preview_max_height', -1)
|
||||
|
||||
Reference in New Issue
Block a user