fix cmp bindings, format on save
This commit is contained in:
parent
ff529bc372
commit
be5e044f83
1 changed files with 68 additions and 53 deletions
|
@ -1,11 +1,8 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
{ pkgs, ... }: {
|
||||
programs.nixvim = {
|
||||
enable = true;
|
||||
|
||||
globals = {
|
||||
mapleader = " ";
|
||||
};
|
||||
globals = { mapleader = " "; };
|
||||
|
||||
opts = {
|
||||
number = true;
|
||||
|
@ -115,11 +112,16 @@
|
|||
}
|
||||
];
|
||||
|
||||
extraPlugins = with pkgs.vimPlugins; [
|
||||
vim-abolish
|
||||
nerdtree
|
||||
vim-rhubarb
|
||||
];
|
||||
autoGroups = { format_on_save = { clear = true; }; };
|
||||
|
||||
autoCmd = [{
|
||||
event = "BufWritePre";
|
||||
group = "format_on_save";
|
||||
pattern = "*";
|
||||
command = "lua vim.lsp.buf.format()";
|
||||
}];
|
||||
|
||||
extraPlugins = with pkgs.vimPlugins; [ vim-abolish nerdtree vim-rhubarb ];
|
||||
|
||||
plugins.commentary.enable = true;
|
||||
plugins.repeat.enable = true;
|
||||
|
@ -162,6 +164,21 @@
|
|||
tailwindcss.enable = true;
|
||||
terraform_lsp.enable = true;
|
||||
};
|
||||
keymaps.lspBuf = {
|
||||
gd = "definition";
|
||||
gi = "implementation";
|
||||
gr = "references";
|
||||
};
|
||||
};
|
||||
|
||||
plugins.none-ls = {
|
||||
enable = true;
|
||||
sources.formatting = {
|
||||
mix.enable = true;
|
||||
nixfmt.enable = true;
|
||||
prettier.enable = true;
|
||||
stylua.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
plugins.telescope.enable = true;
|
||||
|
@ -172,42 +189,40 @@
|
|||
settings = {
|
||||
sources = [
|
||||
{ name = "nvim_lsp"; }
|
||||
{ name = "snippy"; }
|
||||
{ name = "luasnip"; }
|
||||
{ name = "path"; }
|
||||
{ name = "buffer"; }
|
||||
];
|
||||
mappings = {
|
||||
"<C-n>" = ''
|
||||
function(fallback) do
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert })
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end
|
||||
'';
|
||||
"<C-p>" = ''
|
||||
function(fallback) do
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Insert })
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end
|
||||
'';
|
||||
"<CR>" = ''
|
||||
function(fallback)
|
||||
mapping = {
|
||||
"<C-n>" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})";
|
||||
"<C-p>" = "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})";
|
||||
"<Tab>" = ''
|
||||
cmp.mapping(function(fallback)
|
||||
local luasnip = require('luasnip')
|
||||
if cmp.visible() then
|
||||
cmp.confirm({ select = true })
|
||||
elseif luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end
|
||||
end, {'i', 's'})
|
||||
'';
|
||||
"<S-Tab>" = ''
|
||||
cmp.mapping(function(fallback)
|
||||
local luasnip = require('luasnip')
|
||||
if luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {'i', 's'})
|
||||
'';
|
||||
"<CR>" = "cmp.mapping.confirm({ select = true })";
|
||||
};
|
||||
snippet.expand = ''
|
||||
function(args)
|
||||
require('snippy').expand_snippet(args.body)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end
|
||||
'';
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue