nix/home-manager/common/software/cli/nixvim/base.nix
2024-08-14 08:26:41 +09:00

304 lines
7.8 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
home.packages = with pkgs; [
# Linters
yamllint
hadolint
nixfmt-rfc-style
vale
];
# Docs:
# https://nix-community.github.io/nixvim/
programs.nixvim = {
enable = true;
viAlias = true;
vimAlias = true;
globals.mapleader = " ";
globals.maplocalleader = " ";
opts = {
number = true;
wrap = false;
cursorline = true;
cursorcolumn = true;
shiftwidth = 2;
breakindent = true;
colorcolumn = "100";
showmode = false;
termguicolors = true;
};
extraConfigLuaPost = ''
vim.opt.shell = '/run/current-system/sw/bin/fish'
'';
plugins = {
# Git related
# Gutter information for git modifications
gitsigns.enable = true;
# git plugin for vim
fugitive.enable = true;
# pretty stuff
# Fancify markdown et al
headlines.enable = true;
# Rainbow matching {} [] () 's
rainbow-delimiters.enable = true;
# Colorize hex colors inline
nvim-colorizer.enable = true;
# Fancy popups, etc for vim
noice = {
enable = true;
popupmenu.enabled = false;
lsp.hover.enabled = false;
presets = {
bottom_search = true;
command_palette = true;
long_message_to_split = false;
inc_rename = false;
lsp_doc_border = true;
};
};
notify = {
enable = true;
topDown = true;
fps = 60;
stages = "slide";
};
# 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;
# Better yank
yanky.enable = 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;
hover.enabled = true;
separatorStyle = "slant";
offsets = [{
filetype = "NvimTree";
text = "File Explorer";
highlight = "EcovimNvimTreeTitle";
text_align = "center";
separator = true;
}];
};
# sidebar file browser
nvim-tree = {
enable = true;
diagnostics.enable = true;
tab.sync.close = true;
renderer = {
highlightModified = "icon";
highlightOpenedFiles = "all";
indentMarkers.enable = true;
};
};
# Terminal in vim
toggleterm.enable = true;
# Alerts / CodeActions
trouble = {
enable = true;
settings = {
auto_close = true;
cycle_results = false;
height = 14;
win_config = {
border = "rounded";
};
};
};
# Code Related
# Parser generator tool
treesitter.enable = true;
# Status column with click hanlers
statuscol = {
enable = true;
settings = {
bt_ignore = null;
clickhandlers = {
FoldClose = "require('statuscol.builtin').foldclose_click";
FoldOpen = "require('statuscol.builtin').foldopen_click";
FoldOther = "require('statuscol.builtin').foldother_click";
Lnum = "require('statuscol.builtin').lnum_click";
};
clickmod = "c";
ft_ignore = null;
relculright = true;
segments = [
{
click = "v:lua.ScFa";
text = [
"%C"
];
}
{
click = "v:lua.ScSa";
text = [
"%s"
];
}
{
click = "v:lua.ScLa";
condition = [
true
{
__raw = "require('statuscol.builtin').not_empty";
}
];
text = [
{
__raw = "require('statuscol.builtin').lnumfunc";
}
" "
];
}
];
setopt = true;
thousands = ".";
};
};
# 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;
window.border = "rounded";
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";
options.desc = "Search files by name";
};
"<leader>s" = {
action = "live_grep";
options.desc = "Search by live grep";
};
"<leader>bl" = {
action = "buffers";
options.desc = "[L]list open [B]uffers";
};
"<leader>h" = {
action = "help_tags";
options.desc = "Search [H]elp";
};
"<leader>W" = {
action = "grep_string";
options.desc = "Search for [W]ord under cursor";
};
"<leader>gs" = {
action = "git_status";
options.desc = "Search [G]it [S]tatus";
};
"<leader>gl" = {
action = "git_commits";
options.desc = "View [G]it [L]ogs";
};
"<leader>r" = {
action = "oldfiles";
options.desc = "Search [R]ecently opened files by name";
};
"<leader>cs" = {
action = "colorscheme";
options.desc = "Change [C]olor[s]cheme";
};
};
};
};
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
rust-vim
outline-nvim
];
};
}