Add package for nixvim configuration

This commit is contained in:
Artemis Tosini 2023-10-27 06:06:33 +00:00
parent 65326c9f46
commit 8027f6d8fe
Signed by: artemist
GPG key ID: ADFFE553DCBB831E
4 changed files with 165 additions and 167 deletions

View file

@ -338,11 +338,11 @@
"pre-commit-hooks": "pre-commit-hooks" "pre-commit-hooks": "pre-commit-hooks"
}, },
"locked": { "locked": {
"lastModified": 1698328085, "lastModified": 1698386104,
"narHash": "sha256-32Vk8PCa57B4mIXdVTbDrKoHBO5FTm5ZaSwiph9PwIo=", "narHash": "sha256-/QwUn8G1ERjl82RFFTTI/2ulOTV9Mbeog97old9tZl0=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nixvim", "repo": "nixvim",
"rev": "e1138cda396c7b925989cf6158496787051cf3f7", "rev": "315bc508ee0bfb62b6608f8f445126158ca2cc35",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -78,7 +78,11 @@
}; };
in { in {
formatter = pkgs.nixfmt; formatter = pkgs.nixfmt;
packages = { jlink = pkgs.callPackage ./externals/packages/jlink { }; }; packages = {
jlink = pkgs.callPackage ./externals/packages/jlink { };
nvim = inputs.nixvim.legacyPackages."${system}".makeNixvim
(import ./sets/nvim.nix { inherit pkgs inputs; });
};
}); });
} }

View file

