vim-lsp icon indicating copy to clipboard operation
vim-lsp copied to clipboard

Borders are rendered with ASCII characters even if non-ASCII border characters have single width

Open kg8m opened this issue 2 years ago • 2 comments

Hi. Thanks for your great developing. No vim-lsp, no my Vim life.

I have an issue that floating window borders are always rendered with ASCII characters if ambiwidth option is double. But non-ASCII border characters, e.g., , , and so on, can have single width even if ambiwidth is double. For example, setcellwidths([[0x2500, 0x257f, 1]]) makes the non-ASCII border characters single width. I usually set ambiwidth as double for some Japanese symbols and use setcellwidths() for preventing broken layout. But I want to show borders with non-ASCII characters.

ScreenShot_20220507 145037

I think there are some choices:

  1. Use strdisplaywidth() instead of ambiwidth
    • Use non-ASCII characters if strdisplaywidth() returns 1
  2. Add an configuration variable for whether ASCII or non-ASCII is used for borders
    • e.g., let g:lsp_borders_with_ascii = v:false
  3. Add an configuration varaible what characters to use for borders
    • e.g., let g:lsp_border_characters = ['─', '│', '─', '│', '┌', '┐', '┘', '└']
  4. Add an configuration variable for popup options
    • e.g., let g:lsp_float_options = { 'borderchars': ['─', '│', '─', '│', '┌', '┐', '┘', '└'] }
  5. Any other ideas?

Could you please give me feedbacks or your thoughts?

Best regards.

kg8m avatar May 07 '22 06:05 kg8m

Note: I tried to change border characters with lsp_float_opened user event and popup_setoptions() as following.

autocmd User lsp_float_opened call OnFloatOpened()

function OnFloatOpened() abort
  let winid = lsp#ui#vim#output#getpreviewwinid()

  if winid
    call popup_setoptions(winid, #{
      borderchars: ['─', '│', '─', '│', '┌', '┐', '┘', '└'],
      padding: [0, 0, 0, 1],
    })
  endif
endfunction

But it sometimes doesn't work:

  • Signature helps in Insert mode: OK
  • Hover in Normal mode with :LspHover: NG (ASCII characters are used)
  • Previews on completion: NG (ASCII characters are used)

Maybe, this difference is caused because the signature helps are implemented in autoload/lsp/ui/vim/output.vim#L117-L162 but hover and completion previews are implemented in autoload/vital/_lsp/VS/Vim/Window/FloatingWindow.vim#L451-L477.

kg8m avatar May 07 '22 06:05 kg8m

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 10 '22 05:07 stale[bot]