257 lines
6.5 KiB
Nix
257 lines
6.5 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
inputs,
|
|
...
|
|
}:
|
|
# Neovim for the primary user, configured declaratively through nixvim.
|
|
let
|
|
cfg = config.modules.shell.nvim;
|
|
user = config.user.name;
|
|
in
|
|
{
|
|
options.modules.shell.nvim.enable =
|
|
lib.mkEnableOption "Neovim, configured declaratively via nixvim";
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
registry.shell-shortcut.${config.networking.hostName} = {
|
|
vi = "nvim";
|
|
vim = "nvim";
|
|
};
|
|
|
|
home-manager.sharedModules = [ inputs.nixvim.homeModules.nixvim ];
|
|
|
|
home-manager.users.${user} = hm: {
|
|
programs.nixvim = {
|
|
enable = true;
|
|
nixpkgs.useGlobalPackages = true;
|
|
|
|
extraPackages = with pkgs; [
|
|
git # neogit and gitsigns shell out to git
|
|
ripgrep # backs the picker's live grep
|
|
fd # backs the picker's file finder
|
|
wl-clipboard # provides a non-blocking clipboard provider on Wayland
|
|
nixd # provides Nix language-server support
|
|
];
|
|
|
|
globals.mapleader = " ";
|
|
|
|
opts = {
|
|
clipboard = "unnamedplus";
|
|
|
|
number = true;
|
|
relativenumber = true;
|
|
|
|
shiftwidth = 2;
|
|
tabstop = 2;
|
|
expandtab = true;
|
|
|
|
mouse = "a";
|
|
|
|
undofile = true;
|
|
|
|
ignorecase = true;
|
|
smartcase = true;
|
|
|
|
splitright = true;
|
|
splitbelow = true;
|
|
|
|
wrap = false;
|
|
|
|
scrolloff = 8;
|
|
cursorline = true;
|
|
};
|
|
|
|
keymaps = [
|
|
{
|
|
mode = "n";
|
|
key = "<C-h>";
|
|
action = "<C-w>h";
|
|
options.desc = "Move focus left";
|
|
}
|
|
{
|
|
mode = "n";
|
|
key = "<C-j>";
|
|
action = "<C-w>j";
|
|
options.desc = "Move focus down";
|
|
}
|
|
{
|
|
mode = "n";
|
|
key = "<C-k>";
|
|
action = "<C-w>k";
|
|
options.desc = "Move focus up";
|
|
}
|
|
{
|
|
mode = "n";
|
|
key = "<C-l>";
|
|
action = "<C-w>l";
|
|
options.desc = "Move focus right";
|
|
}
|
|
{
|
|
mode = "n";
|
|
key = "<Esc>";
|
|
action = "<cmd>nohlsearch<CR>";
|
|
options.desc = "Clear search highlight";
|
|
}
|
|
{
|
|
mode = "n";
|
|
key = "j";
|
|
action = "gj";
|
|
options.desc = "Move down by display line";
|
|
}
|
|
{
|
|
mode = "n";
|
|
key = "k";
|
|
action = "gk";
|
|
options.desc = "Move up by display line";
|
|
}
|
|
{
|
|
mode = "n";
|
|
key = "<leader>e";
|
|
action = "<cmd>Oil<CR>";
|
|
options.desc = "Open file browser";
|
|
}
|
|
{
|
|
mode = "n";
|
|
key = "<leader>f";
|
|
action.__raw = "function() require('snacks').picker.files() end";
|
|
options.desc = "Find files";
|
|
}
|
|
{
|
|
mode = "n";
|
|
key = "<leader>s";
|
|
action.__raw = "function() require('snacks').picker.grep() end";
|
|
options.desc = "Search text";
|
|
}
|
|
{
|
|
mode = "n";
|
|
key = "<leader>b";
|
|
action.__raw = "function() require('snacks').picker.buffers() end";
|
|
options.desc = "Switch buffer";
|
|
}
|
|
{
|
|
mode = "n";
|
|
key = "<leader>g";
|
|
action.__raw = ''
|
|
function()
|
|
require('gitsigns').toggle_current_line_blame(true)
|
|
require('neogit').open()
|
|
end
|
|
'';
|
|
options.desc = "Open git (Neogit)";
|
|
}
|
|
];
|
|
|
|
plugins = {
|
|
blink-cmp = {
|
|
enable = true;
|
|
setupLspCapabilities = true;
|
|
settings = {
|
|
keymap = {
|
|
preset = "default";
|
|
"<M-Space>" = [
|
|
"show"
|
|
"show_documentation"
|
|
"hide_documentation"
|
|
];
|
|
};
|
|
completion.documentation.auto_show = true;
|
|
signature.enabled = true;
|
|
sources.default = [
|
|
"lsp"
|
|
"path"
|
|
"snippets"
|
|
"buffer"
|
|
];
|
|
};
|
|
};
|
|
|
|
lsp = {
|
|
enable = true;
|
|
inlayHints = true;
|
|
keymaps = {
|
|
silent = true;
|
|
diagnostic = {
|
|
"[d" = "goto_prev";
|
|
"]d" = "goto_next";
|
|
};
|
|
lspBuf = {
|
|
gd = "definition";
|
|
gD = "references";
|
|
K = "hover";
|
|
"<leader>ca" = "code_action";
|
|
"<leader>rn" = "rename";
|
|
};
|
|
};
|
|
servers.rust_analyzer = lib.mkIf config.modules.shell.rust.enable {
|
|
enable = true;
|
|
installCargo = false;
|
|
installRustc = false;
|
|
installRustfmt = false;
|
|
};
|
|
|
|
servers.nixd.enable = true;
|
|
};
|
|
|
|
gitsigns = {
|
|
enable = true;
|
|
settings.current_line_blame = false;
|
|
};
|
|
|
|
neogit.enable = true;
|
|
diffview.enable = true; # neogit's diff integration
|
|
|
|
oil = {
|
|
enable = true;
|
|
settings.view_options.show_hidden = true;
|
|
};
|
|
|
|
snacks = {
|
|
enable = true;
|
|
settings = {
|
|
picker.enabled = true;
|
|
notifier.enabled = true;
|
|
input.enabled = true;
|
|
};
|
|
};
|
|
|
|
which-key.enable = true;
|
|
render-markdown.enable = true;
|
|
|
|
treesitter = {
|
|
enable = true;
|
|
highlight.enable = true;
|
|
indent.enable = true;
|
|
grammarPackages = with hm.config.programs.nixvim.plugins.treesitter.package.builtGrammars; [
|
|
nix
|
|
lua
|
|
bash
|
|
fish
|
|
markdown
|
|
markdown_inline
|
|
rust
|
|
python
|
|
java
|
|
kotlin
|
|
c
|
|
cpp
|
|
html
|
|
css
|
|
javascript
|
|
typescript
|
|
go
|
|
];
|
|
};
|
|
};
|
|
|
|
# `gbprod-nord` provides the `require("nord").setup()` API used in `./config.lua`.
|
|
# nixpkgs packages `shaunsingh/nord.nvim` as `nord-nvim`, which is a different plugin.
|
|
extraPlugins = [ pkgs.vimPlugins.gbprod-nord ];
|
|
|
|
extraConfigLua = builtins.readFile ./config.lua;
|
|
};
|
|
};
|
|
};
|
|
}
|