@ -1,180 +1,171 @@
{ pkgs, inputs, ... }: { pkgs, ... }:
{ {
imports = [ inputs.nixvim.nixosModules.nixvim ]; vimAlias = true;
environment.sessionVariables = { # Basic editing / QoL
EDITOR = "nvim"; editorconfig.enable = true;
VISUAL = "nvim"; colorschemes.kanagawa.enable = true;
}; plugins = {
programs.nixvim = { nix.enable = true;
enable = true; fugitive.enable = true;
vimAlias = true; gitgutter.enable = true;
lualine.enable = true;
# Basic editing / QoL typst-vim.enable = true;
editorconfig.enable = true; telescope = {
colorschemes.kanagawa.enable = true;
plugins = {
nix.enable = true;
fugitive.enable = true;
gitgutter.enable = true;
lualine.enable = true;
typst-vim.enable = true;
telescope = {
enable = true;
keymaps = {
"<leader>tgf" = "git_files";
"<leader>tb" = "buffers";
"<leader>tl" = "live_grep";
"<leader>ts" = "grep_string";
"<leader>tf" = "find_files";
"<leader>tt" = "builtin";
gd = "lsp_definitions";
gt = "lsp_type_definitions";
gr = "lsp_references";
gi = "lsp_implementations";
gcd = "diagnostics";
gsd = "lsp_document_symbols";
gsw = "lsp_workspace_symbols";
gci = "lsp_incoming_calls";
gco = "lsp_outgoing_calls";
"<leader>tgs" = "git_status";
"<leader>tgb" = "git_branches";
"<leader>tgc" = "git_commits";
};
};
};
extraPlugins = with pkgs.vimPlugins; [
vim-fetch
vim-fish
vim-flatbuffers
vim-nftables
vim-protobuf
vim-toml
];
options = {
hidden = true;
backup = false;
writebackup = false;
cmdheight = 2;
shortmess = "filnxtToOFc";
signcolumn = "yes";
number = true;
};
# LSP
plugins.rust-tools = {
enable = true; enable = true;
server.standalone = false;
};
plugins.clangd-extensions.enable = true;
plugins.lsp = {
enable = true;
servers = {
clangd.enable = true;
java-language-server.enable = true;
jsonls.enable = true;
nil_ls.enable = true;
pylsp.enable = true;
texlab.enable = true;
tsserver.enable = true;
typst-lsp.enable = true;
};
keymaps = { keymaps = {
silent = true; "<leader>tgf" = "git_files";
diagnostic = { "<leader>tb" = "buffers";
"<leader>rk" = "goto_prev"; "<leader>tl" = "live_grep";
"<leader>rj" = "goto_next"; "<leader>ts" = "grep_string";
}; "<leader>tf" = "find_files";
lspBuf = { "<leader>tt" = "builtin";
K = "hover";
gD = "declaration";
"<leader>ra" = "code_action"; gd = "lsp_definitions";
"<leader>rn" = "rename"; gt = "lsp_type_definitions";
"<leader>rs" = "signature_help"; gr = "lsp_references";
"<leader>f" = "format"; gi = "lsp_implementations";
}; gcd = "diagnostics";
gsd = "lsp_document_symbols";
gsw = "lsp_workspace_symbols";
gci = "lsp_incoming_calls";
gco = "lsp_outgoing_calls";
"<leader>tgs" = "git_status";
"<leader>tgb" = "git_branches";
"<leader>tgc" = "git_commits";
}; };
};
};
extraPlugins = with pkgs.vimPlugins; [
vim-fetch
vim-fish
vim-flatbuffers
vim-nftables
vim-protobuf
vim-toml
];
options = {
hidden = true;
backup = false;
writebackup = false;
cmdheight = 2;
shortmess = "filnxtToOFc";
signcolumn = "yes";
number = true;
};
onAttach = '' # LSP
if client.server_capabilities.documentHighlightProvider then plugins.rust-tools = {
vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true }) enable = true;
vim.api.nvim_clear_autocmds { buffer = bufnr, group = "lsp_document_highlight" } server.standalone = false;
vim.api.nvim_create_autocmd("CursorHold", { };
callback = vim.lsp.buf.document_highlight, plugins.clangd-extensions.enable = true;
buffer = bufnr, plugins.lsp = {
group = "lsp_document_highlight", enable = true;
desc = "Document Highlight", servers = {
}) clangd.enable = true;
vim.api.nvim_create_autocmd("CursorMoved", { java-language-server.enable = true;
callback = vim.lsp.buf.clear_references, jsonls.enable = true;
buffer = bufnr, nil_ls.enable = true;
group = "lsp_document_highlight", pylsp.enable = true;
desc = "Clear All the References", texlab.enable = true;
}) tsserver.enable = true;
end typst-lsp.enable = true;
'';
}; };
# Autocomplete keymaps = {
plugins = { silent = true;
luasnip.enable = true; diagnostic = {
cmp-cmdline.enable = true; "<leader>rk" = "goto_prev";
cmp-git.enable = true; "<leader>rj" = "goto_next";
cmp-buffer.enable = true; };
nvim-cmp = { lspBuf = {
enable = true; K = "hover";
snippet.expand = "luasnip"; gD = "declaration";
sources = [
{ name = "luasnip"; } "<leader>ra" = "code_action";
{ name = "nvim_lsp"; } "<leader>rn" = "rename";
{ name = "path"; } "<leader>rs" = "signature_help";
{ name = "calc"; } "<leader>f" = "format";
{ name = "emoji"; }
];
mappingPresets = [ "insert" "cmdline" ];
mapping = {
"<CR>" = "cmp.mapping.confirm({ select = true })";
"<C-b>" = "cmp.mapping.scroll_docs(-4)";
"<C-f>" = "cmp.mapping.scroll_docs(4)";
"<C-Space>" = "cmp.mapping.complete()";
"<C-e>" = "cmp.mapping.abort()";
};
}; };
}; };
# For some reason you can't do this directly in nix? onAttach = ''
extraConfigLuaPost = '' if client.server_capabilities.documentHighlightProvider then
do vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true })
local cmp = require('cmp') vim.api.nvim_clear_autocmds { buffer = bufnr, group = "lsp_document_highlight" }
cmp.setup.filetype('gitcommit', { vim.api.nvim_create_autocmd("CursorHold", {
sources = cmp.config.sources({ callback = vim.lsp.buf.document_highlight,
{ name = 'git' }, buffer = bufnr,
}, { group = "lsp_document_highlight",
{ name = 'buffer' }, desc = "Document Highlight",
}) })
}) vim.api.nvim_create_autocmd("CursorMoved", {
callback = vim.lsp.buf.clear_references,
cmp.setup.cmdline({ '/', '?' }, { buffer = bufnr,
mapping = cmp.mapping.preset.cmdline(), group = "lsp_document_highlight",
sources = { desc = "Clear All the References",
{ name = 'buffer' }
}
})
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
}) })
})
end end
''; '';
}; };
# Autocomplete
plugins = {
luasnip.enable = true;
cmp-cmdline.enable = true;
cmp-git.enable = true;
cmp-buffer.enable = true;
nvim-cmp = {
enable = true;
snippet.expand = "luasnip";
sources = [
{ name = "luasnip"; }
{ name = "nvim_lsp"; }
{ name = "path"; }
{ name = "calc"; }
{ name = "emoji"; }
];
mappingPresets = [ "insert" "cmdline" ];
mapping = {
"<CR>" = "cmp.mapping.confirm({ select = true })";
"<C-b>" = "cmp.mapping.scroll_docs(-4)";
"<C-f>" = "cmp.mapping.scroll_docs(4)";
"<C-Space>" = "cmp.mapping.complete()";
"<C-e>" = "cmp.mapping.abort()";
};
};
};
# For some reason you can't do this directly in nix?
extraConfigLuaPost = ''
do
local cmp = require('cmp')
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'git' },
}, {
{ name = 'buffer' },
})
})
cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
end
'';
} }

View file

@ -1,4 +1,4 @@
{ config, pkgs, ... }: { pkgs, inputs, ... }@args:
{ {
imports = [ imports = [
@ -6,9 +6,9 @@
./packages.nix ./packages.nix
./pipewire.nix ./pipewire.nix
./base.nix ./base.nix
./nvim.nix
../home ../home
./nix-index.nix ./nix-index.nix
inputs.nixvim.nixosModules.nixvim
]; ];
i18n.defaultLocale = "de_DE.UTF-8"; i18n.defaultLocale = "de_DE.UTF-8";
@ -16,10 +16,13 @@
environment = { environment = {
variables.EDITOR = "nvim"; variables.EDITOR = "nvim";
variables.VISUAL = "nvim";
variables.TERMINAL = "kitty"; variables.TERMINAL = "kitty";
enableDebugInfo = true; enableDebugInfo = true;
}; };
programs.nixvim = import ./nvim.nix args // { enable = true; };
services = { services = {
avahi = { avahi = {
enable = true; enable = true;