Replace neovim config with NVF

This commit is contained in:
Pim Kunis 2025-01-10 17:51:57 +01:00
parent e286f4d835
commit 54f3b5802a
14 changed files with 2428 additions and 319 deletions

2310
flake.lock

File diff suppressed because it is too large Load diff

View file

@ -12,6 +12,11 @@
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
colmena.url = "github:zhaofengli/colmena";
nvf = {
url = "github:notashelf/nvf";
inputs.nixpkgs.follows = "nixpkgs";
};
git-hooks = {
url = "github:cachix/git-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs-unstable";

View file

@ -5,7 +5,6 @@
...
}: {
imports = [
./neovim
./firefox
./tidal.nix
./gnome
@ -13,6 +12,7 @@
./vscode.nix
inputs.nix-index-database.hmModules.nix-index
inputs.sops-nix.homeManagerModules.sops
inputs.nvf.homeManagerModules.default
];
xsession.enable = true;

View file

@ -1,13 +0,0 @@
require("bufferline").setup({
options = {
diagnostics = "nvim_lsp",
diagnostics_indicator = function(count, level, diagnostics_dict, context)
local icon = level:match("error") and "" or ""
return " " .. icon .. count
end,
separator_style = "slant",
hover = { enabled = true, reveal = { "close" } },
},
})
vim.keymap.set("n", "<leader>ft", ":BufferLinePick<CR>", {})

View file

@ -1,43 +0,0 @@
local cmp = require("cmp")
local luasnip = require("luasnip")
require("luasnip.loaders.from_vscode").lazy_load()
luasnip.config.setup({})
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-p>"] = cmp.mapping.select_prev_item(),
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete({}),
["<CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
sources = { { name = "nvim_lsp" }, { name = "luasnip" } },
})

View file

