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 = {
|
programs.nixvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
globals = {
|
globals = { mapleader = " "; };
|
||||||
mapleader = " ";
|
|
||||||
};
|
|
||||||
|
|
||||||
opts = {
|
opts = {
|
||||||
number = true;
|
number = true;
|
||||||
|
@ -115,11 +112,16 @@
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
extraPlugins = with pkgs.vimPlugins; [
|
autoGroups = { format_on_save = { clear = true; }; };
|
||||||
vim-abolish
|
|
||||||
nerdtree
|
autoCmd = [{
|
||||||
vim-rhubarb
|
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.commentary.enable = true;
|
||||||
plugins.repeat.enable = true;
|
plugins.repeat.enable = true;
|
||||||
|
@ -162,6 +164,21 @@
|
||||||
tailwindcss.enable = true;
|
tailwindcss.enable = true;
|
||||||
terraform_lsp.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;
|
plugins.telescope.enable = true;
|
||||||
|
@ -172,42 +189,40 @@
|
||||||
settings = {
|
settings = {
|
||||||
sources = [
|
sources = [
|
||||||
{ name = "nvim_lsp"; }
|
{ name = "nvim_lsp"; }
|
||||||
{ name = "snippy"; }
|
{ name = "luasnip"; }
|
||||||
{ name = "path"; }
|
{ name = "path"; }
|
||||||
{ name = "buffer"; }
|
{ name = "buffer"; }
|
||||||
];
|
];
|
||||||
mappings = {
|
mapping = {
|
||||||
"<C-n>" = ''
|
"<C-n>" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})";
|
||||||
function(fallback) do
|
"<C-p>" = "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})";
|
||||||
if cmp.visible() then
|
"<Tab>" = ''
|
||||||
cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert })
|
cmp.mapping(function(fallback)
|
||||||
else
|
local luasnip = require('luasnip')
|
||||||
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)
|
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.confirm({ select = true })
|
cmp.confirm({ select = true })
|
||||||
|
elseif luasnip.expand_or_locally_jumpable() then
|
||||||
|
luasnip.expand_or_jump()
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
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 = ''
|
snippet.expand = ''
|
||||||
function(args)
|
function(args)
|
||||||
require('snippy').expand_snippet(args.body)
|
require('luasnip').lsp_expand(args.body)
|
||||||
end
|
end
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue