feat: use nixvim

This commit is contained in:
Moritz Böhme 2024-08-31 10:14:44 +02:00
parent 101ab079ac
commit f1890f15be
Signed by: moritz
GPG key ID: 970C6E89EB0547A9
4 changed files with 517 additions and 41 deletions

View file

@ -228,6 +228,20 @@
}
},
"flake-compat_4": {
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"revCount": 57,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
}
},
"flake-compat_5": {
"flake": false,
"locked": {
"lastModified": 1696426674,
@ -342,6 +356,24 @@
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_4"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gen-nvim": {
"flake": false,
"locked": {
@ -416,6 +448,36 @@
"type": "github"
}
},
"git-hooks_2": {
"inputs": {
"flake-compat": [
"nixvim",
"flake-compat"
],
"gitignore": "gitignore_2",
"nixpkgs": [
"nixvim",
"nixpkgs"
],
"nixpkgs-stable": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1724857454,
"narHash": "sha256-Qyl9Q4QMTLZnnBb/8OuQ9LSkzWjBU1T5l5zIzTxkkhk=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "4509ca64f1084e73bc7a721b20c669a8d4c5ebe6",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
@ -439,6 +501,28 @@
}
},
"gitignore_2": {
"inputs": {
"nixpkgs": [
"nixvim",
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"gitignore_3": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
@ -843,6 +927,27 @@
"type": "github"
}
},
"nix-darwin": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1724561770,
"narHash": "sha256-zv8C9RNa86CIpyHwPIVO/k+5TfM8ZbjGwOOpTe1grls=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "ac5694a0b855a981e81b4d9f14052e3ff46ca39e",
"type": "github"
},
"original": {
"owner": "lnl7",
"repo": "nix-darwin",
"type": "github"
}
},
"nix-index-database": {
"inputs": {
"nixpkgs": [
@ -998,6 +1103,22 @@
"type": "github"
}
},
"nixpkgs_10": {
"locked": {
"lastModified": 1692934111,
"narHash": "sha256-9EEE59v/esKNMR5zKbLRV9NoRPYvERw5jHQOnfr47bk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "1e44a037bbf4fcaba041436e65e87be88f3f495b",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1723603349,
@ -1095,6 +1216,22 @@
}
},
"nixpkgs_8": {
"locked": {
"lastModified": 1724819573,
"narHash": "sha256-GnR7/ibgIH1vhoy8cYdmXE6iyZqKqFxQSVkFgosBh6w=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "71e91c409d1e654808b2621f28a327acfdad8dc2",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_9": {
"locked": {
"lastModified": 1719082008,
"narHash": "sha256-jHJSUH619zBQ6WdC21fFAlDxHErKVDJ5fpN0Hgx4sjs=",
@ -1110,19 +1247,35 @@
"type": "github"
}
},
"nixpkgs_9": {
"nixvim": {
"inputs": {
"devshell": [
"devshell"
],
"flake-compat": "flake-compat_4",
"flake-parts": [
"flake-parts"
],
"git-hooks": "git-hooks_2",
"home-manager": [
"home-manager"
],
"nix-darwin": "nix-darwin",
"nixpkgs": "nixpkgs_8",
"nuschtosSearch": "nuschtosSearch",
"treefmt-nix": "treefmt-nix"
},
"locked": {
"lastModified": 1692934111,
"narHash": "sha256-9EEE59v/esKNMR5zKbLRV9NoRPYvERw5jHQOnfr47bk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "1e44a037bbf4fcaba041436e65e87be88f3f495b",
"lastModified": 1724968633,
"narHash": "sha256-eb2NCdLwfXL1MuTAkoDncSl2lCJwyylV5/NM1Ws2P/U=",
"owner": "nix-community",
"repo": "nixvim",
"rev": "2704133fe3ca616b22ed6685cc67180456eb4160",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"owner": "nix-community",
"repo": "nixvim",
"type": "github"
}
},
@ -1157,6 +1310,28 @@
"type": "github"
}
},
"nuschtosSearch": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1724584782,
"narHash": "sha256-7FfHv7b1jwMPSu9SPY9hdxStk8E6EeSwzqdvV69U4BM=",
"owner": "NuschtOS",
"repo": "search",
"rev": "5a08d691de30b6fc28d58ce71a5e420f2694e087",
"type": "github"
},
"original": {
"owner": "NuschtOS",
"repo": "search",
"type": "github"
}
},
"nvim-lspconfig": {
"flake": false,
"locked": {
@ -1175,9 +1350,9 @@
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat_4",
"gitignore": "gitignore_2",
"nixpkgs": "nixpkgs_8",
"flake-compat": "flake-compat_5",
"gitignore": "gitignore_3",
"nixpkgs": "nixpkgs_9",
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
@ -1237,6 +1412,7 @@
"nix-monitored": "nix-monitored",
"nix-super": "nix-super",
"nixpkgs": "nixpkgs_7",
"nixvim": "nixvim",
"none-ls-shellcheck-nvim": "none-ls-shellcheck-nvim",
"nur": "nur",
"nvim-lspconfig": "nvim-lspconfig",
@ -1340,6 +1516,21 @@
"type": "github"
}
},
"systems_5": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"telekasten-nvim": {
"flake": false,
"locked": {
@ -1359,7 +1550,7 @@
"timers": {
"inputs": {
"naersk": "naersk",
"nixpkgs": "nixpkgs_9",
"nixpkgs": "nixpkgs_10",
"utils": "utils"
},
"locked": {
@ -1376,9 +1567,30 @@
"url": "https://gitea.moritzboeh.me/moritz/timers.git"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1724833132,
"narHash": "sha256-F4djBvyNRAXGusJiNYInqR6zIMI3rvlp6WiKwsRISos=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "3ffd842a5f50f435d3e603312eefa4790db46af5",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
},
"utils": {
"inputs": {
"systems": "systems_4"
"systems": "systems_5"
},
"locked": {
"lastModified": 1692799911,

View file

@ -48,6 +48,11 @@
cmp-vimtex.flake = false;
cmp-vimtex.url = "github:micangl/cmp-vimtex";
nixvim.url = "github:nix-community/nixvim";
nixvim.inputs.devshell.follows = "devshell";
nixvim.inputs.flake-parts.follows = "flake-parts";
nixvim.inputs.home-manager.follows = "home-manager";
# river
river.url = "git+https://github.com/riverwm/river?submodules=1";
river.flake = false;
@ -116,6 +121,7 @@
packages = with pkgs; [
stylua
sumneko-lua-language-server
nixpkgs-fmt
];
};
@ -153,7 +159,10 @@
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = { inherit inputs self; };
sharedModules = [ inputs.nix-lazy-nvim.homeManagerModules.default ];
sharedModules = [
inputs.nix-lazy-nvim.homeManagerModules.default
inputs.nixvim.homeManagerModules.nixvim
];
};
}
inputs.agenix.nixosModules.age

View file

@ -21,36 +21,290 @@ in
xdotool # for vimtex
];
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;
# [
# alejandra
# checkmake
# codespell
# deadnix
# dotenv-linter
# fish
# jq
# nil
# nixd
# nixpkgs-fmt
# nodePackages.bash-language-server
# python3Packages.python-lsp-server
# shellcheck
# shfmt
# stable.yamlfix
# statix
# taplo
# yamllint
# ];
# extraLuaConfig = readFile ./options.lua;
# lazy.enable = true;
# };
programs.nixvim = {
enable = true;
package = inputs.neovim-nightly-overlay.packages.${pkgs.system}.default;
vimAlias = true;
vimdiffAlias = true;
withNodeJs = true;
withPython3 = true;
extraPackages = with pkgs;
[
alejandra
checkmake
codespell
deadnix
dotenv-linter
fish
jq
nil
nixd
nixpkgs-fmt
nodePackages.bash-language-server
python3Packages.python-lsp-server
shellcheck
shfmt
stable.yamlfix
statix
taplo
yamllint
colorschemes.catppuccin.enable = true;
colorschemes.catppuccin.settings.flavour = "macchiato";
plugins.lualine.enable = true;
plugins.cmp.autoEnableSources = true;
plugins.cmp.enable = true;
plugins.cmp.settings.sources = [
{ priority = 1; name = "async_path"; }
{ priority = 1; name = "buffer"; }
{ priority = 2; name = "nvim_lsp"; }
{ priority = 3; name = "nvim_lsp_signature_help"; }
{ priority = 4; name = "luasnip"; }
{ priority = 4; name = "vimtex"; }
];
plugins.cmp.settings.mapping = {
__raw = ''
cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
elseif require("luasnip").locally_jumpable(1) then
require("luasnip").jump(1)
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select })
elseif require("luasnip").locally_jumpable(-1) then
require("luasnip").jump(-1)
else
fallback()
end
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
require("luasnip").jump(1)
else
fallback()
end
end, { "i", "s" }),
["<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;
plugins.luasnip.settings = {
history = true;
update_events = "TextChanged,TextChangedI";
delete_check_events = "TextChanged";
ext_opts.__raw = ''{
[require("luasnip.util.types").choiceNode] = {
active = {
virt_text = { { "<--", "Error" } },
},
},
}'';
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;
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;
}
];
extraLuaConfig = readFile ./options.lua;
lazy.enable = 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;
configs = true;
initLua = true;
nvimRuntime = true;
plugins = true;
};
combinePlugins.enable = true;
combinePlugins.standalonePlugins = [
"nvim-treesitter"
"conform.nvim"
];
};
};
};
};

View file

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