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

select_next_item() causing LSP crash #1917

Open
2 tasks done
SethGower opened this issue May 10, 2024 · 1 comment
Open
2 tasks done

select_next_item() causing LSP crash #1917

SethGower opened this issue May 10, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@SethGower
Copy link

FAQ

  • I have checked the FAQ and it didn't resolve my problem.

Announcement

Minimal reproducible full config

if has('vim_starting')
  set encoding=utf-8
endif
scriptencoding utf-8

if &compatible
  set nocompatible
endif

let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir .. '/plug.vim')
  execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end

execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-buffer'
Plug 'hrsh7th/cmp-nvim-lsp'
Plug 'hrsh7th/vim-vsnip'
Plug 'neovim/nvim-lspconfig'
call plug#end()
PlugInstall | quit

" Setup global configuration. More on configuration below.
lua << EOF
local cmp = require "cmp"
cmp.setup {
  snippet = {
    expand = function(args)
      vim.fn["vsnip#anonymous"](args.body)
    end,
  },

  mapping = {
    ['<CR>'] = cmp.mapping.confirm({ select = true }),
    ['<Tab>'] = cmp.mapping.select_next_item()
  },

  sources = cmp.config.sources({
    { name = "nvim_lsp" },
    -- { name = "buffer" },
  }),
}
EOF

lua << EOF
local capabilities = require('cmp_nvim_lsp').default_capabilities()

require'lspconfig'.vhdl_ls.setup {
  capabilities = capabilities,
}
EOF

Description

I am having an issue that I seem to have boiled down to when I select a completion candidate with cmp.mapping.select_next_item(). The LSP Server crashes when I do this (or select_prev_item() for that matter). Everything seems fine when I do just cmp.mapping.confirm{select = true}.

VHDL-LS/rust_hdl#300

Steps to reproduce

  • Have vhdl_ls installed with version v0.80
  • Open a VHDL file (see below for example)
  • Try to complete a signal or port name
  • Use tab to select the completion candidate

Expected behavior

It should just select the candidate as normal

Actual behavior

The LSP server crashes. I reported this originally over on the vhdl_ls repo, but they weren't able to reproduce in VSCode (neither was I). It doesn't always happen, I found a case where it doesn't happen, however given it doesn't happen at all in VSCode, I am not sure if it's the server or client (I'm including nvim-cmp in "the client").

Additional context

Example VHDL file to use. After the end process q_proc; line, if you do o_| where | is the cursor, and then hit <Tab> to select the next completion candidate, the LSP should crash.

Please see my various comments in the other issue for logs during this process (which were captured not using the minimal config, FYI).

library ieee;
    use ieee.std_logic_1164.all;
    use ieee.numeric_std.all;

entity test1 is
    port (
        i_clk  : in    std_logic;
        i_rstn : in    std_logic;
        i_d    : in    std_logic;
        o_q    : out   std_logic;
        o_qn   : out   std_logic
    );
end entity test1;

architecture behav of test1 is

begin

    o_q_proc : process (i_clk) is
    begin

        if rising_edge(i_clk) then
            if (i_rstn = '0') then
                o_q <= '0';
            else
                o_q <= i_d;
            end if;
        end if;

    end process o_q_proc;

end architecture behav;
@SethGower SethGower added the bug Something isn't working label May 10, 2024
@Chris44442
Copy link

I have the same issue. Strangely enough when I scroll through the auto complete list with the arrow keys, the LSP does not crash. With cmp.mapping.select_next_item() it crashes.

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

No branches or pull requests

3 participants