Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Signature hint window disappears in insert mode #238

Open
daveriedstra opened this issue Apr 26, 2024 · 9 comments · May be fixed by #251
Open

[BUG] Signature hint window disappears in insert mode #238

daveriedstra opened this issue Apr 26, 2024 · 9 comments · May be fixed by #251
Labels
bug Something isn't working

Comments

@daveriedstra
Copy link
Contributor

Describe the bug
When inserting function parameters, the signature hint window appears after the initial open paren, then disappears while typing. Additionally, invoking signature.show while in insert mode often does not trigger the signature window. This seems to be related to other content in the parens and whether the closing paren is present.

Expected behavior
The signature hint window should show in insert mode according to the default config, and also when triggered.

Steps to reproduce

  • Open a .scd file and start scnvim
  • Insert a function and an open paren, eg, LPF.ar(| (where | is the cursor)
  • Signature hint window appears
  • While still in insert mode, insert any characters
  • Signature hint window disappears
  • Close the paren, eg, LPF.ar(something)|
  • Return to normal mode with <ESC> then enter insert mode with ci(, resulting in LPF.ar(|)
  • While still in insert mode, trigger signature.show (with a keybind, <C-k> using the below vimrc)
  • Signature hint window does not appear

Additional context
This can be reproduced using this minimal config (eg, with nvim -u testconfig.vimrc, using vim-plug):

call plug#begin()
Plug 'davidgranstrom/scnvim'
call plug#end()

lua << EOF
local scnvim = require('scnvim')
scnvim.setup({
    keymaps = {
        ['<C-k>'] = scnvim.map('signature.show', {'n', 'i'}),
    }
})
EOF

Sorry for the long explanation, this one got slipperier the more I investigated. It has always been this way on my system, so it's not a new thing, I only just got around to trying to fix it...

Information

  • Operating system
    Pop!_OS 22.04

  • SuperCollider version
    3.11.12

  • nvim --version

NVIM v0.10.0-dev                                                                                                                          
Build type: RelWithDebInfo                                                                                                                
LuaJIT 2.1.0-beta3
  • Package manager
    vim-plug
@daveriedstra daveriedstra added the bug Something isn't working label Apr 26, 2024
@salkin-mada
Copy link
Contributor

#241

@salkin-mada
Copy link
Contributor

salkin-mada commented May 5, 2024

For me signature hints only pop up with <C-k> and disappears as soon as I start to type. It does not show after SomeUgen.kr(|.

['<C-k>'] = map('signature.show', {'n', 'i'}, {desc ="signature show"}),

@davidgranstrom
Copy link
Owner

davidgranstrom commented May 6, 2024

@daveriedstra Thanks for the report. I can reproduce the behaviour you are describing (no signature shown while triggering the mapping in insert mode), I'll take a look.

@salkin-mada The float window opens automatically for me when typing the opening paren, perhaps there is some sort of conflict with another plugin and or mapping that causes the issue you are describing?

In case someone stumbles upon this issue in the future while searching, I would just like to share this specific configuration option that changes the "close" behaviour of the signature pop-up.

You will find all possible configuration options in this help file: :h vim.lsp.util.open_floating_preview()

local scnvim = require('scnvim')
scnvim.setup {
  editor = {
    signature = {
      config = {
        -- Keep the signature visible until exiting insert mode, or if cursor moves in normal mode
        close_events = {'InsertLeave', 'CursorMoved'},
      },
    },
  }
}

@daveriedstra
Copy link
Contributor Author

@davidgranstrom thanks for the config example, that's very helpful and probably what I'll end up using with some tweaks. Is there a way to manually close the signature window? I haven't been able to find a scnvim.signature.close and haven't been successful with User autocmd events.

@davidgranstrom
Copy link
Owner

Currently there is no such function, but it should be possible to save the winid returned by this function call and implement a signature.close() function to close the window with said winid. By setting the close_events option to an empty table would mean that you would have to manually close the window so I think it would be a good addition. PR is welcome :)

@daveriedstra
Copy link
Contributor Author

Thanks for the push to write this little PR, @davidgranstrom!

I noticed in another issue that some features relating to syntax could be rewritten to integrate upcoming supercollider LSP. Is that also the case here? Maybe it's worth waiting for that?

@salkin-mada
Copy link
Contributor

@salkin-mada The float window opens automatically for me when typing the opening paren, perhaps there is some sort of conflict with another plugin and or mapping that causes the issue you are describing?

Thanks <3 soo nice to have it sticking until I leave insertmode.

Håhåhå you wont believe it, I dont. So in my config I was not setting the editor = { signature = { config = { } } }
Just adding the signature part after hightlight in the editor table and restarting scnvim. Now the signature hint starts on SinOsc.ar(|.. weird.

Nevermind.. too esoteric. But I am wondering why is the default of signature/config/close_events not InsertLeave and CursorMoved?

@salkin-mada
Copy link
Contributor

You will find all possible configuration options in this help file: :h vim.lsp.util.open_floating_preview()

I have not been able to find this because I have been searching the scnvim help docs. Did I miss it? Is there a link to lsp.util float preview in the docs or?

@daveriedstra
Copy link
Contributor Author

So in my config I was not setting the editor = { signature = { config = { } } }

I've made that mistake before too, with scnvim and other plugins. Easy to get lost in levels of nesting.

But I am wondering why is the default of signature/config/close_events not InsertLeave and CursorMoved?

I'm also curious, I find the default behaviour unintuitive. The signature hint disappears right when I need it. My guess is that it's because there's no event to hook into for reaching the end of the argument list in insert mode, and without one, the hint remains for any time spent in insert mode after the user finishes writing the argument list.

Is there a link to lsp.util float preview in the docs or?

I don't think so. FWIW and for future visitors, the config object is passed directly to open_floating_preview, and the possible close_events are the same as autocmd events (see :h autocmd-events)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants