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

Doesn't seem to work #1

Closed
gegoune opened this issue Mar 1, 2021 · 64 comments
Closed

Doesn't seem to work #1

gegoune opened this issue Mar 1, 2021 · 64 comments
Assignees

Comments

@gegoune
Copy link

gegoune commented Mar 1, 2021

Hi! I am quite keen to get try out this plugin, but as of now it doesn't work. Tried lua file with sumneko's lsp, and python with pyright; didn't get any popups with argument once in () after function call for neither of filetypes.

Installed with packer like that:

use {
  "neovim/nvim-lspconfig",
  requires = {
    {
      "kosayoda/nvim-lightbulb",
      config = function()
        vim.api.nvim_command("highlight LightBulbVirtualText guifg=red")
      end
    },
    "nvim-lua/lsp-status.nvim",
    {"ojroques/nvim-lspfuzzy", config = require "lspfuzzy".setup {}},
    {
      "ray-x/lsp_signature.nvim",
      config = function()
        require "lsp_signature".on_attach()
      end
    }
  }
}

I also have nvim-compe if that makes any difference.

@ray-x
Copy link
Owner

ray-x commented Mar 1, 2021

Thanks for trying this out.

Did a quick test with lua and python. It should work
Screen Shot 2021-03-02 at 12 43 03 am
Screen Shot 2021-03-02 at 12 46 10 am

Can you check if your 'textDocument/hover' or
'lua vim.lsp.buf.signature_help()' works when the cursor inside bracket?

Sometime when lsp can not find signature, pop up will not show. This may happen for the script where function definition is not strong typed.

my lua lsp config is here:
https://github.com/ray-x/dotfiles/blob/7e7709cdab3491e03a6f7fd5f96d13ac139cd865/lua/lsp_config.lua#L383

also pyls:
https://github.com/ray-x/dotfiles/blob/7e7709cdab3491e03a6f7fd5f96d13ac139cd865/lua/lsp_config.lua#L432

@gegoune
Copy link
Author

gegoune commented Mar 1, 2021

Yes, calling lua vim.lsp.buf.signature_help() does show signature help, so it's there and working, just doesn't show up automatically. Perhaps some autocmd is missing?

@ray-x
Copy link
Owner

ray-x commented Mar 1, 2021

That is a bit wired.

require "lsp_signature".on_attach()

Should register the handler to Insert event.

One more thing to check:

I also exported the signature function, can you check if

lua require'lsp_signature'.signature()

give you same result of:

lua vim.lsp.buf.signature_help()

If it shows the same, that means the handler was not registered. If signature() also shows nothing, that there are other place need to check. So another thing to check is

require "lsp_signature".on_attach()
lua require'lsp_signature'.signature()

Togher to enforce on_attach to run again. I put my attach() in init.lua. Not sure it works same way in parker.

@gegoune
Copy link
Author

gegoune commented Mar 1, 2021

Interesting, lua require'lsp_signature'.signature() returned nothing in both tests, that is, with and without (after) require "lsp_signature".on_attach().

Did double check and lua vim.lsp.buf.signature_help() showed signature.

Thanks for helping with debug!

@ray-x
Copy link
Owner

ray-x commented Mar 2, 2021

I just full back to a min config. It still works.

call plug#begin('~/.vim/plugged')
" Group dependencies, vim-snippets depends on ultisnips
Plug 'neovim/nvim-lspconfig'
Plug 'ray-x/lsp_signature.nvim'
call plug#end()

lua <<EOF
local nvim_lsp = require('lspconfig')
-- require('lsp_config')  -- you may need my lsp_config.lua
require('lsp_signature').on_attach()
local sumneko_root_path = vim.fn.expand("$HOME")..'/github/sumneko/lua-language-server'
local sumneko_binary = vim.fn.expand("$HOME")..'/github/sumneko/lua-language-server/bin/macOS/lua-language-server'
local on_attach = function(client, bufnr)
  require'lsp_signature'.on_attach()
  vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
