init.lua icon indicating copy to clipboard operation
init.lua copied to clipboard

[help] How do I select completion from lsp ?

Open fadhilsaheer opened this issue 1 year ago • 9 comments

Ik, I'm dumb, no need to say that again.

I'm from vscode, I've no idea how to use vim, I manage to set this up, lsp works fine, but cant i select from autocompletion ? pressing enter is creating a new line.., I'm from shit world (vscode), how does this work in chad world ?

fadhilsaheer avatar Apr 01 '23 02:04 fadhilsaheer

Press Enter or Ctrl + y can also do the same, Just pressing enter works for me , Check your lsp.lua file again

anon-marvin avatar Apr 01 '23 15:04 anon-marvin

I changed the mappings inside lsp.lua:

local cmp_mappings = lsp.defaults.cmp_mappings({
	['<C-k>'] = cmp.mapping.select_prev_item(cmp_select),
	['<C-j>'] = cmp.mapping.select_next_item(cmp_select),
	['<Tab>'] = cmp.mapping.select_next_item(cmp_select),	
    ['<Enter>'] = cmp.mapping.confirm({ select = true }),
	['<C-Space>'] = cmp.mapping.complete(),
})

With this I can go through the suggestions with tab or CTRL+j, go back up with CTRL+k, confirm with enter and toggle the suggestions with CTRL+space

domhel avatar Apr 01 '23 20:04 domhel

Compare with my config , https://github.com/anon-marvin/NeoChad/blob/main/after/plugin/lsp.lua

anon-marvin avatar Apr 01 '23 20:04 anon-marvin

Compare with my config , https://github.com/anon-marvin/NeoChad/blob/main/after/plugin/lsp.lua

Good idea. I have copied the tab part. But it threw an error. chatGPT fixed the error:

local has_words_before = function()
    local line_nr, col_nr = unpack(vim.api.nvim_win_get_cursor(0))
    local line = vim.api.nvim_buf_get_lines(0, line_nr - 1, line_nr, true)[1]
    return col_nr ~= 0 and line:sub(col_nr, col_nr):match("%s") == nil
end

domhel avatar Apr 01 '23 20:04 domhel

Press Enter or Ctrl + y can also do the same, Just pressing enter works for me , Check your lsp.lua file again

The enter key was working for me previously, but I recently did a fresh install of neovim and it stopped working. Also the lua snip is not showing up. I guess that's the issue with lsp-zero.

ShashwatAgrawal20 avatar May 20 '23 11:05 ShashwatAgrawal20

Press Enter or Ctrl + y can also do the same, Just pressing enter works for me , Check your lsp.lua file again

The enter key was working for me previously, but I recently did a fresh install of neovim and it stopped working. Also the lua snip is not showing up. I guess that's the issue with lsp-zero.

Try my config , git clone https://github.com/anon-marvin/NeoChad ~/.config/nvim

anon-marvin avatar May 20 '23 12:05 anon-marvin

Press Enter or Ctrl + y can also do the same, Just pressing enter works for me , Check your lsp.lua file again

The enter key was working for me previously, but I recently did a fresh install of neovim and it stopped working. Also the lua snip is not showing up. I guess that's the issue with lsp-zero.

Try my config , git clone https://github.com/anon-marvin/NeoChad ~/.config/nvim

It was working for me till today. Until I did the complete reinstallation removing cache and everything

ShashwatAgrawal20 avatar May 20 '23 12:05 ShashwatAgrawal20

Press Enter or Ctrl + y can also do the same, Just pressing enter works for me , Check your lsp.lua file again

The enter key was working for me previously, but I recently did a fresh install of neovim and it stopped working. Also the lua snip is not showing up. I guess that's the issue with lsp-zero.

Try my config , git clone https://github.com/anon-marvin/NeoChad ~/.config/nvim

It was working for me till today. Until I did the complete reinstallation removing cache and everything

Lsp-zero been causing issues to me , no removed it

anon-marvin avatar May 20 '23 13:05 anon-marvin

@anon-marvin I figured it out, you just have to put this line in your lsp.lua file

require('luasnip.loaders.from_vscode').lazy_load()

ShashwatAgrawal20 avatar May 20 '23 17:05 ShashwatAgrawal20