Files
lux/modules/features/neovim/default.nix
2026-04-17 00:27:22 +02:00

188 lines
6.0 KiB
Nix

{ inputs, ... }:
{
lux.neovim.homeManager =
{
pkgs,
lib,
config,
...
}:
{
home.sessionVariables = {
EDITOR = "nvim";
VISUAL = "nvim";
};
imports = [
(inputs.nix-wrapper-modules.lib.mkInstallModule {
name = "neovim";
value = inputs.nix-wrapper-modules.lib.wrapperModules.neovim;
loc = [
"home"
"packages"
];
})
];
# Configure sops-nix secret
sops.secrets.gemini-api-key-neovim = {};
wrappers.neovim = {
enable = true;
# Inject the API key into the Neovim environment only
env = {
GEMINI_API_KEY = "$(cat ${config.sops.secrets.gemini-api-key-neovim.path})";
};
# 1. Point to your existing Lua config directory
settings.config_directory = ./lua-config;
# 2. Runtime Dependencies (from lspsAndRuntimeDeps)
# These are added to the PATH of the wrapper
extraPackages = with pkgs; [
# Tools
universal-ctags
ripgrep
fd
tree-sitter
wl-clipboard
# LSPs & Formatters
stylua
lua-language-server
nixd
nix-doc
nixfmt
dafny
typescript
typescript-language-server
rustc
rust-analyzer
rustfmt
astro-language-server
tinymist
typstyle
# ty
# basedpyright
ty
ruff
];
# 3. Plugins (from startupPlugins & optionalPlugins)
# Since you use lz.n in Lua, we just list them all here.
# The wrapper will add them to the packpath.
specs = {
# Core lazy-loading plugin
lz-n = {
data = pkgs.vimPlugins.lz-n;
};
plenary = {
data = pkgs.vimPlugins.plenary-nvim;
};
# All other plugins
general = {
data = with pkgs.vimPlugins; [
nvim-treesitter.withAllGrammars
nvim-treesitter-textobjects
trouble-nvim
guess-indent-nvim
which-key-nvim
telescope-nvim
telescope-fzf-native-nvim
telescope-ui-select-nvim
conform-nvim
blink-cmp
luasnip
friendly-snippets
mini-nvim
nvim-lspconfig
lazydev-nvim
colorful-menu-nvim
lualine-nvim
zen-mode-nvim
kanagawa-nvim
project-nvim
typst-preview-nvim
direnv-vim
codecompanion-nvim
copilot-lua
];
};
};
# 4. Passing Data to Lua (Replacing nixCats.extra)
# We put these in `settings` so they appear in require('nix-info').settings
settings = {
# Hostname/ConfigDir needed for nixd
# NOTE: Adjust these paths to match your actual denful/flake variables
nixdExtras = {
nixpkgs = "import ${pkgs.path} {}";
# Assuming you have access to the flake path in your config,
# otherwise hardcode or pass via specialArgs
nixos_options = ''(builtins.getFlake "path://${config.home.homeDirectory}/.config/nixos").nixosConfigurations.polaris.config.networking.hostName}.options'';
home_manager_options = ''(builtins.getFlake "path://${config.home.homeDirectory}/.config/nixos").nixosConfigurations.polaris.config.networking.hostName}.options.home-manager.users.type.getSubOptions []'';
};
# TODO: Put in separate theme file
themeSetup = # lua
''
require("kanagawa").setup({
colors = {
theme = {
all = {
ui = {
bg_gutter = "none"
}
}
}
},
overrides = function(colors)
local theme = colors.theme
local makeDiagnosticColor = function(color)
local c = require("kanagawa.lib.color")
return { fg = color, bg = c(color):blend(theme.ui.bg, 0.95):to_hex() }
end
return {
TelescopeTitle = { fg = theme.ui.special, bold = true },
TelescopePromptNormal = { bg = theme.ui.bg_p1 },
TelescopePromptBorder = { fg = theme.ui.bg_p1, bg = theme.ui.bg_p1 },
TelescopeResultsNormal = { fg = theme.ui.fg_dim, bg = theme.ui.bg_m1 },
TelescopeResultsBorder = { fg = theme.ui.bg_m1, bg = theme.ui.bg_m1 },
TelescopePreviewNormal = { bg = theme.ui.bg_dim },
TelescopePreviewBorder = { bg = theme.ui.bg_dim, fg = theme.ui.bg_dim },
Pmenu = { fg = theme.ui.shade0, bg = theme.ui.bg_p1 }, -- add `blend = vim.o.pumblend` to enable transparency
PmenuSel = { fg = "NONE", bg = theme.ui.bg_p2 },
PmenuSbar = { bg = theme.ui.bg_m1 },
PmenuThumb = { bg = theme.ui.bg_p2 },
DiagnosticVirtualTextHint = makeDiagnosticColor(theme.diag.hint),
DiagnosticVirtualTextInfo = makeDiagnosticColor(theme.diag.info),
DiagnosticVirtualTextWarn = makeDiagnosticColor(theme.diag.warning),
DiagnosticVirtualTextError = makeDiagnosticColor(theme.diag.error),
}
end,
})
vim.cmd.colorscheme("kanagawa-wave")
'';
};
# 5. Wrapper Configuration
# Enable Python/Node providers
hosts.python3.nvim-host.enable = true;
hosts.node.nvim-host.enable = true;
# Ensure the bin name matches what you expect
binName = "nvim";
};
};
}