end

require'lspconfig'.sumneko_lua.setup {
  cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"};
  on_attach = on_attach,
}
EOF

Can you send a minimum vimrc to reproduce the issue. I tried packer a few months before, but does not keep the configurations.

@ray-x
Copy link
Owner

ray-x commented Mar 2, 2021

Also tried following pack config vimrc it works as expected.

lua <<EOF

vim.cmd [[packadd packer.nvim]]
-- Only if your version of Neovim doesn't have https://github.com/neovim/neovim/pull/12632 merged
-- vim._update_package_paths()

require('packer').startup(function()
use {
  "neovim/nvim-lspconfig",
  "ray-x/lsp_signature.nvim",
}
end)

local nvim_lsp = require('lspconfig')
-- require('lsp_config')  -- you may need my lsp_config.lua
require('lsp_signature').on_attach()
local sumneko_root_path = vim.fn.expand("$HOME")..'/github/sumneko/lua-language-server'
local sumneko_binary = vim.fn.expand("$HOME")..'/github/sumneko/lua-language-server/bin/macOS/lua-language-server'
local on_attach = function(client, bufnr)
  require'lsp_signature'.on_attach()
end

require'lspconfig'.sumneko_lua.setup {
  cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"};
  on_attach = on_attach,
}

EOF
let g:min_load = 1 "prevent other configure to load

@gegoune
Copy link
Author

gegoune commented Mar 2, 2021

It works with minimal config, so something else in my configuration conflicts with your plugin. Will try to figure it out and come back to you. Thanks!

@gegoune
Copy link
Author

gegoune commented Mar 10, 2021

It cut my configuration in many different ways, removed all plugins, settings and whatever else I could think of, but still no luck. Do you have any insight where to look exactly, as in, what could be stopping your plugin from working?

@ray-x
Copy link
Owner

ray-x commented Mar 10, 2021

It is really wired. Can you check if my minimum vimrc works for you or not?
Also, I am using kitty + mac.
Your issue looks like the event was hijacked and was not hooked.
Another thing is timer.
The code setup time in this plugin

timer:start(100, 200, vim.schedule_wrap(function()
...

This setup works for me. delay 100ms and refresh every 200ms.

And my timeout setting in vimrc:
timeoutlen = 500;
ttimeoutlen = 10;
updatetime = 100;
redrawtime = 1500;

The final check is to dump all InsertEnter/Leave registration in vim... That would be annoying to check the conflictions.

Also tried following pack config vimrc it works as expected.

lua <<EOF

vim.cmd [[packadd packer.nvim]]
-- Only if your version of Neovim doesn't have https://github.com/neovim/neovim/pull/12632 merged
-- vim._update_package_paths()

require('packer').startup(function()
use {
  "neovim/nvim-lspconfig",
  "ray-x/lsp_signature.nvim",
}
end)

local nvim_lsp = require('lspconfig')
-- require('lsp_config')  -- you may need my lsp_config.lua
require('lsp_signature').on_attach()
local sumneko_root_path = vim.fn.expand("$HOME")..'/github/sumneko/lua-language-server'
local sumneko_binary = vim.fn.expand("$HOME")..'/github/sumneko/lua-language-server/bin/macOS/lua-language-server'
local on_attach = function(client, bufnr)
  require'lsp_signature'.on_attach()
end

require'lspconfig'.sumneko_lua.setup {
  cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"};
  on_attach = on_attach,
}

EOF
let g:min_load = 1 "prevent other configure to load

@gegoune
Copy link
Author

gegoune commented Mar 10, 2021

Ah, no, problem definitely is within my configuration. Your minimal configuration with packer does work.

I am not sure if it is due to autocmd or not, but lua require'lsp_signature'.signature() returns nil when run on pcall(| (where | is cursor).

@ray-x
Copy link
Owner

ray-x commented Mar 10, 2021

Is your plugin is lazyloading? Try opt=false?

@gegoune
Copy link
Author

gegoune commented Mar 10, 2021

No, it's not lazy loaded:

use {
  "neovim/nvim-lspconfig",
  requires = {
    {
      "kosayoda/nvim-lightbulb",
      config = function()
        vim.api.nvim_command("highlight LightBulbVirtualText guifg=red")
      end
    },
    "nvim-lua/lsp-status.nvim",
    {"ojroques/nvim-lspfuzzy", config = require "lspfuzzy".setup {}},
    "ray-x/lsp_signature.nvim"
  }
}

I then have require "lsp" in my init.lua sourcing lsp/init.lua with require "lsp_signature".on_attach() in custom on_attach() function which is called by every language server I have set up.

@ray-x
Copy link
Owner

ray-x commented Mar 10, 2021

Hi, @cloggier Can you send me your minium vimrc, hopefully, 1 or 2 files so I can reproduce your issue?

@talbergs
Copy link

Does not work for me also. Is it because I use compe?

@talbergs
Copy link

I may add this info - language server seems to provide this functionality.

  use {'neovim/nvim-lspconfig'}
  require'lspconfig'.intelephense.setup{
    on_attach = function(client, bufnr)
      print(vim.inspect(client.resolved_capabilities))
    end
  }

Outputs:

{
  call_hierarchy = false,
  code_action = false,
  code_lens = false,
  code_lens_resolve = false,
  completion = true,
  declaration = false,
  document_formatting = true,
  document_highlight = true,
  document_range_formatting = true,
  document_symbol = true,
  execute_command = false,
  find_references = true,
  goto_definition = true,
  hover = true,
  implementation = false,
  rename = false,
  signature_help = true,
  signature_help_trigger_characters = { "(", "," },
  text_document_did_change = 2,
  text_document_open_close = true,
  text_document_save = true,
  text_document_save_include_text = false,
  text_document_will_save = false,
  text_document_will_save_wait_until = false,
  type_definition = false,
  workspace_folder_properties = {
    changeNotifications = true,
    supported = true
  },
  workspace_symbol = true
}

@horseinthesky
Copy link

Hi.
Tried with pyright and pyls; both give me

Error executing vim.schedule lua callback: ...einthesky/.local/share/nvim/runtime/lua/vim/lsp/util.lua:946: Failed to switch to window 1006

when open the bracket.

This is my config;

local on_attach = function(client, _)
  require "completion".on_attach(client)
  require "lsp_signature".on_attach(client)

  utils.opt("omnifunc", "v:lua.vim.lsp.omnifunc")

  local lsp_keymappings = {
    {"n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>"},
    {"n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>"},
    {"n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>"},
    {"n", "<leader>f", "<cmd>lua vim.lsp.buf.formatting()<CR>"},
    {"n", "<leader>td", "<cmd>lua vim.lsp.buf.type_definition()<CR>"},
    {"n", "<leader>rf", "<cmd>lua vim.lsp.buf.references()<CR>"},
    {"n", "<leader>ll", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>"},
    -- Use <Tab> and <S-Tab> to navigate through popup menu
    {"i", "<Tab>", 'pumvisible() ? "\\<C-n>" : "\\<Tab>"', {expr = true}},
    {"i", "<S-Tab>", 'pumvisible() ? "\\<C-p>" : "\\<Tab>"', {expr = true}}
  }

  for _, map in ipairs(lsp_keymappings) do
    local mode, lhs, rhs, opts = unpack(map)
    utils.map(mode, lhs, rhs, opts)
  end

  -- Format on save
  if client.resolved_capabilities.document_formatting then
    vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.formatting()]]
  end

  -- Document highlight
  if client.resolved_capabilities.document_highlight then
    vim.api.nvim_exec(
      [[
        hi LspReferenceRead cterm=bold ctermbg=239 guibg=#504945
        hi LspReferenceText cterm=bold ctermbg=239 guibg=#504945
        hi LspReferenceWrite cterm=bold ctermbg=243 guibg=#7c6f64
        augroup lsp_document_highlight
          autocmd! * <buffer>
          autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
          autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
        augroup END
      ]],
      false
    )
  end
end

lspconfig.pyright.setup {
  on_attach = on_attach
}

@ray-x
Copy link
Owner

ray-x commented Mar 30, 2021

I may add this info - language server seems to provide this functionality.

  use {'neovim/nvim-lspconfig'}
  require'lspconfig'.intelephense.setup{
    on_attach = function(client, bufnr)
      print(vim.inspect(client.resolved_capabilities))
    end
  }

Outputs:

{
  call_hierarchy = false,
  code_action = false,
  code_lens = false,
  code_lens_resolve = false,
  completion = true,
  declaration = false,
  document_formatting = true,
  document_highlight = true,
  document_range_formatting = true,
  document_symbol = true,
  execute_command = false,
  find_references = true,
  goto_definition = true,
  hover = true,
  implementation = false,
  rename = false,
  signature_help = true,
  signature_help_trigger_characters = { "(", "," },
  text_document_did_change = 2,
  text_document_open_close = true,
  text_document_save = true,
  text_document_save_include_text = false,
  text_document_will_save = false,
  text_document_will_save_wait_until = false,
  type_definition = false,
  workspace_folder_properties = {
    changeNotifications = true,
    supported = true
  },
  workspace_symbol = true
}

@talbergs
In fact, I could not reproduce the issue. Here is my PHP lsp setup with compe

lua <<EOF
vim.cmd [[packadd packer.nvim]]
require('packer').startup(function()
use {
"wbthomason/packer.nvim",
"neovim/nvim-lspconfig",
"hrsh7th/nvim-compe",
"ray-x/lsp_signature.nvim"
}
end)

local lspconfig = require('lspconfig')

require'compe'.setup {
  enabled = true;
  autocomplete = true;
  debug = false;
  min_length = 1;
  preselect = 'enable';
  throttle_time = 80;
  source_timeout = 200;
  incomplete_delay = 400;
  max_abbr_width = 100;
  max_kind_width = 100;
  max_menu_width = 100;
  documentation = true;

  source = {
    nvim_lsp = true;
    vsnip = true;
  };
}

require "lsp_signature".on_attach()

require('lspconfig').intelephense.setup{
}

EOF

let g:min_load = 1

Screen Shot 2021-03-30 at 6 38 59 pm

One thing, writeMsg() does not have a signature as there ar no arguments .

@ray-x
Copy link
Owner

ray-x commented Mar 30, 2021

Hi.
Tried with pyright and pyls; both give me

Error executing vim.schedule lua callback: ...einthesky/.local/share/nvim/runtime/lua/vim/lsp/util.lua:946: Failed to switch to window 1006

when open the bracket.

This is my config;

local on_attach = function(client, _)
  require "completion".on_attach(client)
  require "lsp_signature".on_attach(client)

  utils.opt("omnifunc", "v:lua.vim.lsp.omnifunc")

  local lsp_keymappings = {
    {"n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>"},
    {"n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>"},
    {"n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>"},
    {"n", "<leader>f", "<cmd>lua vim.lsp.buf.formatting()<CR>"},
    {"n", "<leader>td", "<cmd>lua vim.lsp.buf.type_definition()<CR>"},
    {"n", "<leader>rf", "<cmd>lua vim.lsp.buf.references()<CR>"},
    {"n", "<leader>ll", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>"},
    -- Use <Tab> and <S-Tab> to navigate through popup menu
    {"i", "<Tab>", 'pumvisible() ? "\\<C-n>" : "\\<Tab>"', {expr = true}},
    {"i", "<S-Tab>", 'pumvisible() ? "\\<C-p>" : "\\<Tab>"', {expr = true}}
  }

  for _, map in ipairs(lsp_keymappings) do
    local mode, lhs, rhs, opts = unpack(map)
    utils.map(mode, lhs, rhs, opts)
  end

  -- Format on save
  if client.resolved_capabilities.document_formatting then
    vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.formatting()]]
  end

  -- Document highlight
  if client.resolved_capabilities.document_highlight then
    vim.api.nvim_exec(
      [[
        hi LspReferenceRead cterm=bold ctermbg=239 guibg=#504945
        hi LspReferenceText cterm=bold ctermbg=239 guibg=#504945
        hi LspReferenceWrite cterm=bold ctermbg=243 guibg=#7c6f64
        augroup lsp_document_highlight
          autocmd! * <buffer>
          autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
          autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
        augroup END
      ]],
      false
    )
  end
end

lspconfig.pyright.setup {
  on_attach = on_attach
}

@horseinthesky Should be fixed in the new version. Thanks for reporting.

@ray-x ray-x self-assigned this Mar 30, 2021
@talbergs
Copy link

Thank you @ray-x !
This is the change I had to do, to get this plugin working.

 use {'ray-x/lsp_signature.nvim',
   config = function()
-    require "lsp_signature".on_attach()
   end
 }
+require "lsp_signature".on_attach()

@gegoune
Copy link
Author

gegoune commented Mar 31, 2021

That still does not solve the issue for me though, I am calling that function from my custom on_attach function from lsp initialisation.

@ray-x
Copy link
Owner

ray-x commented Mar 31, 2021

Thanks for the feedback.
I think the packer lazy loading might prevent the on_attach be called. And as @cloggier suggested. attach the plugin in lsp client attach func would do the trick

local golang_setup = {
  on_attach = function(client, bufnr)
    if lsp_status ~= nil then
      lsp_status.on_attach(client, bufnr)
    end
    require "lsp_signature".on_attach()  -- Note: add in lsp client on-attach
    diagnostic_map(bufnr),
    ...
  end,
  ...
}

I updated the README.md as well

@gegoune
Copy link
Author

gegoune commented Apr 1, 2021

@ray-x Apologies if I wasn't clear enough. It does not work for me still, even with require "lsp_signature".on_attach() in on_attach function.

@ray-x
Copy link
Owner

ray-x commented Apr 1, 2021

In that case, I will leave the issue open ATM and I will wait on more info regarding how to reproduce the issue.

@miladabc
Copy link

miladabc commented Apr 1, 2021

Here is a minimum config that does not work for me:

call plug#begin('~/.config/nvim/plugged')

Plug 'neovim/nvim-lspconfig'
Plug 'ray-x/lsp_signature.nvim'

call plug#end()

lua require'lspconfig'.tsserver.setup{}
lua require'lsp_signature'.on_attach()

Although running :lua vim.lsp.buf.signature_help() and :lua require'lsp_signature'.signature() commands manually, shows the signature help pop up.
Neovim info:

NVIM v0.5.0-dev+f89bfa686
Build type: Release
LuaJIT 2.1.0-beta3

@ray-x
Copy link
Owner

ray-x commented Apr 2, 2021

@Milad-abbasi
Can not reproduce.
I am suspect if the lsp server started or not in your case.
The default tsserver require package.json or a tsconfig.json in your project root, otherwise it will not start and thus the signature will not work.

Screen Shot 2021-04-02 at 8 04 41 pm

@miladabc
Copy link

miladabc commented Apr 2, 2021

@ray-x
Yes it is started, it shows diagnostic texts.

@ray-x
Copy link
Owner

ray-x commented Apr 2, 2021

@Milad-abbasi I can not reproduce with your minimum vimrc. One thing not sure about is I am using Mac+Kitty, may it affect the sequence of initilization.

Can you check adjust your vimrc like this:

lua <<EOF
local nvim_lsp = require('lspconfig')

require'lspconfig'.tsserver.setup{
  on_attach = function(client)
    require'lsp_signature'.on_attach()
  end
}

EOF

@miladabc
Copy link

miladabc commented Apr 2, 2021

@ray-x
It now works🤘

@gegoune
Copy link
Author

gegoune commented Apr 16, 2021

I think I just have found a culprit. I had stylelint-lsp and efm-langserver also enabled and attached to the buffer. They both were returning

{
  signature_help = false,
  signature_help_trigger_characters = {},
}

(amongst other capabilities).

After disabling them and leaving only sumneko's lua lsp or tsserver active for buffer I do get signature hints.

@ray-x
Copy link
Owner

ray-x commented Apr 26, 2021

I thought the issue was fixed last week.

Can you send the minimum vimrc to reproduce this issue?
Also would be great to dump the info by running:

:lua print(vim.inspect(vim.lsp.buf_get_clients(0)))
and post the log would be helpful.

@andersevenrud
Copy link

andersevenrud commented Apr 26, 2021

Here you go. I've extracted the minimal amount of code from my setup to reproduce this (configured for node project with typescript and eslint). Once I comment out the diagnosticsls section it all works as expected.

call plug#begin()
  Plug 'neovim/nvim-lspconfig'
  Plug 'ray-x/lsp_signature.nvim'
call plug#end()

lua <<EOF
require'lspconfig'.tsserver.setup{}
require'lspconfig'.diagnosticls.setup{
    root_dir = require'lspconfig'.util.root_pattern('package.json'),
    filetypes = {
        'javascript',
        'javascriptreact',
        'typescript',
        'typescriptreact'
    },
    init_options = {
        linters = {
            eslint = {
                command = 'node_modules/.bin/eslint',
                rootPatterns = { 'package.json' },
                debounce = 100,
                args = { '--stdin', '--stdin-filename', '%filepath', '--format', 'json' },
                sourceName = 'eslint',
                parseJson = {
                    errorsRoot = '[0].messages',
                    line = 'line',
                    column = 'column',
                    endLine = 'endLine',
                    endColumn = 'endColumn',
                    message = '[eslint] ${message} [${ruleId}]',
                    security = 'severity'
                },
                securities = {
                    [1] = 'error',
                    [2] = 'warning'
                },
                requiredFiles = {
                    '.eslintrc',
                    'package.json'
                }
            },
        },
        filetypes = {
            javascript = 'eslint',
            javascriptreact = 'eslint',
            typescript = 'eslint',
            typescriptreact = 'eslint',
        }
    }
}
require'lsp_signature'.on_attach()
EOF

And here's the log you requested: buf_get_clients.txt

@andersevenrud
Copy link

I suspect this has something to do with how lsp_signature is displayed and how diagnostics is rendered in the UI. Might be a case of some internal neovim rendering action that just hides the signature help quickly so it looks like it's not working 🤔 I haven't really dug deep into this, so I might be way off on this, hehe.

@ray-x
Copy link
Owner

ray-x commented Apr 26, 2021

I am trying to fix your issue. But seems the latest neovim lsp signature for ts/js is broken.
So if things still working(after remove diagnositcls), please do not update your neovim and update lsp_signature see if I fixed the issue.
An code update was add. I think diagnositcls introduce an empty client and caused some trouble to launch the plugin. I can see from the log after code fix, the plugin was triggered. But as upstream broken, I can not fully verify.

@andersevenrud
Copy link

That seems to work @ray-x 👍 . Did your change also make it so the signature text no longer wraps ? I can't remember that being an issue before...but maybe it's just bad memory.

@ray-x
Copy link
Owner

ray-x commented Apr 26, 2021

It is great the plugin works for you. I did not change the wrap setup yesterday. And it seems to be wrap correct on my side. In fact, the plugin does not even has a wrap setup in the backend.

@andersevenrud
Copy link

Okay mr @ray-x . Then everything is solved! Thank you for fast response and fast fix :)

@argapost
Copy link

It works for me in lua but it doesn't work for python with pyright-ls.

This is the output of inspect client:

messages
  call_hierarchy = true,
  code_action = {
    codeActionKinds = { "quickfix", "source.organizeImports" },
    workDoneProgress = true
  },
  code_lens = false,
  code_lens_resolve = false,
  completion = true,
  declaration = false,
  document_formatting = false,
  document_highlight = {
    workDoneProgress = true
  },
  document_range_formatting = false,
  document_symbol = {
    workDoneProgress = true
  },
  execute_command = true,
  find_references = {
    workDoneProgress = true
  },
  goto_definition = {
    workDoneProgress = true
  },
  hover = {
    workDoneProgress = true
  },
  implementation = false,
  rename = true,
  signature_help = true,
  signature_help_trigger_characters = { "(", ",", ")" },
  text_document_did_change = 2,
  text_document_open_close = true,
  text_document_save = true,
  text_document_save_include_text = false,
  text_document_will_save = false,
  text_document_will_save_wait_until = false,
  type_definition = false,
  workspace_folder_properties = {
    changeNotifications = false,
    supported = false
  },
  workspace_symbol = {
    workDoneProgress = true
  }
}

This is my pyright setup

require'lspconfig'.pyright.setup {
    cmd = {DATA_PATH .. "/lspinstall/python/node_modules/.bin/pyright-langserver", "--stdio"},
    on_attach = function(client, bufnr)
        require"lsp_signature".on_attach()
        print(vim.inspect(client.resolved_capabilities))
    end
}

I had also efm but I disabled it as I saw in the comments above.

The :lua.vim.buf.signature_help() works but the :lua require'lsp_signature'.signature() does not.

Any ideas? Thank you in advance

@ray-x
Copy link
Owner

ray-x commented Apr 27, 2021

This issue was caused by pyright cap does not support hover. However, the signature help can display correctly. So I remove the hover check and hope it will work for you

@argapost
Copy link

Yeah, it seems to work now! Thanks for the quick fix!

@argapost
Copy link

Sometimes when I type fast in python I get the following

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp/util.lua:1022: Failed to switch to window 1065

I guess it has something to do with the changing focus between the hover window of the signature help and the main window.

@ray-x
Copy link
Owner

ray-x commented Apr 28, 2021

This issue happen to me as well this week after I update my nvim nightly as well. I think the upstream has an bug when preview closed but not notify neovim.

@Chaitanyabsprip
Copy link

After very quick test it seems like it works now, thanks a lot!

Hey, I couldn't follow what fixed your issue, I am having a similar setup as yours and I am running efm + sumeko_lua too. Can you please clarify what helped you?

@ray-x
Copy link
Owner

ray-x commented Apr 28, 2021

I have never tested efm. Could you please run and share the result of.
lua print(vim.inspect(vim.lsp.buf_get_clients(0)))
After the lsp attached?
efm does not have signature help. only sumeko did. The issue might be some value was override

@lourenci
Copy link

lourenci commented Apr 28, 2021

I could get it working when I provide the config on on_attach event of each lsp. Is there some way to do this in a general way? I don't want to repeat the configuration for each lsp.

// This is working
local lsp_signature = require"lsp_signature"

lspconfig.tsserver.setup{
  on_attach = function()
      lsp_signature.on_attach()
  end
}

lspconfig.gopls.setup{
  on_attach = function()
      lsp_signature.on_attach()
  end
}

@ray-x
Copy link
Owner

ray-x commented Apr 28, 2021

I think you can do something like this:

https://github.com/ray-x/navigator.lua/blob/4b4097e35c0e59013a9dfbaa749eef7590d4c3e3/lua/navigator/lspclient/clients.lua#L197-L222

@seblj
Copy link

seblj commented Apr 28, 2021

It does not seem to work if I don't open a buffer directly. Let's say I have a file test.c (Cursor is straight line character '|' )

int test(int a, int b){
    return a + b;
}

int main(){
    test(|
}

If I am inside the same folder and type nvim test.c, I get signature help. However if I open an empty buffer, and then :e test.c I don't get signature help

@ray-x
Copy link
Owner

ray-x commented Apr 28, 2021

@seblj
This is the same issue saw by lourenci. In some cases, the plugin has to initiate inside on_attach() of your lsp config. e.g.

lspconfig.gopls.setup{
  on_attach = function()
      lsp_signature.on_attach()
  end
}

Or you can refer to

https://github.com/ray-x/navigator.lua/blob/4b4097e35c0e59013a9dfbaa749eef7590d4c3e3/lua/navigator/lspclient/clients.lua#L197-L222

Another solution is in you BufReadPre or FileReadPre auto event, run
lua require"lsp_signature".on_attach()

@seblj
Copy link

seblj commented Apr 28, 2021

Oh, my bad for not reading carefully enough! Thanks!

mjtorn added a commit to mjtorn/dotnvim that referenced this issue Jun 20, 2021
Looks like it only worked on named
files, which is why I thought it was
broken on this machine, because why
would I test all the things and catch
all the cases ;)

Now it seems to work with both named
files and files opened using Telescope.

ray-x/lsp_signature.nvim#1
@ayamir
Copy link

ayamir commented Jun 21, 2021

local servers = { "pyright", "rust_analyzer", "tsserver", "gopls", "clangd" }
for _, lsp in ipairs(servers) do
	nvim_lsp[lsp].setup {
		on_attach = function()
		require"lsp_signature".on_attach({
		bind = false,
		use_lspsaga = true,
		floating_window = true,
		fix_pos = true,
		hint_enable = true,
		hi_parameter = "Search",
		handler_opts = {
			"shadow"
			}
		})
                end
         }
end

This works for me. But it need sometime to start.
image

@ray-x
Copy link
Owner

ray-x commented Jun 21, 2021

for functions defined in the common lib/system package. LSP might be slow in responding to the signature request.

@levouh
Copy link

levouh commented Aug 8, 2021

Commenting in the event that someone else comes across this. My config makes heavy use of packer.nvim, but I'm still calling require("lsp_signature").on_attach() inside of the on_attach keyword of require("lspconfig").server.setup({ ... }). Things weren't working for me, and as I've found is usually the problem, it is solved by wrapping the call to require("lsp_signature").on_attach() in a :h vim.schedule call. So something like:

local function my_on_attach(client)
  vim.schedule(function()
    require("lsp_signature").on_attach()
  end)
  
  ...
end

require("lspconfig").clangd.setup({
  on_attach = my_on_attach,
})

@ray-x
Copy link
Owner

ray-x commented Aug 8, 2021

You should be able to use require("lsp_signature").setup() as well. It calls start_client provided by neovim.
One reason on_attach() may not work is that this function needs to be called for each buffer opened by neovim.

@Mte90
Copy link

Mte90 commented Sep 3, 2021

It is not happening anymore.
Maybe some of the plugins I am using are changed.
Who knows.

@JustCoderdev
Copy link

I have the same problem, even after calling require("lsp_signature").on_attach() in the lsp in the on_attach method.
But apparently it only happens in buffers opened automatically with the session file (nvim -S session.vim), once i open a new buffer it works as expected

@Salmondx
Copy link

I'm using LunarVim with lazy plugin manager and recommended plugin config from docs was working only once on first buffer/file that I opened.
Here is the default config:

{
  "ray-x/lsp_signature.nvim",
  event = "BufRead",
  config = function() require"lsp_signature".on_attach() end,
},

Looks like BufRead event is being called only once. After trying different events I just gave up and created autocommand that activates on every filetype and plugin started to work:

lvim.autocommands = {
  {
    "BufEnter",
    {
      pattern = { "*" },
      callback = function() require"lsp_signature".on_attach() end,
    }
  }
}

Probably not the most correct workaround but at least it works.

@ray-x
Copy link
Owner

ray-x commented May 16, 2024

For lazy.nvim, maybe something like

{
  "ray-x/lsp_signature.nvim",
  envent =  "LspAttach",
  cfg = {},
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests