lsp icon indicating copy to clipboard operation
lsp copied to clipboard

Signature help mapping conflicts with other mappings to ( or {

Open jclsn opened this issue 7 months ago • 2 comments

I use this old vim-PairTools plugin for per-filetype automatic pair insertion.

For some reason the plugin breaks pair insertion for ( and { characters. Any idea why?

jclsn avatar May 04 '25 17:05 jclsn

Seems like it is the LspShowSignature mapping. Would be nice to have both actually. Maybe a more advanced trigger than ( would be needed.

Found a workaround. You can turn off the signatureHelp option and then use

autocmd InsertCharPre * call g:LspShowSignature()

It's a bit excessive to call this every time a character is inserted. Would be nice if there were an InsertCharPost!

jclsn avatar May 04 '25 17:05 jclsn

I asked the coc.nvim developers how they handle it. Seems they check if the last inserted character matches the trigger char and then do an InsertCharPre.

This seems to work as expected

function! s:MaybeShowSignature(timer)
    if g:last_char_was_trigger
        let g:last_char_was_trigger = 0
        call g:LspShowSignature()
    endif
endfunction

let g:last_char_was_trigger = 0

autocmd InsertCharPre * if v:char ==# '(' | let g:last_char_was_trigger = 1 | call timer_start(10, function('s:MaybeShowSignature')) | endif
autocmd InsertCharPre * if v:char ==# '{' | let g:last_char_was_trigger = 1 | call timer_start(10, function('s:MaybeShowSignature')) | endif

jclsn avatar May 05 '25 10:05 jclsn