nix/home-manager/common/software/cli/nixvim.nix

158 lines
5.5 KiB
Nix

{ inputs, pkgs, config, lib, theme, ... }: {
imports = [
inputs.nixvim.homeManagerModules.nixvim
] ++ lib.optional (builtins.isString theme) ../../../../stylix/${theme}/home-manager.nix;
programs.nixvim = {
enable = true;
viAlias = true;
vimAlias = true;
globals.mapleader = " ";
globals.maplocalleader = " ";
keymaps = let
map = mode: key: action: { mode = mode; key = key; action = action; };
nmap = key: action: map [ "n" ] key action;
nvmap = key: action: map [ "n" "v" ] key action;
imap = key: action: map [ "i" ] key action;
desc = d: { options.desc = d; };
silent = { options.silent = true; };
expr = { options.expr = true; };
in [
# Unmap keys that aren't useful, or that we want to use for different things
(nvmap "<Space>" "<Nop>" // silent)
(nvmap "<Cr>" "<Nop>" // silent)
(nvmap "s" "<Nop>" // silent)
# Leave insert mode by pressing j and k simultaneously
(imap "jk" "<Esc>")
(imap "kj" "<Esc>")
# Redo
(nmap "R" "<C-r>")
# Copy and paste
(nvmap "<leader>y" "\"+y" // desc "Cop[y] to clipboard")
(nvmap "<leader>p" "\"+p" // desc "[P]aste from clipboard")
# Jump to start/end of line
(nvmap "H" "0")
(nvmap "L" "$")
# Navigate up and down word wrapped text as if it were not word wrapped
(nmap "k" "v:count == 0 ? 'gk' : 'k'" // silent // expr)
(nmap "j" "v:count == 0 ? 'gj' : 'j'" // silent // expr)
# Center cursor when jumping foward or back
(nmap "<C-o>" "<C-o>zz")
(nmap "<C-i>" "<C-i>zz")
];
options = {
number = true;
shiftwidth = 2;
# Indent wrapped text.
breakindent = true;
colorcolumn = "100";
# This is the default value. `:help cot` to see the available options.
completeopt = "menu,preview";
cursorline = true;
};
plugins = {
treesitter.enable = true;
lualine.enable = true;
luasnip.enable = true;
nix.enable = true;
nix-develop.enable = true;
bufferline.enable = true;
which-key.enable = true;
intellitab.enable = true;
illuminate.enable = true;
neo-tree.enable = true;
gitsigns.enable = true;
toggleterm.enable = true;
rainbow-delimiters.enable = true;
fidget.enable = true;
git-worktree = {
enable = true;
enableTelescope = true;
};
telescope = {
enable = true;
extensions.frecency.enable = true;
extensions.fzf-native.enable = true;
keymaps = {
"<leader><leader>" = {
action = "find_files";
desc = "Search files by name";
};
"<leader>s" = {
action = "live_grep";
desc = "[S]earch by live grep";
};
"<leader>b" = {
action = "buffers";
desc = "[S]earch open [B]uffers by file name";
};
"<leader>h" = {
action = "help_tags";
desc = "[S]earch [H]elp";
};
"<leader>w" = {
action = "grep_string";
desc = "[S]earch for [W]ord under cursor";
};
"<leader>g" = {
action = "buffers";
desc = "[S]earch [G]it files";
};
"<leader>r" = {
action = "oldfiles";
desc = "[S]earch [R]ecently opened files by name";
};
};
};
lsp = {
enable = true;
servers = {
rust-analyzer = {
enable = true;
installCargo = true;
installRustc = true;
};
nixd.enable = true;
pylsp.enable = true;
html.enable = true;
cssls.enable = true;
bashls.enable = true;
};
};
nvim-cmp = {
enable = true;
autoEnableSources = true;
sources = [
{ name = "nvim_lsp"; }
{ name = "path"; }
{ name = "buffer"; }
];
};
};
# TODO: Add this to stylix configs
# colorscheme = lib.mkForce "everforest";
colorscheme = lib.mkForce "catpuccin-mocha";
colorschemes = {
tokyonight.enable = true;
gruvbox.enable = true;
oxocarbon.enable = true;
nord.enable = true;
catppuccin.enable = true;
base16.enable = true;
kanagawa.enable = true;
dracula.enable = true;
};
extraPlugins = with pkgs.vimPlugins; [
everforest
];
};
}