fix: nvim-cmp completion bugs

This commit is contained in:
Noah Masur 2022-07-13 02:15:00 +00:00
parent a22acac57d
commit 51c75e2874
7 changed files with 51 additions and 15 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
*.db
**/.direnv/**
result
.luarc.json

View File

@ -20,7 +20,9 @@ nixpkgs.lib.nixosSystem {
automountPath = "/mnt";
defaultUser = globals.user;
startMenuLaunchers = true;
wslConf.network.generateResolvConf = true;
wslConf.network.generateResolvConf = true; # Turn off if breaking VPN
interop.includePath =
false; # Including Windows PATH will slow down Neovim
};
}
../common.nix

View File

@ -13,7 +13,7 @@
if test "$argv[1]" = "offline"
set option "--option substitute false"
end
git -C ${config.dotfilesPath} add --all
git -C ${config.dotfilesPath} add --intent-to-add --all
commandline -r "darwin-rebuild switch $option --flake ${config.dotfilesPath}#macbook"
commandline --function execute
'';

View File

@ -13,6 +13,7 @@ M.packer = function(use)
use("hrsh7th/cmp-nvim-lua") --- Nvim lua api completion
use("saadparwaiz1/cmp_luasnip") --- Luasnip completion
use("lukas-reineke/cmp-rg") --- Ripgrep completion
use("rafamadriz/friendly-snippets") -- Lots of pre-generated snippets
-- Completion engine
use({
@ -20,6 +21,35 @@ M.packer = function(use)
requires = { "L3MON4D3/LuaSnip" },
config = function()
local cmp = require("cmp")
local kind_icons = {
Text = "",
Method = "m",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
}
cmp.setup({
-- Setup snippet completion
@ -31,9 +61,11 @@ M.packer = function(use)
-- Setup completion keybinds
mapping = {
["<C-n>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }),
["<C-p>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }),
["<C-d>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "c" }),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "c" }),
["<Esc>"] = function(fallback)
["<Esc>"] = function(_)
cmp.mapping({
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
@ -48,7 +80,7 @@ M.packer = function(use)
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
["<C-l>"] = cmp.mapping(function(fallback)
["<C-l>"] = cmp.mapping(function(_)
if require("luasnip").expand_or_jumpable() then
require("luasnip").expand_or_jump()
end
@ -72,8 +104,9 @@ M.packer = function(use)
-- Visual presentation
formatting = {
fields = { "abbr", "menu" },
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
vim_item.menu = ({
luasnip = "[Snippet]",
buffer = "[Buffer]",
@ -87,10 +120,10 @@ M.packer = function(use)
},
-- Docs
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
-- window = {
-- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(),
-- },
-- Extra features
experimental = {

View File

@ -24,7 +24,7 @@ M.packer = function(use)
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
globals = { "vim", "hs" },
},
},
},

View File

@ -49,11 +49,11 @@ M.packer = function(use)
},
})
-- Move buffers
vim.keymap.set("n", "L", ":BufferLineCycleNext<CR>")
vim.keymap.set("n", "H", ":BufferLineCyclePrev<CR>")
vim.keymap.set("n", "L", ":BufferLineCycleNext<CR>", { silent = true })
vim.keymap.set("n", "H", ":BufferLineCyclePrev<CR>", { silent = true })
-- Kill buffer
vim.keymap.set("n", "<Leader>x", " :Bdelete<CR>")
vim.keymap.set("n", "<Leader>x", " :Bdelete<CR>", { silent = true })
-- Shift buffers
-- vim.keymap.set("n", "<C-L>", ":BufferLineMoveNext<CR>")
@ -100,7 +100,7 @@ M.packer = function(use)
relativenumber = false,
},
})
vim.keymap.set("n", "<Leader>e", ":NvimTreeFindFileToggle<CR>")
vim.keymap.set("n", "<Leader>e", ":NvimTreeFindFileToggle<CR>", { silent = true })
end,
})

View File

@ -37,7 +37,7 @@
if test "$argv[1]" = "offline"
set option "--option substitute false"
end
git -C ${config.dotfilesPath} add --all
git -C ${config.dotfilesPath} add --intent-to-add --all
commandline -r "doas nixos-rebuild switch $option --flake ${config.dotfilesPath}"
commandline --function execute
'';