feat: add more plugins

nixos
Moritz Böhme 2024-09-01 22:05:20 +02:00
parent f1890f15be
commit 44bcf963b2
Signed by: moritz
GPG Key ID: 970C6E89EB0547A9
2 changed files with 307 additions and 249 deletions

View File

@ -22,12 +22,6 @@ in
]; ];
# programs.neovim = { # programs.neovim = {
# enable = true;
# package = inputs.neovim-nightly-overlay.packages.${pkgs.system}.default;
# vimAlias = true;
# vimdiffAlias = true;
# withNodeJs = true;
# withPython3 = true;
# extraPackages = with pkgs; # extraPackages = with pkgs;
# [ # [
# alejandra # alejandra
@ -49,263 +43,327 @@ in
# taplo # taplo
# yamllint # yamllint
# ]; # ];
# extraLuaConfig = readFile ./options.lua;
# lazy.enable = true;
# }; # };
programs.nixvim = { programs.nixvim = lib.mkMerge [
enable = true; {
package = inputs.neovim-nightly-overlay.packages.${pkgs.system}.default; enable = true;
vimAlias = true; package = inputs.neovim-nightly-overlay.packages.${pkgs.system}.default;
vimAlias = true;
colorschemes.catppuccin.enable = true; extraConfigLuaPre = readFile ./options.lua;
colorschemes.catppuccin.settings.flavour = "macchiato"; performance = {
byteCompileLua = {
plugins.lualine.enable = true; enable = true;
configs = true;
plugins.cmp.autoEnableSources = true; initLua = true;
plugins.cmp.enable = true; nvimRuntime = true;
plugins.cmp.settings.sources = [ plugins = true;
{ priority = 1; name = "async_path"; } };
{ priority = 1; name = "buffer"; } combinePlugins.enable = true;
{ priority = 2; name = "nvim_lsp"; } };
{ priority = 3; name = "nvim_lsp_signature_help"; } }
{ priority = 4; name = "luasnip"; } {
{ priority = 4; name = "vimtex"; } colorschemes.catppuccin = {
]; enable = true;
plugins.cmp.settings.mapping = { settings.flavour = "macchiato";
__raw = '' };
cmp.mapping.preset.insert({ }
['<C-b>'] = cmp.mapping.scroll_docs(-4), {
['<C-f>'] = cmp.mapping.scroll_docs(4), plugins.lualine.enable = true;
['<C-Space>'] = cmp.mapping.complete(), }
['<C-e>'] = cmp.mapping.abort(), {
['<CR>'] = cmp.mapping.confirm({ select = true }), plugins.cmp = {
["<Tab>"] = cmp.mapping(function(fallback) autoEnableSources = true;
if cmp.visible() then enable = true;
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select }) settings.sources = [
elseif require("luasnip").locally_jumpable(1) then { priority = 1; name = "async_path"; }
require("luasnip").jump(1) { priority = 1; name = "buffer"; }
else { priority = 2; name = "nvim_lsp"; }
fallback() { priority = 3; name = "nvim_lsp_signature_help"; }
end { priority = 4; name = "luasnip"; }
end, { "i", "s" }), { priority = 4; name = "vimtex"; }
["<S-Tab>"] = cmp.mapping(function(fallback) ];
if cmp.visible() then settings.mapping = {
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select }) __raw = ''
elseif require("luasnip").locally_jumpable(-1) then cmp.mapping.preset.insert({
require("luasnip").jump(-1) ['<C-b>'] = cmp.mapping.scroll_docs(-4),
else ['<C-f>'] = cmp.mapping.scroll_docs(4),
fallback() ['<C-Space>'] = cmp.mapping.complete(),
end ['<C-e>'] = cmp.mapping.abort(),
end, { "i", "s" }), ['<CR>'] = cmp.mapping.confirm({ select = true }),
["<C-n>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if require("luasnip").choice_active() then if cmp.visible() then
require("luasnip").change_choice(1) cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
elseif require("luasnip").locally_jumpable(1) then elseif require("luasnip").locally_jumpable(1) then
require("luasnip").jump(1) require("luasnip").jump(1)
else else
fallback() fallback()
end end
end, { "i", "s" }), end, { "i", "s" }),
["<C-p>"] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if require("luasnip").choice_active() then if cmp.visible() then
require("luasnip").change_choice(-1) cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select })
elseif require("luasnip").locally_jumpable(-1) then elseif require("luasnip").locally_jumpable(-1) then
require("luasnip").jump(-1) require("luasnip").jump(-1)
else else
fallback() fallback()
end end
end, { "i", "s" }), end, { "i", "s" }),
}) ["<C-n>"] = cmp.mapping(function(fallback)
''; if require("luasnip").choice_active() then
}; require("luasnip").change_choice(1)
elseif require("luasnip").locally_jumpable(1) then
plugins.luasnip.enable = true; require("luasnip").jump(1)
plugins.luasnip.settings = { else
history = true; fallback()
update_events = "TextChanged,TextChangedI"; end
delete_check_events = "TextChanged"; end, { "i", "s" }),
ext_opts.__raw = ''{ ["<C-p>"] = cmp.mapping(function(fallback)
if require("luasnip").choice_active() then
require("luasnip").change_choice(-1)
elseif require("luasnip").locally_jumpable(-1) then
require("luasnip").jump(-1)
else
fallback()
end
end, { "i", "s" }),
})
'';
};
};
}
{
plugins.luasnip = {
enable = true;
settings = {
history = true;
update_events = "TextChanged,TextChangedI";
delete_check_events = "TextChanged";
ext_opts.__raw = ''{
[require("luasnip.util.types").choiceNode] = { [require("luasnip.util.types").choiceNode] = {
active = { active = {
virt_text = { { "<--", "Error" } }, virt_text = { { "<--", "Error" } },
}, },
}, },
}''; }'';
ft_func.__raw = ''require("luasnip.extras.filetype_functions").from_pos_or_filetype''; ft_func.__raw = ''require("luasnip.extras.filetype_functions").from_pos_or_filetype'';
};
plugins.lsp.enable = true;
plugins.lsp.inlayHints = true;
plugins.lsp.servers.nil-ls.enable = true;
plugins.lsp.servers.nixd.enable = true;
plugins.lsp.servers.nixd.extraOptions.settings.nixd = {
nixpkgs = {
expr = "import <nixpkgs> { }";
};
options = {
nixos = {
expr = ''(builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations.nixos-desktop.options'';
};
"flake-parts" = {
expr = ''(builtins.getFlake ("git+file://" + toString ./.)).debug.options'';
};
"flake-parts2" = {
expr = ''(builtins.getFlake ("git+file://" + toString ./.)).currentSystem.options'';
}; };
}; };
}; }
plugins.lspsaga = { {
enable = true; plugins.lsp = {
codeAction.keys.quit = "<esc>";
lightbulb.virtualText = false;
};
keymapsOnEvents = {
LspAttach = [
{
key = "<leader>cc";
action = "<cmd>Lspsaga code_action<cr>";
options.desc = "Code Action";
options.buffer = true;
}
{
key = "gd";
action = "<cmd>Lspsaga goto_definition<cr>";
options.desc = "Goto Definition";
options.buffer = true;
}
{
key = "<leader>cr";
action = "<cmd>Lspsaga rename<cr>";
options.desc = "Rename";
options.buffer = true;
}
{
key = "K";
action = "<cmd>Lspsaga hover_doc<cr>";
options.desc = "Hover";
options.buffer = true;
}
];
};
plugins.nvim-ufo.enable = true;
plugins.treesitter = {
enable = true;
folding = true;
nixvimInjections = true;
settings.indent.enable = true;
settings.highlight.enable = true;
};
plugins.which-key.enable = true;
plugins.lastplace.enable = true;
plugins.comment.enable = true;
plugins.ts-context-commentstring.enable = true;
plugins.vimtex = {
enable = true;
settings.view_method = "zathura";
};
plugins.todo-comments.enable = true;
plugins.todo-comments.keymaps.todoTelescope.key = "<leader>fc";
plugins.conform-nvim.enable = true;
plugins.conform-nvim.settings.formatters_by_ft = {
"*" = [ "codespell" "trim_whitespace" ];
elixir = [ "mix" ];
gleam = [ "gleam" ];
go = [ "gofmt" ];
json = [ "jq" ];
lua = [ "stylua" ];
nix = [ [ "nixpkgs_fmt" "alejandra" ] ];
python = [ [ "ruff_fix" "isort" ] [ "ruff_format" "black" ] ];
rust = [ "rustfmt" ];
sh = [ "shfmt" ];
tex = [ "latexindent" ];
toml = [ "taplo" ];
yaml = [ "yamlfix" ];
};
keymaps = [
{ key = "<esc>"; action = "<cmd>noh<cr><esc>"; options.desc = "Escape and clear hlsearch"; mode = [ "i" "n" ]; }
];
opts.formatexpr = "v:lua.require'conform'.formatexpr()";
extraConfigLua = ''
vim.api.nvim_create_user_command("Format", function(opts)
require("conform").format({ formatters = opts.fargs })
end, {
nargs = "+",
complete = function()
local names = formatters_by_ft[vim.bo.filetype] or formatters_by_ft["_"] or {}
names = vim.list_extend(names, formatters_by_ft["*"] or {})
names = vim.tbl_flatten(names)
local formatters = vim.tbl_map(require("conform").get_formatter_info, names)
formatters = vim.tbl_filter(function(formatter)
return formatter.available
end, formatters)
return vim.tbl_map(function(formatter_info)
return formatter_info.name
end, formatters)
end,
})
'';
plugins.oil.enable = true;
plugins.telescope.enable = true;
plugins.telescope.extensions.fzf-native.enable = true;
plugins.telescope.keymaps = {
"<leader>ff" = {
action = "find_files";
options.desc = "Find files";
};
"<leader>fb" = {
action = "buffers";
options.desc = "Find buffers";
};
"<leader>fl" = {
action = "current_buffer_fuzzy_find";
options.desc = "Search lines";
};
"<leader>fg" = {
action = "live_grep";
options.desc = "Live grep";
};
"<leader>fh" = {
action = "help_tags";
options.desc = "Help tags";
};
"<leader>fr" = {
action = "oldfiles";
options.desc = "Recent files";
};
};
plugins.nvim-autopairs.enable = true;
plugins.surround.enable = true;
extraConfigLuaPre = readFile ./options.lua;
performance = {
byteCompileLua = {
enable = true; enable = true;
configs = true; inlayHints = true;
initLua = true; servers.nil-ls.enable = true;
nvimRuntime = true; servers.nixd.enable = true;
plugins = true; servers.nixd.extraOptions.settings.nixd = {
nixpkgs = {
expr = "import <nixpkgs> { }";
};
options = {
nixos = {
expr = ''(builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations.nixos-desktop.options'';
};
"flake-parts" = {
expr = ''(builtins.getFlake ("git+file://" + toString ./.)).debug.options'';
};
"flake-parts2" = {
expr = ''(builtins.getFlake ("git+file://" + toString ./.)).currentSystem.options'';
};
};
};
}; };
combinePlugins.enable = true; }
combinePlugins.standalonePlugins = [ {
plugins.lspsaga = {
enable = true;
codeAction.keys.quit = "<esc>";
lightbulb.virtualText = false;
};
keymapsOnEvents = {
LspAttach = [
{
key = "<leader>cc";
action = "<cmd>Lspsaga code_action<cr>";
options.desc = "Code Action";
options.buffer = true;
}
{
key = "gd";
action = "<cmd>Lspsaga goto_definition<cr>";
options.desc = "Goto Definition";
options.buffer = true;
}
{
key = "<leader>cr";
action = "<cmd>Lspsaga rename<cr>";
options.desc = "Rename";
options.buffer = true;
}
{
key = "K";
action = "<cmd>Lspsaga hover_doc<cr>";
options.desc = "Hover";
options.buffer = true;
}
];
};
}
{
plugins.nvim-ufo.enable = true;
}
{
plugins.treesitter = {
enable = true;
folding = true;
nixvimInjections = true;
settings.indent.enable = true;
settings.highlight.enable = true;
};
performance.combinePlugins.standalonePlugins = [
"nvim-treesitter" "nvim-treesitter"
];
}
{ plugins.which-key.enable = true; }
{ plugins.lastplace.enable = true; }
{ plugins.comment.enable = true; }
{ plugins.ts-context-commentstring.enable = true; }
{
plugins.vimtex = {
enable = true;
settings.view_method = "zathura";
};
}
{
plugins.todo-comments = {
enable = true;
keymaps.todoTelescope.key = "<leader>fc";
};
}
{
plugins.conform-nvim = {
enable = true;
settings.formatters_by_ft = {
"*" = [ "codespell" "trim_whitespace" ];
elixir = [ "mix" ];
gleam = [ "gleam" ];
go = [ "gofmt" ];
json = [ "jq" ];
lua = [ "stylua" ];
nix.__raw = ''{ "nixpkgs_fmt", "alejandra", stop_after_first=true }'';
python.__raw = ''
function(bufnr)
return { first("ruff_organize_imports", "isort"), first("ruff_format", "black")}
end
'';
rust = [ "rustfmt" ];
sh = [ "shfmt" ];
tex = [ "latexindent" ];
toml = [ "taplo" ];
yaml = [ "yamlfix" ];
};
};
opts.formatexpr = "v:lua.require'conform'.formatexpr()";
extraConfigLuaPre = ''
---@param bufnr integer
---@param ... string
---@return string
local function first(bufnr, ...)
local conform = require("conform")
for i = 1, select("#", ...) do
local formatter = select(i, ...)
if conform.get_formatter_info(formatter, bufnr).available then
return formatter
end
end
return select(1, ...)
end
vim.api.nvim_create_user_command("Format", function(opts)
require("conform").format({ formatters = opts.fargs })
end, {
nargs = "+",
complete = function()
local formatters_by_ft = require("conform").formatters_by_ft
local names = formatters_by_ft[vim.bo.filetype] or formatters_by_ft["_"] or {}
names = vim.list_extend(names, formatters_by_ft["*"] or {})
names = vim.tbl_flatten(names)
local formatters = vim.tbl_map(require("conform").get_formatter_info, names)
formatters = vim.tbl_filter(function(formatter)
return formatter.available
end, formatters)
return vim.tbl_map(function(formatter_info)
return formatter_info.name
end, formatters)
end,
})
'';
performance.combinePlugins.standalonePlugins = [
"conform.nvim" "conform.nvim"
]; ];
}; keymaps = [
}; { key = "<leader>cf"; action.__raw = ''function() require("conform").format() end''; options.desc = "Format current file"; }
];
}
{
keymaps = [
{ key = "<esc>"; action = "<cmd>noh<cr><esc>"; options.desc = "Escape and clear hlsearch"; mode = [ "i" "n" ]; }
];
}
{ plugins.oil.enable = true; }
{
plugins.telescope = {
enable = true;
extensions.fzf-native.enable = true;
keymaps = {
"<leader>ff" = {
action = "find_files";
options.desc = "Find files";
};
"<leader>fb" = {
action = "buffers";
options.desc = "Find buffers";
};
"<leader>fl" = {
action = "current_buffer_fuzzy_find";
options.desc = "Search lines";
};
"<leader>fg" = {
action = "live_grep";
options.desc = "Live grep";
};
"<leader>fh" = {
action = "help_tags";
options.desc = "Help tags";
};
"<leader>fr" = {
action = "oldfiles";
options.desc = "Recent files";
};
};
};
}
{ plugins.nvim-autopairs.enable = true; }
{ plugins.surround.enable = true; }
{
plugins.lint.enable = true;
# TODO: add linters
plugins.lint.lintersByFt = { };
}
{
plugins.marks.enable = true;
plugins.marks.defaultMappings = false;
}
{
plugins.hmts.enable = true;
performance.combinePlugins.standalonePlugins = [ "hmts.nvim" ];
}
{ plugins.gitsigns.enable = true; }
{ plugins.fugitive.enable = true; }
{ plugins.friendly-snippets.enable = true; }
{ plugins.direnv.enable = true; }
{ plugins.crates-nvim.enable = true; }
];
}; };
}; };
} }

View File

@ -23,7 +23,7 @@ vim.opt.termguicolors = true
vim.opt.undofile = true vim.opt.undofile = true
vim.opt.undolevels = 10000 vim.opt.undolevels = 10000
vim.opt.updatetime = 300 vim.opt.updatetime = 300
vim.opt.foldlevel = 2 vim.opt.foldlevel = 99
vim.opt_local.spell = true vim.opt_local.spell = true
vim.opt_local.spelllang = { "en", "de_20" } -- all English regions and new German spelling vim.opt_local.spelllang = { "en", "de_20" } -- all English regions and new German spelling