Use `cmp-nvim-lua` as `nvim-cmp` source for neovim Lua API
Things like vim.keymap.set were not autocompleting for me and I thought I heard @tjdevries mention that we should be able to type commands in our config without having to "wing it" unless I missed a later part of the video where this was added and removed, but I think it's very helpful for editing your config
https://github.com/hrsh7th/cmp-nvim-lua/tree/main
I can confirm that this used to work with the old kickstart before the last rewrite and that with this change it works again.
One more thing, the old kickstart also provided a detailed description of the selected item, for example:
vim.keymap.s
set(mode, lhs, rhs, opts) Function function
function keymap.set(mode: string|table,
lhs: string, rhs: string|function, opts:
table|nil)
──────────────────────────────
Adds a new |mapping|.
Examples:
-- Map to a Lua function:
vim.keymap.set('n', 'lhs', function()
print("real lua function") end)
Now it just says function without any details:
vim.keymap.s
set Function function
Any idea why, and how to improve that to match the old kickstart version?
Perhaps related: Completion is not complete...
Ok figured out the vim.keymap.set fix, here is a PR:
https://github.com/nvim-lua/kickstart.nvim/pull/754
@feoh : Hmm, with neodev change merged, this PR is not necessary, in fact now there are two completions offered, the first coming from cmp-nvim-lua: without parameters and without help and the second from neodev (actually nvim_lsp which neodev sets up), which has the parameters and help:
or at least the sources order should be changed like this:
diff --git a/init.lua b/init.lua
index fe25648..7c2cf87 100644
--- a/init.lua
+++ b/init.lua
@@ -704,8 +704,8 @@ require('lazy').setup({
end, { 'i', 's' }),
},
sources = {
- { name = 'nvim_lua' },
{ name = 'nvim_lsp' },
+ { name = 'nvim_lua' },
{ name = 'luasnip' },
{ name = 'path' },
},
So that the neodev set nvim_lsp takes precedence and it looks like this: