2024-02-08 11:40:29 +01:00
|
|
|
{ inputs, pkgs, config, lib, theme, ... }: {
|
2024-02-08 03:17:11 +01:00
|
|
|
imports = [
|
|
|
|
inputs.nixvim.homeManagerModules.nixvim
|
2024-02-08 12:55:26 +01:00
|
|
|
] ++ lib.optional (builtins.isString theme) ../../../../stylix/${theme}/home-manager/nixvim.nix;
|
2024-02-08 03:17:11 +01:00
|
|
|
|
|
|
|
programs.nixvim = {
|
|
|
|
enable = true;
|
2024-02-08 05:49:29 +01:00
|
|
|
viAlias = true;
|
|
|
|
vimAlias = true;
|
2024-02-08 06:23:38 +01:00
|
|
|
|
|
|
|
globals.mapleader = " ";
|
|
|
|
globals.maplocalleader = " ";
|
2024-02-08 06:23:59 +01:00
|
|
|
|
2024-02-08 12:56:57 +01:00
|
|
|
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)
|
|
|
|
# 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")
|
2024-02-10 02:13:46 +01:00
|
|
|
|
2024-02-09 13:19:35 +01:00
|
|
|
# Insert Mode
|
2024-02-10 02:13:46 +01:00
|
|
|
|
2024-02-12 04:54:48 +01:00
|
|
|
# Normal Mode
|
2024-02-13 03:54:56 +01:00
|
|
|
# NVimTree
|
2024-02-13 03:30:44 +01:00
|
|
|
(nmap "<leader>n" "<Nop>" // desc "[N]vimTree" // silent)
|
2024-02-13 03:54:56 +01:00
|
|
|
(nmap "<leader>nf" ":NvimTreeFocus<CR>" // desc "[F]ocus NvimTree")
|
|
|
|
(nmap "<leader>nt" ":NvimTreeToggle<CR>" // desc "[T]oggle NvimTree")
|
|
|
|
(nmap "<leader>ns" ":NvimTreeFindFile<CR>" // desc "[S]earch NvimTree")
|
|
|
|
(nmap "<leader>nc" ":NvimTreeClose<CR>" // desc "[C]lose NvimTree")
|
|
|
|
# ToggleTerm
|
2024-02-13 03:31:29 +01:00
|
|
|
(nmap "<leader>t" "<Nop>" // desc "[T]oggleTerm" // silent)
|
2024-02-13 03:21:43 +01:00
|
|
|
(nmap "<leader>tt" ":ToggleTerm<CR>" // desc "[T]oggle Terminal")
|
2024-02-13 04:46:13 +01:00
|
|
|
# Fugitive
|
2024-02-13 04:56:16 +01:00
|
|
|
(nmap "<leader>gc" ":Git commit -a<CR>" // desc "[C]ommit" )
|
2024-02-13 04:54:27 +01:00
|
|
|
(nmap "<leader>gp" ":Git push<CR>" // desc "[P]ush")
|
2024-02-08 12:56:57 +01:00
|
|
|
];
|
|
|
|
|
2024-02-08 03:17:11 +01:00
|
|
|
options = {
|
|
|
|
number = true;
|
|
|
|
shiftwidth = 2;
|
2024-02-08 06:26:53 +01:00
|
|
|
# Indent wrapped text.
|
|
|
|
breakindent = true;
|
|
|
|
colorcolumn = "100";
|
2024-02-08 12:54:42 +01:00
|
|
|
showmode = false;
|
2024-02-08 03:17:11 +01:00
|
|
|
};
|
2024-02-08 03:42:16 +01:00
|
|
|
plugins = {
|
2024-02-13 03:01:32 +01:00
|
|
|
# Parser generator tool
|
2024-02-08 12:43:21 +01:00
|
|
|
treesitter.enable = true;
|
2024-02-13 03:01:32 +01:00
|
|
|
# Snippet engine for neovim
|
2024-02-08 12:55:16 +01:00
|
|
|
luasnip.enable = true;
|
2024-02-13 03:01:32 +01:00
|
|
|
# Nix language syntax highlighting / file type associations
|
2024-02-08 12:43:21 +01:00
|
|
|
nix.enable = true;
|
2024-02-13 03:01:32 +01:00
|
|
|
# Run nix develop / shell without exiting vim
|
2024-02-08 12:43:21 +01:00
|
|
|
nix-develop.enable = true;
|
2024-02-13 03:01:32 +01:00
|
|
|
# tab bar like Firefox or Chrome
|
2024-02-08 12:43:21 +01:00
|
|
|
bufferline.enable = true;
|
2024-02-13 03:01:32 +01:00
|
|
|
# Popup to show shortcuts
|
2024-02-08 12:43:21 +01:00
|
|
|
which-key.enable = true;
|
2024-02-13 03:01:32 +01:00
|
|
|
# Automatic indent
|
2024-02-08 12:43:21 +01:00
|
|
|
intellitab.enable = true;
|
2024-02-13 03:01:32 +01:00
|
|
|
# Highlight all entries of the currently selected word
|
2024-02-08 12:55:16 +01:00
|
|
|
illuminate.enable = true;
|
2024-02-13 03:01:32 +01:00
|
|
|
# sidebar file browser
|
|
|
|
nvim-tree.enable = true;
|
|
|
|
# Gutter information for git modifications
|
2024-02-08 12:43:21 +01:00
|
|
|
gitsigns.enable = true;
|
2024-02-13 03:01:32 +01:00
|
|
|
# Terminal in vim
|
2024-02-08 12:43:21 +01:00
|
|
|
toggleterm.enable = true;
|
2024-02-13 03:01:32 +01:00
|
|
|
# Rainbow matching {} [] () 's
|
2024-02-08 12:43:21 +01:00
|
|
|
rainbow-delimiters.enable = true;
|
2024-02-13 03:01:32 +01:00
|
|
|
# Colorize hex colors inline
|
|
|
|
nvim-colorizer.enable = true;
|
2024-02-13 04:40:37 +01:00
|
|
|
# git plugin for vim
|
2024-02-13 04:46:13 +01:00
|
|
|
fugitive.enable = true;
|
2024-02-08 06:06:13 +01:00
|
|
|
|
2024-02-13 05:17:00 +01:00
|
|
|
# Airline / Powerline alternative
|
|
|
|
lualine = {
|
|
|
|
enable = true;
|
|
|
|
componentSeparators = {
|
|
|
|
left = "|";
|
|
|
|
right = "|";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-02-08 06:06:13 +01:00
|
|
|
telescope = {
|
|
|
|
enable = true;
|
2024-02-08 06:32:46 +01:00
|
|
|
extensions.fzf-native.enable = true;
|
|
|
|
keymaps = {
|
|
|
|
"<leader><leader>" = {
|
|
|
|
action = "find_files";
|
|
|
|
desc = "Search files by name";
|
|
|
|
};
|
2024-02-08 11:40:29 +01:00
|
|
|
"<leader>s" = {
|
2024-02-08 06:32:46 +01:00
|
|
|
action = "live_grep";
|
2024-02-08 12:08:01 +01:00
|
|
|
desc = "Search by live grep";
|
2024-02-08 06:32:46 +01:00
|
|
|
};
|
2024-02-08 11:40:29 +01:00
|
|
|
"<leader>b" = {
|
2024-02-08 06:32:46 +01:00
|
|
|
action = "buffers";
|
2024-02-08 12:08:01 +01:00
|
|
|
desc = "Search open [B]uffers by file name";
|
2024-02-08 06:32:46 +01:00
|
|
|
};
|
2024-02-08 11:40:29 +01:00
|
|
|
"<leader>h" = {
|
2024-02-08 06:32:46 +01:00
|
|
|
action = "help_tags";
|
2024-02-08 12:08:01 +01:00
|
|
|
desc = "Search [H]elp";
|
2024-02-08 06:32:46 +01:00
|
|
|
};
|
2024-02-08 11:40:29 +01:00
|
|
|
"<leader>w" = {
|
2024-02-08 06:32:46 +01:00
|
|
|
action = "grep_string";
|
2024-02-08 12:08:01 +01:00
|
|
|
desc = "Search for [W]ord under cursor";
|
2024-02-08 06:32:46 +01:00
|
|
|
};
|
2024-02-13 04:53:16 +01:00
|
|
|
"<leader>gs" = {
|
2024-02-13 04:46:13 +01:00
|
|
|
action = "git_status";
|
2024-02-13 04:53:16 +01:00
|
|
|
desc = "Search [G]it [S]tatus";
|
2024-02-08 06:32:46 +01:00
|
|
|
};
|
2024-02-08 11:40:29 +01:00
|
|
|
"<leader>r" = {
|
2024-02-08 06:32:46 +01:00
|
|
|
action = "oldfiles";
|
2024-02-08 12:08:01 +01:00
|
|
|
desc = "Search [R]ecently opened files by name";
|
2024-02-08 06:32:46 +01:00
|
|
|
};
|
2024-02-08 06:06:13 +01:00
|
|
|
};
|
|
|
|
};
|
2024-02-08 03:42:16 +01:00
|
|
|
|
|
|
|
lsp = {
|
|
|
|
enable = true;
|
|
|
|
servers = {
|
2024-02-08 03:44:30 +01:00
|
|
|
rust-analyzer = {
|
|
|
|
enable = true;
|
|
|
|
installCargo = true;
|
|
|
|
installRustc = true;
|
|
|
|
};
|
2024-02-13 06:47:15 +01:00
|
|
|
pylsp = {
|
|
|
|
enable = true;
|
|
|
|
autostart = true;
|
|
|
|
installLanguageServer = true;
|
|
|
|
settings = {
|
|
|
|
plugins = {
|
|
|
|
black = {
|
|
|
|
enabled = true;
|
|
|
|
preview = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-02-08 04:04:30 +01:00
|
|
|
nixd.enable = true;
|
|
|
|
html.enable = true;
|
|
|
|
cssls.enable = true;
|
|
|
|
bashls.enable = true;
|
2024-02-08 03:42:16 +01:00
|
|
|
};
|
2024-02-13 06:19:41 +01:00
|
|
|
keymaps = {
|
|
|
|
silent = true;
|
|
|
|
diagnostic = {
|
2024-02-13 06:59:40 +01:00
|
|
|
"<leader>lk" = {
|
|
|
|
action = "goto_prev";
|
|
|
|
desc = "Go to prev";
|
|
|
|
};
|
|
|
|
"<leader>lj" = {
|
|
|
|
action = "goto_next";
|
|
|
|
desc = "Go to next";
|
|
|
|
};
|
2024-02-13 06:19:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
lspBuf = {
|
2024-02-13 06:57:05 +01:00
|
|
|
K = {
|
|
|
|
action = "hover";
|
2024-02-13 06:57:54 +01:00
|
|
|
desc = "Hover";
|
2024-02-13 06:57:05 +01:00
|
|
|
};
|
|
|
|
"<leader>lr" = {
|
2024-02-13 06:59:40 +01:00
|
|
|
action = "references";
|
|
|
|
desc = "LSP [r]eferences";
|
2024-02-13 06:57:05 +01:00
|
|
|
};
|
|
|
|
"<leader>ld" = {
|
2024-02-13 06:59:40 +01:00
|
|
|
action = "definition";
|
|
|
|
desc = "LSP [d]efinitions";
|
2024-02-13 06:57:05 +01:00
|
|
|
};
|
|
|
|
"<leader>li" = {
|
2024-02-13 06:59:40 +01:00
|
|
|
action = "implementation";
|
|
|
|
desc = "LSP [i]implementations";
|
2024-02-13 06:57:05 +01:00
|
|
|
};
|
|
|
|
"<leader>lt" = {
|
2024-02-13 06:59:40 +01:00
|
|
|
action = "type_definition";
|
|
|
|
desc = "LSP [t]ype definitions";
|
2024-02-13 06:57:05 +01:00
|
|
|
};
|
|
|
|
"<leader>la" = {
|
2024-02-13 06:59:40 +01:00
|
|
|
action = "code_action";
|
|
|
|
desc = "LSP Code [A]ctions";
|
2024-02-13 06:57:05 +01:00
|
|
|
};
|
2024-02-13 06:19:41 +01:00
|
|
|
};
|
|
|
|
};
|
2024-02-08 03:42:16 +01:00
|
|
|
};
|
2024-02-08 12:51:55 +01:00
|
|
|
|
2024-02-08 03:42:16 +01:00
|
|
|
nvim-cmp = {
|
|
|
|
enable = true;
|
|
|
|
autoEnableSources = true;
|
2024-02-13 03:54:56 +01:00
|
|
|
mapping = {
|
2024-02-13 03:57:10 +01:00
|
|
|
"<C-Space>" = "cmp.mapping.complete()";
|
2024-02-13 03:54:56 +01:00
|
|
|
"<C-d>" = "cmp.mapping.scroll_docs(-4)";
|
|
|
|
"<C-e>" = "cmp.mapping.close()";
|
|
|
|
"<C-f>" = "cmp.mapping.scroll_docs(4)";
|
|
|
|
"<CR>" = "cmp.mapping.confirm({ select = true })";
|
|
|
|
"<S-Tab>" = {
|
|
|
|
action = "cmp.mapping.select_prev_item()";
|
|
|
|
modes = [
|
|
|
|
"i"
|
|
|
|
"s"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
"<Tab>" = {
|
|
|
|
action = "cmp.mapping.select_next_item()";
|
|
|
|
modes = [
|
|
|
|
"i"
|
|
|
|
"s"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2024-02-08 03:42:16 +01:00
|
|
|
sources = [
|
2024-02-09 13:19:35 +01:00
|
|
|
{ name = "nvim_lua"; }
|
2024-02-08 03:42:16 +01:00
|
|
|
{ name = "nvim_lsp"; }
|
|
|
|
{ name = "path"; }
|
|
|
|
{ name = "buffer"; }
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2024-02-08 04:20:38 +01:00
|
|
|
|
2024-02-08 03:17:11 +01:00
|
|
|
colorschemes = {
|
2024-02-08 06:06:13 +01:00
|
|
|
tokyonight.enable = true;
|
|
|
|
gruvbox.enable = true;
|
|
|
|
catppuccin.enable = true;
|
|
|
|
dracula.enable = true;
|
2024-02-08 04:18:12 +01:00
|
|
|
|
2024-02-08 03:17:11 +01:00
|
|
|
};
|
2024-02-08 03:24:24 +01:00
|
|
|
extraPlugins = with pkgs.vimPlugins; [
|
2024-02-08 03:17:11 +01:00
|
|
|
everforest
|
2024-02-13 03:30:44 +01:00
|
|
|
onehalf
|
2024-02-08 03:17:11 +01:00
|
|
|
];
|
|
|
|
};
|
2024-02-08 11:08:43 +01:00
|
|
|
}
|