nix/home-manager/common/software/cli/nixvim/base.nix
2024-06-06 22:01:33 +09:00

254 lines
6.5 KiB
Nix

{ inputs, pkgs, lib, theme, ... }: {
imports = [
./alpha.nix
./keymaps.nix
./cmp.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;
};
extraConfigLuaPost = ''
vim.opt.shell = '/run/current-system/sw/bin/bash'
'';
plugins = {
# Git related
# Gutter information for git modifications
gitsigns.enable = true;
# git plugin for vim
fugitive.enable = true;
# pretty stuff
# Fancify markdown et al
# TODO Re-enable this after 24.05
# 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;
# 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;
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;
# TODO Re-enable on 24.05
# settings = {
# auto_close = true;
# auto_open = true;
# cycle_results = false;
# height = 14;
# win_config = {
# border = "rounded";
# };
# };
};
# Code Related
# Parser generator tool
treesitter.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;
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
];
};
}