nixvim: add default tab behavior

This commit is contained in:
Anthony Rodriguez 2024-09-23 13:48:11 +02:00
parent 2fdfe072c2
commit e66373dda6
Signed by: nezia
GPG key ID: EE3BE97C040A86CE
2 changed files with 82 additions and 72 deletions

View file

@ -19,7 +19,6 @@
globals.mapleader = " "; globals.mapleader = " ";
opts = { opts = {
smartindent = false;
relativenumber = true; relativenumber = true;
clipboard = "unnamedplus"; clipboard = "unnamedplus";
}; };

View file

@ -1,6 +1,13 @@
{ ... }: { ... }:
{ {
programs.nixvim = { programs.nixvim = {
opts = {
tabstop = 4;
shiftwidth = 4;
softtabstop = 0;
expandtab = true;
smartindent = true;
};
plugins = { plugins = {
treesitter = { treesitter = {
enable = true; enable = true;
@ -11,9 +18,7 @@
custom_captures = { }; custom_captures = { };
enable = true; enable = true;
}; };
indent = { indent.enable = false;
enable = true;
};
folding = true; folding = true;
parser_install_dir = { parser_install_dir = {
__raw = "vim.fs.joinpath(vim.fn.stdpath('data'), 'treesitter')"; __raw = "vim.fs.joinpath(vim.fn.stdpath('data'), 'treesitter')";
@ -37,14 +42,14 @@
indent-blankline = { indent-blankline = {
enable = true; enable = true;
settings = settings =
{ {
exclude = { exclude = {
buftypes = [ buftypes = [
"terminal" "terminal"
"quickfix" "quickfix"
]; ];
filetypes = [ filetypes = [
"" ""
"checkhealth" "checkhealth"
"help" "help"
"lspinfo" "lspinfo"
@ -52,17 +57,17 @@
"TelescopePrompt" "TelescopePrompt"
"TelescopeResults" "TelescopeResults"
"yaml" "yaml"
]; ];
};
indent = {
char = "";
};
scope = {
show_end = false;
show_exact_scope = true;
show_start = false;
};
}; };
indent = {
char = "";
};
scope = {
show_end = false;
show_exact_scope = true;
show_start = false;
};
};
}; };
lsp = { lsp = {
enable = true; enable = true;
@ -70,7 +75,13 @@
gopls.enable = true; gopls.enable = true;
nixd.enable = true; nixd.enable = true;
lua-ls.enable = true; lua-ls.enable = true;
clangd.enable = true; clangd = {
enable = true;
cmd = [
"clangd"
"--fallback-style=webkit"
];
};
}; };
keymaps = { keymaps = {
lspBuf = { lspBuf = {
@ -89,34 +100,34 @@
}; };
}; };
extra = [ extra = [
{ {
action = "<CMD>LspStop<Enter>"; action = "<CMD>LspStop<Enter>";
key = "<leader>lx"; key = "<leader>lx";
options = { options = {
desc = "Stop LSP"; desc = "Stop LSP";
}; };
} }
{ {
action = "<CMD>LspStart<Enter>"; action = "<CMD>LspStart<Enter>";
key = "<leader>ls"; key = "<leader>ls";
options = { options = {
desc = "Start LSP"; desc = "Start LSP";
}; };
} }
{ {
action = "<CMD>LspRestart<Enter>"; action = "<CMD>LspRestart<Enter>";
key = "<leader>lr"; key = "<leader>lr";
options = { options = {
desc = "Restart LSP"; desc = "Restart LSP";
}; };
} }
{ {
action = "<CMD>Telescope lsp_definitions<Enter>"; action = "<CMD>Telescope lsp_definitions<Enter>";
key = "gd"; key = "gd";
options = { options = {
desc = "Go to definitions"; desc = "Go to definitions";
}; };
} }
]; ];
}; };
postConfig = '' postConfig = ''
@ -139,30 +150,30 @@
"<CR>" = "cmp.mapping.confirm({ select = true })"; "<CR>" = "cmp.mapping.confirm({ select = true })";
"<S-Tab>" = '' "<S-Tab>" = ''
cmp.mapping(function (fallback) cmp.mapping(function (fallback)
local luasnip = require('luasnip') local luasnip = require('luasnip')
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif luasnip.jumpable(-1) then elseif luasnip.jumpable(-1) then
luasnip.jump(-1) luasnip.jump(-1)
else else
fallback() fallback()
end end
end, {'i', 's'}) end, {'i', 's'})
''; '';
"<Tab>" = '' "<Tab>" = ''
cmp.mapping(function (fallback) cmp.mapping(function (fallback)
local luasnip = require('luasnip') local luasnip = require('luasnip')
if luasnip.expandable() then if luasnip.expandable() then
luasnip.expand() luasnip.expand()
elseif cmp.visible() then elseif cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
elseif luasnip.jumpable(1) then elseif luasnip.jumpable(1) then
luasnip.jump(1) luasnip.jump(1)
else else
fallback() fallback()
end end
end, {'i', 's'}) end, {'i', 's'})
''; '';
}; };
sources = sources =