ray-x / lsp_signature.nvim

LSP signature hint as you type
Apache License 2.0
2.02k stars 57 forks source link

No option to set lsp_signature auto-trigger off #209

Open drusmanbashir opened 2 years ago

drusmanbashir commented 2 years ago

Hi, I want lsp_signature to only fire on demand, using a toggle key. This was working before one of the recent updates, but no longer works. Lsp_signature always triggers when i am inside a function parenthesis. The signature box hides text behind it and that becomes a problem for me, so i have to manually turn if off with the toggle key. Before, I could toggle it on and off whenever needed. Can you please check? My config is below:

cfg = {
  debug = false, -- set to true to enable debug logging
  log_path = vim.fn.stdpath("cache") .. "/lsp_signature.log", -- log dir when debug is on
  -- default is  ~/.cache/nvim/lsp_signature.log
  verbose = false, -- show debug line number

  bind = true, -- This is mandatory, otherwise border config won't get registered.
               -- If you want to hook lspsaga or other signature handler, pls set to false
  doc_lines = 10, -- will show two lines of comment/doc(if there are more than two lines in doc, will be truncated);
                 -- set to 0 if you DO NOT want any API comments be shown
                 -- This setting only take effect in insert mode, it does not affect signature help in normal
                 -- mode, 10 by default

  floating_window = true, -- show hint in a floating window, set to false for virtual text only mode

  floating_window_above_cur_line = true, -- try to place the floating above the current line when possible Note:
  -- will set to true when fully tested, set to false will use whichever side has more space
  -- this setting will be helpful if you do not want the PUM and floating win overlap

  floating_window_off_x = 1, -- adjust float windows x position.
  floating_window_off_y = 1, -- adjust float windows y position.

  fix_pos = false,  -- set to true, the floating window will not auto-close until finish all parameters
  hint_enable = false, -- virtual hint enable
  hint_prefix = "🐼 ",  -- Panda for parameter
  hint_scheme = "String",
  hi_parameter = "LspSignatureActiveParameter", -- how your parameter will be highlight
  max_height = 12, -- max height of signature floating_window, if content is more than max_height, you can scroll down
                   -- to view the hiding contents
  max_width = 80, -- max_width of signature floating_window, line will be wrapped if exceed max_width
  handler_opts = {
    border = "rounded"   -- double, rounded, single, shadow, none
  },

  always_trigger = false, -- sometime show signature on new line or in middle of parameter can be confusing, set it to false for #58

  auto_close_after = nil, -- autoclose signature float win after x sec, disabled if nil.
  extra_trigger_chars = {","}, -- Array of extra characters that will trigger signature completion, e.g., {"(", ","}
  zindex = 200, -- by default it will be on top of all floating windows, set to <= 50 send it to bottom

  padding = '', -- character to pad on left and right of signature can be ' ', or '|'  etc

  transparency = nil, -- disabled by default, allow floating win transparent value 1~100
  shadow_blend = 36, -- if you using shadow as border use this set the opacity
  shadow_guibg = 'Black', -- if you using shadow as border use this set the color e.g. 'Green' or '#121315'
  timer_interval = 200, -- default timer check interval set to lower value if you want to reduce latency
  toggle_key = '<M-;>',
  select_signature_key='<M-n>' ,
}

require "lsp_signature".setup(cfg,bufnr) --ignore:type
require'lsp_signature'.on_attach(cfg, bufnr) 
require("lsp_signature").status_line(max_width)

Many thanks for the fantastic plugin

ray-x commented 2 years ago

What language and LSP you using when you saw the issue?

drusmanbashir commented 2 years ago

Python and pyright today

ray-x commented 2 years ago

There might be something broken. I pushed a fix.

drusmanbashir commented 2 years ago

I updated. Now the behaviour is erratic. The first ever function call in a nvim session still auto-triggers. The next calls of various functions will randomly either trigger, not trigger, or will flash for a moment. Below is a screencast showing the first 2 call auto-trigger the signature. On the 3rd call, signature flashes for a moment and then disappears. Note i use nvim-cmp: Peek 2022-07-25 17-59

ray-x commented 2 years ago

I tried pyright and it works fine for me.

drusmanbashir commented 2 years ago

Yes it works if i disable nvim-cmp plugin and go manual. Just need to find a way to make it work with nvim-cmp active

ray-x commented 2 years ago

nop, I am using nvim-cmp myself, and did not see the issue you experienced. did you update the plugin to latest?

drusmanbashir commented 2 years ago

Yes. Latest plugin versions. Currently, I just get slightly unpredictable behaviour. it does not autoshow half of the time, other times signature pops up if i jump inside a function parentheses. Other times, it pops up for a second and disappears. Below is my neovim version.

:version                                                                                                                                                                                      
NVIM v0.8.0-dev-739-ge59bc078d                                                                                                                                                                
Build type: RelWithDebInfo                                                                                                                                                                    
LuaJIT 2.1.0-beta3                                                                                                                                                                            
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-
prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-c
ommon -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/ub/programs/neovim/build/cmake.
config -I/home/ub/programs/neovim/src -I/home/ub/programs/neovim/.deps/usr/include -I/usr/include -I/home/ub/programs/neovim/build/src/nvim/auto -I/home/ub/programs/neovim/build/include     
Compiled by root@zen                                                                                                                                                                          

Features: +acl +iconv +tui                                                                                                                                                                    
See ":help feature-compile"                                                                                                                                                                   

   system vimrc file: "$VIM/sysinit.vim"                                                                                                                                                      
  fall-back for $VIM: "/usr/local/share/nvim"                                                                                                                                                 

Run :checkhealth for more info      
ray-x commented 2 years ago

Could you try this minimum vimrc https://github.com/ray-x/nvim/blob/master/min/init_pack.lua And check if the issue can be reproduce?

icholy commented 1 year ago

I'm having the same issue, is there a simple way to disable this plugin for python files?

drusmanbashir commented 1 year ago

It works fine for me. My lsp-signature.lua file is the much abbreviated:

cfg = {
  debug = true,
  verbose = true,
  floating_window = false,
  hint_enable = false,
  handler_opts = {
    border = "single",
  },

  bind = true, -- This is mandatory, otherwise border config won't get registered.
    toggle_key = '<M-;>',
  select_signature_key='<M-n>' ,
}

require "lsp_signature".setup(cfg) --ignore:type

See if this helps

ghost commented 1 year ago

这对我来说可以。我的lsp-signature.lua文件被简化了很多:

cfg = {
  debug = true,
  verbose = true,
  floating_window = false,
  hint_enable = false,
  handler_opts = {
    border = "single",
  },

  bind = true, -- This is mandatory, otherwise border config won't get registered.
    toggle_key = '<M-;>',
  select_signature_key='<M-n>' ,
}

require "lsp_signature".setup(cfg) --ignore:type

看这是否有帮助

Hello, may I ask you what is the M in the shortcut key ''?

ray-x commented 1 year ago

Meta key, Can be <Alt> or <Cmd> depending on your keyboard.

ghost commented 1 year ago

Meta key, Can be <Alt> or <Cmd> depending on your keyboard. Thanks so much