mirror of
https://github.com/nmasur/dotfiles
synced 2024-12-24 02:34:52 +00:00
fix: nvim-cmp completion bugs
This commit is contained in:
parent
a22acac57d
commit
51c75e2874
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@
|
||||
*.db
|
||||
**/.direnv/**
|
||||
result
|
||||
.luarc.json
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
'';
|
||||
|
@ -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 = {
|
||||
|
@ -24,7 +24,7 @@ M.packer = function(use)
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
globals = { "vim", "hs" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -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,
|
||||
})
|
||||
|
||||
|
@ -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
|
||||
'';
|
||||
|
Loading…
Reference in New Issue
Block a user