refactor(shell): use default modules for grouped tools
This commit is contained in:
192
modules/shell/nvim/default.nix
Normal file
192
modules/shell/nvim/default.nix
Normal file
@@ -0,0 +1,192 @@
|
||||
{
|
||||
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
|
||||
];
|
||||
|
||||
globals.mapleader = " ";
|
||||
globals.clipboard = "osc52"; # built-in OSC 52 provider, no external binary needed
|
||||
|
||||
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 = "<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 = {
|
||||
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;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user