Files
NixOS/modules/neovim/home.nix
Cookiez cf1470cb63 Added Neovim Plugins:
- Remenber where you exited file
- Limited treesitter header context
- Added autocompletion
2026-03-24 09:30:30 +01:00

179 lines
4.6 KiB
Nix

{
inputs,
config,
lib,
pkgs,
...
}: {
imports = [
inputs.nixvim.homeModules.nixvim
];
programs.nixvim = {
enable = true;
waylandSupport = true;
# Basic options
opts = {
autoindent = true;
clipboard = "unnamedplus";
shiftwidth = 2;
mousescroll = "ver:0,hor:0";
expandtab = true; # Always insert spaces, never hard tab characters
tabstop = 2; # Make hard tabs display as 2 columns (matches shiftwidth)
softtabstop = 2; # Backspace deletes 2 spaces at a time
number = true;
relativenumber = true;
cursorline = true; # Highlights the entire current line
cursorlineopt = "both"; # Highlights both the line AND the line number
termguicolors = true;
};
colorschemes.catppuccin = {
enable = true;
settings = {
flavour = "mocha";
term_colors = true;
styles = {
booleans = ["bold" "italic"];
conditionals = ["bold"];
functions = ["bold"];
keywords = ["italic"];
};
};
};
keymaps = [
{
mode = "v";
key = ">";
action = ">gv";
options.desc = "Indent and keep selection";
}
{
mode = "v";
key = "<";
action = "<gv";
options.desc = "Unindent and keep selection";
}
];
plugins = {
# Remeber where you left the file last time
lastplace.enable = true;
# Statusline at the bottom of the screen
lualine.enable = true;
# Tab bar at the top of the screen
bufferline.enable = true;
# File type icons used by many UI plugins (Dependency)
web-devicons.enable = true;
# Replaces the default cmdline, messages, and popupmenu with a nicer UI
noice.enable = true;
# Popup notification manager
notify.enable = true;
treesitter = {
# Syntax parsing for accurate highlighting and code understanding
enable = true;
settings = {
highlight.enable = true;
indent.enable = true;
};
};
# Shows the current function/class context pinned at the top of the buffer
treesitter-context = {
enable = true;
settings = {
# Cap the context header
max_lines = 4;
# When over the limit, drop outermost context
trim_scope = "outer";
# Only show context in tall-enough windows
min_window_height = 20;
};
};
# Provides autocompletion suggestions
blink-cmp = {
enable = true;
settings = {
keymap.preset = "default"; # Tab/S-Tab to navigate, Enter to confirm
sources.default = ["lsp" "path" "snippets" "buffer"];
completion = {
documentation.auto_show = true;
ghost_text.enabled = true; # inline preview of the top suggestion
};
};
};
lsp = {
enable = true;
servers = {
nixd.enable = true; # Nix
ts_ls.enable = true; # TypeScript/JavaScript
# ... add more as needed
};
};
# Text objects based on treesitter nodes (e.g. select a function body)
treesitter-textobjects.enable = true;
# Auto-closes and renames HTML/JSX tags using treesitter
ts-autotag.enable = true;
# Adds indentation guide lines to every indent level
indent-blankline = {
enable = true;
settings = {
indent = {
char = "";
tab_char = ""; # Explicitly define the tab indent guide character
};
scope = {
enabled = true;
};
whitespace = {
remove_blankline_trail = false;
};
};
};
# Highlights and searches TODO/FIXME/HACK comments
todo-comments.enable = true;
nvim-autopairs = {
enable = true;
settings = {
check_ts = true; # Use treesitter to avoid pairing inside strings/comments
};
};
conform-nvim = {
enable = true;
settings = {
formatters_by_ft = {
nix = ["alejandra"];
};
format_on_save = {
lsp_format = "fallback";
timeout_ms = 500;
};
};
# Pin the exact binary path so Nix guarantees it's available
settings.formatters = {
alejandra.command = "${pkgs.alejandra}/bin/alejandra";
};
};
};
extraPlugins = with pkgs.vimPlugins; [
];
# Additional Lua configuration
extraConfigLua = ''
-- Custom Lua config here
vim.opt.cpoptions:append('I')
'';
};
}