@ -1,2 +0,0 @@
vim.cmd([[autocmd FileType nix setlocal commentstring=#%s]])
vim.cmd([[autocmd FileType terraform setlocal commentstring=#%s]])

View file

@ -1,9 +0,0 @@
vim.o.background = "dark"
vim.cmd([[colorscheme gruvbox]])
vim.g.mapleader = ";"
vim.o.signcolumn = "yes"
vim.wo.number = true
vim.wo.relativenumber = true
vim.wo.cursorline = true
vim.opt.termguicolors = true
vim.o.mousemoveevent = true

View file

@ -1,95 +0,0 @@
{
pkgs,
config,
lib,
...
}: let
cfg = config.pim.neovim;
in {
options.pim.neovim.enable = lib.mkEnableOption "neovim";
config = lib.mkIf cfg.enable {
# Disable Stylix styling of Neovim,
# because we have a plugin for that.
stylix.targets.neovim.enable = false;
programs.neovim = {
enable = true;
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
defaultEditor = true;
extraLuaConfig = builtins.readFile ./core.lua;
extraPackages = with pkgs; [
nil
pyright
gopls
terraform-ls
nixfmt-classic
stylua
black
nixpkgs-fmt
];
plugins = with pkgs.vimPlugins; [
{
plugin = nvim-lspconfig;
type = "lua";
config = builtins.readFile ./lspconfig.lua;
}
gruvbox-nvim
{
plugin = leap-nvim;
type = "lua";
config = builtins.readFile ./leap.lua;
}
{
plugin = telescope-nvim;
type = "lua";
config = builtins.readFile ./telescope.lua;
}
{
plugin = vim-commentary;
type = "lua";
config = builtins.readFile ./commentary.lua;
}
vim-sleuth
{
plugin = gitsigns-nvim;
type = "lua";
config = ''require("gitsigns").setup()'';
}
{
plugin = nvim-cmp;
type = "lua";
config = builtins.readFile ./cmp.lua;
}
cmp-nvim-lsp
friendly-snippets
neodev-nvim
luasnip
cmp_luasnip
{
plugin = nvim-treesitter.withAllGrammars;
type = "lua";
config = builtins.readFile ./treesitter.lua;
}
{
plugin = bufferline-nvim;
type = "lua";
config = builtins.readFile ./bufferline.lua;
}
nvim-web-devicons
lsp-format-nvim
{
plugin = pkgs.vimPlugins.none-ls-nvim;
type = "lua";
config = builtins.readFile ./none-ls.lua;
}
];
};
programs.git.extraConfig.core.editor = "nvim";
};
}

View file

@ -1,4 +0,0 @@
require("leap").add_default_mappings()
-- Don't remap 'x' in visual mode.
vim.keymap.del({ "x", "o" }, "x")
vim.keymap.del({ "x", "o" }, "X")

View file

@ -1,65 +0,0 @@
require("lsp-format").setup({})
local on_attach = function(client, bufnr)
local bufmap = function(keys, func)
vim.keymap.set("n", keys, func, { buffer = bufnr })
end
bufmap("<leader>r", vim.lsp.buf.rename)
bufmap("<leader>a", vim.lsp.buf.code_action)
bufmap("gd", vim.lsp.buf.definition)
bufmap("gD", vim.lsp.buf.declaration)
bufmap("gI", vim.lsp.buf.implementation)
bufmap("<leader>D", vim.lsp.buf.type_definition)
bufmap("gr", require("telescope.builtin").lsp_references)
bufmap("<leader>s", require("telescope.builtin").lsp_document_symbols)
bufmap("<leader>S", require("telescope.builtin").lsp_dynamic_workspace_symbols)
bufmap("K", vim.lsp.buf.hover)
vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_)
vim.lsp.buf.format()
end, {})
end
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
require("neodev").setup()
require("lspconfig").nil_ls.setup({
on_attach = on_attach,
capabilities = capabilities,
})
require("lspconfig").pyright.setup({
on_attach = on_attach,
capabilities = capabilities,
})
require("lspconfig").gopls.setup({
on_attach = on_attach,
capabilities = capabilities,
})
require("lspconfig").terraformls.setup({
on_attach = on_attach,
capabilities = capabilities,
})
local function has_treefmt()
local git_root = vim.fn.systemlist("git rev-parse --show-toplevel")[1]
if vim.v.shell_error ~= 0 then
return false
end
local treefmt_path = git_root .. "/treefmt.nix"
return vim.fn.filereadable(treefmt_path) == 1
end
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = "*",
callback = function()
if vim.fn.expand("%:p") ~= vim.fn.getcwd() .. "/.git/COMMIT_EDITMSG" and has_treefmt() then
vim.cmd("silent !treefmt > /dev/null 2>&1")
end
end,
group = vim.api.nvim_create_augroup("TreefmtAutoformat", { clear = true }),
})

View file

@ -1,53 +0,0 @@
-- renamed to none-ls
local null_ls_status_ok, null_ls = pcall(require, "null-ls")
if not null_ls_status_ok then
return
end
local formatting = null_ls.builtins.formatting
local diagnostics = null_ls.builtins.diagnostics
local code_actions = null_ls.builtins.code_actions
-- to setup format on save
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
require("null-ls").setup({
sources = {
formatting.stylua,
formatting.black,
formatting.nixpkgs_fmt,
formatting.mix,
},
-- configure format on save
-- on_attach = function(current_client, bufnr)
-- if current_client.supports_method("textDocument/formatting") then
-- vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
-- vim.api.nvim_create_autocmd("BufWritePre", {
-- group = augroup,
-- buffer = bufnr,
-- callback = function()
-- vim.lsp.buf.format({
-- filter = function(client)
-- -- only use null-ls for formatting instead of lsp server
-- return client.name == "null-ls"
-- end,
-- bufnr = bufnr,
-- })
-- end,
-- })
-- end
-- end,
})
-- formatting command
vim.api.nvim_create_user_command("Format", function()
vim.lsp.buf.format(nil, 10000)
end, {})
vim.keymap.set(
"n",
"<leader>fm",
":Format<CR>",
{ desc = "Format current buffer (also done on save)", noremap = true, silent = true }
)

View file

@ -1,17 +0,0 @@
local builtin = require("telescope.builtin")
vim.keymap.set("n", "<leader>ff", builtin.find_files, {})
vim.keymap.set("n", "<leader>fg", builtin.live_grep, {})
vim.keymap.set("n", "<leader>fb", builtin.buffers, {})
vim.keymap.set("n", "<leader>fr", builtin.lsp_references, {})
vim.keymap.set("n", "<leader>fs", builtin.lsp_document_symbols, {})
require("telescope").setup({
pickers = {
find_files = { theme = "dropdown" },
live_grep = { theme = "dropdown" },
buffers = { theme = "dropdown" },
lsp_references = { theme = "dropdown" },
lsp_document_symbols = { theme = "dropdown" },
},
})

View file

@ -1,9 +0,0 @@
require("nvim-treesitter.configs").setup({
ensure_installed = {},
auto_install = false,
highlight = { enable = true },
indent = { enable = true },
})

View file

@ -11,17 +11,131 @@
gnome.enable = true;
vscode.enable = true;
syncthing.enable = true;
neovim.enable = true;
firefox.enable = true;
};
programs.chromium.enable = true;
programs = {
chromium.enable = true;
git.extraConfig.core.editor = lib.getExe config.programs.nvf.finalPackage;
nvf = {
enable = true;
settings = {
vim = {
viAlias = true;
vimAlias = true;
telescope.enable = true;
autopairs.nvim-autopairs.enable = true;
autocomplete.nvim-cmp.enable = true;
snippets.luasnip.enable = true;
filetree.neo-tree.enable = true;
tabline.nvimBufferline.enable = true;
treesitter.context.enable = true;
minimap.codewindow.enable = false;
dashboard.alpha.enable = true;
notify.nvim-notify.enable = true;
projects.project-nvim.enable = true;
comments.comment-nvim.enable = true;
lsp = {
formatOnSave = true;
lightbulb.enable = true;
trouble.enable = true;
lspSignature.enable = true;
otter-nvim.enable = true;
lsplines.enable = true;
};
languages = {
enableLSP = true;
enableFormat = true;
enableTreesitter = true;
enableExtraDiagnostics = true;
nix.enable = true;
markdown.enable = true;
bash.enable = true;
clang.enable = true;
css.enable = true;
html.enable = true;
sql.enable = true;
go.enable = true;
python.enable = true;
rust = {
enable = true;
crates.enable = true;
};
};
visuals = {
nvim-scrollbar.enable = true;
nvim-web-devicons.enable = true;
nvim-cursorline.enable = true;
cinnamon-nvim.enable = true;
fidget-nvim.enable = true;
highlight-undo.enable = true;
indent-blankline.enable = true;
cellular-automaton.enable = true;
};
statusline.lualine = {
enable = true;
theme = "gruvbox";
};
theme = {
enable = true;
name = "gruvbox";
style = "dark";
transparent = false;
};
binds = {
whichKey.enable = true;
cheatsheet.enable = true;
};
git = {
enable = true;
gitsigns.enable = true;
};
utility = {
surround.enable = true;
diffview-nvim.enable = true;
motion = {
hop.enable = true;
leap.enable = true;
};
};
terminal.toggleterm = {
enable = true;
lazygit.enable = true;
};
ui = {
borders.enable = true;
noice.enable = true;
colorizer.enable = true;
illuminate.enable = true;
smartcolumn.enable = true;
fastaction.enable = true;
};
};
};
};
};
home = {
username = "pim";
homeDirectory = "/home/pim";
stateVersion = "23.05";
sessionVariables.MANPAGER = "${lib.getExe config.programs.neovim.finalPackage} +Man!";
sessionVariables = {
MANPAGER = "${lib.getExe config.programs.nvf.finalPackage} +Man!";
EDITOR = lib.getExe config.programs.nvf.finalPackage;
};
};
sops = {