nix/home-manager/common/software/cli/nixvim/base.nix
2024-04-02 18:23:07 +09:00

271 lines
7.1 KiB
Nix

{ inputs, pkgs, lib, theme, ... }: {
imports = [
./alpha.nix
./keymaps.nix
inputs.nixvim.homeManagerModules.nixvim
] ++ lib.optional (builtins.isString theme) ../../../../../stylix/themes/${theme}/home-manager/nixvim.nix;
# https://github.com/nix-community/nixvim
# Docs:
# https://nix-community.github.io/nixvim/
programs.nixvim = {
enable = true;
viAlias = true;
vimAlias = true;
globals.mapleader = " ";
globals.maplocalleader = " ";
options = {
number = true;
wrap = false;
cursorline = true;
cursorcolumn = true;
shiftwidth = 2;
breakindent = true;
colorcolumn = "100";
showmode = false;
termguicolors = true;
};
plugins = {
# Testing
noice = {
enable = true;
popupmenu.enabled = true;
};
notify = {
enable = true;
topDown = true;
fps = 60;
stages = "slide";
};
# Git related
# Gutter information for git modifications
gitsigns.enable = true;
# git plugin for vim
fugitive.enable = true;
# pretty stuff
# Rainbow matching {} [] () 's
rainbow-delimiters.enable = true;
# Colorize hex colors inline
nvim-colorizer.enable = true;
# Nix related
# Nix language syntax highlighting / file type associations
nix.enable = true;
# Run nix develop / shell without exiting vim
nix-develop.enable = true;
# Efficiency
# Multicursor support
multicursors.enable = true;
# auto bracket completion
nvim-autopairs.enable = true;
# Indentation guides
indent-blankline.enable = true;
# Surround text blocks
surround.enable = true;
# Automatic indent
intellitab.enable = true;
# Code navigation
navbuddy.enable = true;
navbuddy.lsp.autoAttach = true;
# Layout Related
# winbar that uses nvim-navic in order to get LSP context from your language server.
barbecue.enable = true;
# tab bar like Firefox or Chrome
bufferline.enable = true;
# sidebar file browser
nvim-tree.enable = true;
# Terminal in vim
toggleterm.enable = true;
# Alerts / CodeActions
trouble.enable = true;
# Code Related
# Parser generator tool
treesitter.enable = true;
# Snippet engine for neovim
luasnip.enable = true;
cmp_luasnip.enable = true;
# CMP Addons
# cmp-buffer.enable = true;
# cmp-path.enable = true;
# cmp-nvim-lsp.enable = true;
# cmp-nvim-lsp-document-symbol.enable = true;
# cmp-nvim-lsp-signature-help.enable = true;
# List of linters for nixvim
lint = {
enable = true;
lintersByFt = {
text = ["vale"];
json = ["jsonlint"];
markdown = ["vale"];
rst = ["vale"];
ruby = ["ruby"];
janet = ["janet"];
inko = ["inko"];
clojure = ["clj-kondo"];
dockerfile = ["hadolint"];
terraform = ["tflint"];
yaml = ["yamllint"];
nix = ["nix"];
};
};
# Popup to show shortcuts
which-key = {
enable = true;
registrations = {
"<leader>b" = "Manage buffers...";
"<leader>c" = "Colorscheme...";
"<leader>g" = "Git Options...";
"<leader>l" = "LSP Options...";
"<leader>n" = "NvimTree / Noice...";
"<leader>t" = "Trouble...";
"<leader>T" = "ToggleTerm...";
"<leader>w" = "Manage Windows...";
"<leader>wo" = "Open New...";
"<leader>wr" = "Resize...";
"<leader>m" = "Multicursor...";
};
};
# Airline / Powerline alternative
lualine = {
enable = true;
componentSeparators = {
right = "«";
left = "»";
};
sectionSeparators = {
right = "";
left = "";
};
};
telescope = {
enable = true;
extensions.fzf-native.enable = true;
keymaps = {
"<leader><leader>" = {
action = "find_files";
desc = "Search files by name";
};
"<leader>s" = {
action = "live_grep";
desc = "Search by live grep";
};
"<leader>bl" = {
action = "buffers";
desc = "[L]list open [B]uffers";
};
"<leader>h" = {
action = "help_tags";
desc = "Search [H]elp";
};
"<leader>W" = {
action = "grep_string";
desc = "Search for [W]ord under cursor";
};
"<leader>gs" = {
action = "git_status";
desc = "Search [G]it [S]tatus";
};
"<leader>gl" = {
action = "git_commits";
desc = "View [G]it [L]ogs";
};
"<leader>r" = {
action = "oldfiles";
desc = "Search [R]ecently opened files by name";
};
"<leader>cs" = {
action = "colorscheme";
desc = "Change [C]olor[s]cheme";
};
};
};
nvim-cmp = {
enable = true;
autoEnableSources = true;
mapping = {
"<C-Space>" = "cmp.mapping.complete()";
"<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"
];
};
};
sources = [
# { name = "nvim_lua"; }
{ name = "nvim_lsp"; }
{ name = "nvim_lsp_signature_help"; }
{ name = "calc"; }
{ name = "path"; }
{ name = "buffer"; }
{ name = "luasnip"; }
];
snippet.expand = "luasnip";
window = {
completion.border = "rounded";
documentation.border = "rounded";
};
formatting = {
fields = [ "menu" "abbr" "kind" ];
# https://rsdlt.github.io/posts/rust-nvim-ide-guide-walkthrough-development-debug/
format = ''
function(entry, item)
local menu_icon = {
nvim_lsp = 'λ',
luasnip = '',
buffer = 'Ω',
path = '🖫',
}
item.menu = menu_icon[entry.source.name]
return item
end,
'';
};
};
};
colorschemes = {
tokyonight.enable = true;
gruvbox.enable = true;
catppuccin.enable = true;
dracula.enable = true;
oxocarbon.enable = true;
ayu.enable = true;
kanagawa.enable = true;
};
extraPlugins = with pkgs.vimPlugins; [
everforest
onedark-nvim
rose-pine
melange-nvim
];
};
}