feat: add more plugins

use-nixvim
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,23 +43,39 @@ in
# taplo # taplo
# yamllint # yamllint
# ]; # ];
# extraLuaConfig = readFile ./options.lua;
# lazy.enable = true;
# }; # };
programs.nixvim = { programs.nixvim = lib.mkMerge [
{
enable = true; enable = true;
package = inputs.neovim-nightly-overlay.packages.${pkgs.system}.default; package = inputs.neovim-nightly-overlay.packages.${pkgs.system}.default;
vimAlias = true; vimAlias = true;
extraConfigLuaPre = readFile ./options.lua;
colorschemes.catppuccin.enable = true; performance = {
colorschemes.catppuccin.settings.flavour = "macchiato"; byteCompileLua = {
enable = true;
configs = true;
initLua = true;
nvimRuntime = true;
plugins = true;
};
combinePlugins.enable = true;
};
}
{
colorschemes.catppuccin = {
enable = true;
settings.flavour = "macchiato";
};
}
{
plugins.lualine.enable = true; plugins.lualine.enable = true;
}
plugins.cmp.autoEnableSources = true; {
plugins.cmp.enable = true; plugins.cmp = {
plugins.cmp.settings.sources = [ autoEnableSources = true;
enable = true;
settings.sources = [
{ priority = 1; name = "async_path"; } { priority = 1; name = "async_path"; }
{ priority = 1; name = "buffer"; } { priority = 1; name = "buffer"; }
{ priority = 2; name = "nvim_lsp"; } { priority = 2; name = "nvim_lsp"; }
@ -73,7 +83,7 @@ in
{ priority = 4; name = "luasnip"; } { priority = 4; name = "luasnip"; }
{ priority = 4; name = "vimtex"; } { priority = 4; name = "vimtex"; }
]; ];
plugins.cmp.settings.mapping = { settings.mapping = {
__raw = '' __raw = ''
cmp.mapping.preset.insert({ cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4), ['<C-b>'] = cmp.mapping.scroll_docs(-4),
@ -120,9 +130,12 @@ in
}) })
''; '';
}; };
};
plugins.luasnip.enable = true; }
plugins.luasnip.settings = { {
plugins.luasnip = {
enable = true;
settings = {
history = true; history = true;
update_events = "TextChanged,TextChangedI"; update_events = "TextChanged,TextChangedI";
delete_check_events = "TextChanged"; delete_check_events = "TextChanged";
@ -135,12 +148,15 @@ in
}''; }'';
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 = {
plugins.lsp.servers.nixd.enable = true; enable = true;
plugins.lsp.servers.nixd.extraOptions.settings.nixd = { inlayHints = true;
servers.nil-ls.enable = true;
servers.nixd.enable = true;
servers.nixd.extraOptions.settings.nixd = {
nixpkgs = { nixpkgs = {
expr = "import <nixpkgs> { }"; expr = "import <nixpkgs> { }";
}; };
@ -156,6 +172,9 @@ in
}; };
}; };
}; };
};
}
{
plugins.lspsaga = { plugins.lspsaga = {
enable = true; enable = true;
codeAction.keys.quit = "<esc>"; codeAction.keys.quit = "<esc>";
@ -189,9 +208,11 @@ in
} }
]; ];
}; };
}
{
plugins.nvim-ufo.enable = true; plugins.nvim-ufo.enable = true;
}
{
plugins.treesitter = { plugins.treesitter = {
enable = true; enable = true;
folding = true; folding = true;
@ -199,48 +220,71 @@ in
settings.indent.enable = true; settings.indent.enable = true;
settings.highlight.enable = true; settings.highlight.enable = true;
}; };
performance.combinePlugins.standalonePlugins = [
plugins.which-key.enable = true; "nvim-treesitter"
plugins.lastplace.enable = true; ];
plugins.comment.enable = true; }
plugins.ts-context-commentstring.enable = true; { plugins.which-key.enable = true; }
{ plugins.lastplace.enable = true; }
{ plugins.comment.enable = true; }
{ plugins.ts-context-commentstring.enable = true; }
{
plugins.vimtex = { plugins.vimtex = {
enable = true; enable = true;
settings.view_method = "zathura"; settings.view_method = "zathura";
}; };
}
plugins.todo-comments.enable = true; {
plugins.todo-comments.keymaps.todoTelescope.key = "<leader>fc"; plugins.todo-comments = {
enable = true;
plugins.conform-nvim.enable = true; keymaps.todoTelescope.key = "<leader>fc";
plugins.conform-nvim.settings.formatters_by_ft = { };
}
{
plugins.conform-nvim = {
enable = true;
settings.formatters_by_ft = {
"*" = [ "codespell" "trim_whitespace" ]; "*" = [ "codespell" "trim_whitespace" ];
elixir = [ "mix" ]; elixir = [ "mix" ];
gleam = [ "gleam" ]; gleam = [ "gleam" ];
go = [ "gofmt" ]; go = [ "gofmt" ];
json = [ "jq" ]; json = [ "jq" ];
lua = [ "stylua" ]; lua = [ "stylua" ];
nix = [ [ "nixpkgs_fmt" "alejandra" ] ]; nix.__raw = ''{ "nixpkgs_fmt", "alejandra", stop_after_first=true }'';
python = [ [ "ruff_fix" "isort" ] [ "ruff_format" "black" ] ]; python.__raw = ''
function(bufnr)
return { first("ruff_organize_imports", "isort"), first("ruff_format", "black")}
end
'';
rust = [ "rustfmt" ]; rust = [ "rustfmt" ];
sh = [ "shfmt" ]; sh = [ "shfmt" ];
tex = [ "latexindent" ]; tex = [ "latexindent" ];
toml = [ "taplo" ]; toml = [ "taplo" ];
yaml = [ "yamlfix" ]; 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()"; 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
extraConfigLua = ''
vim.api.nvim_create_user_command("Format", function(opts) vim.api.nvim_create_user_command("Format", function(opts)
require("conform").format({ formatters = opts.fargs }) require("conform").format({ formatters = opts.fargs })
end, { end, {
nargs = "+", nargs = "+",
complete = function() complete = function()
local formatters_by_ft = require("conform").formatters_by_ft
local names = formatters_by_ft[vim.bo.filetype] or formatters_by_ft["_"] or {} local names = formatters_by_ft[vim.bo.filetype] or formatters_by_ft["_"] or {}
names = vim.list_extend(names, formatters_by_ft["*"] or {}) names = vim.list_extend(names, formatters_by_ft["*"] or {})
names = vim.tbl_flatten(names) names = vim.tbl_flatten(names)
@ -254,12 +298,24 @@ in
end, end,
}) })
''; '';
performance.combinePlugins.standalonePlugins = [
plugins.oil.enable = true; "conform.nvim"
];
plugins.telescope.enable = true; keymaps = [
plugins.telescope.extensions.fzf-native.enable = true; { key = "<leader>cf"; action.__raw = ''function() require("conform").format() end''; options.desc = "Format current file"; }
plugins.telescope.keymaps = { ];
}
{
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" = { "<leader>ff" = {
action = "find_files"; action = "find_files";
options.desc = "Find files"; options.desc = "Find files";
@ -285,27 +341,29 @@ in
options.desc = "Recent files"; options.desc = "Recent files";
}; };
}; };
plugins.nvim-autopairs.enable = true;
plugins.surround.enable = true;
extraConfigLuaPre = readFile ./options.lua;
performance = {
byteCompileLua = {
enable = true;
configs = true;
initLua = true;
nvimRuntime = true;
plugins = true;
}; };
combinePlugins.enable = true; }
combinePlugins.standalonePlugins = [ { plugins.nvim-autopairs.enable = true; }
"nvim-treesitter" { plugins.surround.enable = true; }
"conform.nvim" {
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