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

Signature help triggers after pressing , inside an object #41

Open
joshuali925 opened this issue Sep 24, 2023 · 1 comment
Open

Signature help triggers after pressing , inside an object #41

joshuali925 opened this issue Sep 24, 2023 · 1 comment

Comments

@joshuali925
Copy link

joshuali925 commented Sep 24, 2023

To reproduce use the following init.lua

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
    {
        "williamboman/mason.nvim",
        build = ":MasonUpdate",
        dependencies = { "williamboman/mason-lspconfig.nvim", "neovim/nvim-lspconfig" },
        config = function()
            require("mason").setup()
            require("mason-lspconfig").setup({ ensure_installed = { "tsserver" } })
            require("lspconfig").tsserver.setup({})
        end,
    },
    {
        "hrsh7th/nvim-cmp",
        dependencies = { "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lsp-signature-help" },
        opts = { sources = { { name = "nvim_lsp" }, { name = "nvim_lsp_signature_help" } } },
    },
})

vim.cmd.colorscheme("habamax")

then create a js file vim repro.js, wait for tsserver, then type:

Object.freeze({
        foo: 'bar',

see completion menu opens, suggesting o: T.
image

The problem is that

  1. I've configured the enter key to trigger completion, but in this case i want a new line. since the item is preselected, pressing enter will complete the item
  2. the suggestion is based on parameter of Object.freeze(o), it's no longer valid when cursor is inside the curly brackets

If it's not easy to fix, is there a way to configure entry_filter to not display suggestion in this case? maybe like this

                        entry_filter = function()
                            local col = vim.api.nvim_win_get_cursor(0)[2]
                            return vim.api.nvim_get_current_line():sub(col, col) ~= ","
                        end,

But wanted to see if there's a better way. Thanks

ramonbakker added a commit to ramonbakker/dotfiles that referenced this issue Apr 12, 2024
The automatic signature help selects items when it's not desired. See hrsh7th/cmp-nvim-lsp-signature-help#41.
@antoinemadec
Copy link

@joshuali925 regarding the "enter selects the arg name instead of adding a new line" problem, I had the same issue.

Here is how I fixed it: antoinemadec/dotfiles@6b4b700

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

2 participants