rearrange and refactor multiple modules

This commit is contained in:
Yan Lin 2026-02-11 20:08:30 +01:00
parent 622265bd6e
commit be7cee9208
13 changed files with 233 additions and 456 deletions

View file

@ -4,14 +4,9 @@
programs.nixvim = {
enable = true;
defaultEditor = true;
# scowl provides English word lists for completion on NixOS
extraPackages = [ pkgs.scowl ];
# Global settings
globals.mapleader = " ";
# Vim options
opts = {
number = true;
relativenumber = false;
@ -20,35 +15,32 @@
tabstop = 2;
smartindent = true;
wrap = true;
linebreak = true; # Don't break words when wrapping
breakindent = true; # Preserve indentation when wrapping
linebreak = true;
breakindent = true;
termguicolors = true;
signcolumn = "yes";
autoread = true; # Automatically reload files when changed externally
clipboard = "unnamedplus"; # Use system clipboard by default
autoread = true;
clipboard = "unnamedplus";
};
# Enable filetype detection
viAlias = true;
vimAlias = true;
# Gruvbox colorscheme with hard contrast
colorschemes.gruvbox = {
enable = true;
settings = {
contrast = "hard"; # Makes background much darker (#1d2021 instead of #282828)
contrast = "hard";
background = "dark";
};
};
# Plugins
plugins = {
bufferline = {
enable = true;
settings = {
options = {
separator_style = [ "" "" ]; # Remove gaps between tabs
separator_style = [ "" "" ];
};
};
};
@ -57,15 +49,14 @@
enable = true;
settings = {
indent = {
char = ""; # Thinner vertical line
char = "";
};
scope = {
enabled = false; # Disable scope highlighting
enabled = false;
};
};
};
# Syntax highlighting
treesitter = {
enable = true;
settings = {
@ -76,7 +67,7 @@
indent = {
enable = true;
};
ensure_installed = []; # Managed by Nix
ensure_installed = [];
auto_install = false;
};
grammarPackages = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [
@ -84,7 +75,6 @@
];
};
# Status line with gruvbox theme and relative paths
lualine = {
enable = true;
settings = {
@ -99,38 +89,13 @@
};
};
# Web dev icons
web-devicons = {
enable = true;
};
# Basic auto-completion
cmp = {
enable = true;
autoEnableSources = true;
settings = {
sources = [
{ name = "buffer"; } # Words from open buffers
{ name = "path"; } # File system paths
{ name = "dictionary"; keyword_length = 2; } # English dictionary words
];
mapping = {
"<C-Space>" = "cmp.mapping.complete()"; # Trigger completion manually
"<C-e>" = "cmp.mapping.close()"; # Close completion menu
"<CR>" = "cmp.mapping.confirm({ select = true })"; # Accept selected completion
"<Tab>" = "cmp.mapping.select_next_item()"; # Navigate down in menu
"<S-Tab>" = "cmp.mapping.select_prev_item()"; # Navigate up in menu
};
};
};
# Telescope - Fuzzy finder
telescope = {
enable = true;
keymaps = {
# Find files using Telescope command-line sugar
"<leader>t" = "find_files";
"<leader>g" = "live_grep";
};
@ -174,7 +139,7 @@
render-markdown = {
enable = true;
settings = {
enabled = false; # Disabled by default
enabled = false;
};
};
@ -214,7 +179,6 @@
border = "rounded";
};
mappings = {
# Keep: navigation & file operations
"." = "set_root";
"<bs>" = "navigate_up";
"<cr>" = "open";
@ -232,7 +196,6 @@
d = "delete";
o = { command = "system_open"; nowait = true; };
f = { command = "show_in_finder"; nowait = true; };
# Disable everything else
"#" = "none";
"/" = "none";
"<" = "none";
@ -292,31 +255,24 @@
};
};
# Extra plugins that don't have dedicated modules
extraPlugins = with pkgs.vimPlugins; [
vim-fugitive
cmp-dictionary
plenary-nvim
];
# Keymaps
keymaps = [
# File explorer (neo-tree)
{
mode = "n";
key = "<leader>e";
action = ":Neotree toggle reveal<CR>";
options = { desc = "Toggle file explorer"; };
}
# Markdown rendering
{
mode = "n";
key = "<leader>m";
action = ":RenderMarkdown toggle<CR>";
options = { desc = "Toggle markdown rendering"; };
}
# Basic keymaps
{
mode = "n";
key = "<leader>w";
@ -335,8 +291,6 @@
action = ":e<CR>";
options = { desc = "Refresh"; };
}
# Buffer/Tab navigation
{
mode = "n";
key = "<S-h>";
@ -364,25 +318,7 @@
];
# Additional Lua configuration for plugins that need custom setup
extraConfigLua = ''
-- Dictionary completion setup
${lib.optionalString pkgs.stdenv.isDarwin ''
require("cmp_dictionary").setup({
paths = { "/usr/share/dict/words" }, -- Standard dictionary path on macOS
exact_length = 2, -- Minimum length before completion
first_case_insensitive = true, -- Case insensitive matching
})
''}
${lib.optionalString (!pkgs.stdenv.isDarwin) ''
require("cmp_dictionary").setup({
paths = { "${pkgs.scowl}/share/dict/wamerican.txt" }, -- Nix-provided dictionary on NixOS
exact_length = 2, -- Minimum length before completion
first_case_insensitive = true, -- Case insensitive matching
})
''}
-- Telescope setup for better file finding
local telescope = require('telescope')
local actions = require('telescope.actions')
@ -397,9 +333,6 @@
}
},
}
-- OSC-52 clipboard integration (matches tmux setup, works with Ghostty)
-- This enables clipboard functionality across SSH, tmux, and multi-platform
-- Only enabled on Linux; macOS uses native clipboard with "unnamedplus"
${lib.optionalString (!pkgs.stdenv.isDarwin) ''
vim.g.clipboard = {
name = 'OSC 52',
@ -414,7 +347,6 @@
}
''}
-- Close all buffers except current (preserving special buffers)
function close_other_buffers()
local current_buf = vim.api.nvim_get_current_buf()
local buffers = vim.api.nvim_list_bufs()
@ -423,7 +355,6 @@
if buf ~= current_buf and vim.api.nvim_buf_is_valid(buf) then
local buftype = vim.api.nvim_buf_get_option(buf, 'buftype')
-- Skip special buffers (terminals, quickfix, etc.)
if buftype == "" then
vim.api.nvim_buf_delete(buf, { force = false })
end
@ -431,7 +362,6 @@
end
end
-- Disable italic for code blocks and strings
vim.api.nvim_set_hl(0, "@markup.raw", { italic = false })
vim.api.nvim_set_hl(0, "@markup.raw.block", { italic = false })
vim.api.nvim_set_hl(0, "@markup.raw.markdown_inline", { italic = false })