156 lines
3.8 KiB
Nix
156 lines
3.8 KiB
Nix
src:
|
|
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.programs.nvim-config;
|
|
full = cfg.profile == "full";
|
|
|
|
# Slim also needs tree-sitter and a C compiler so its few parsers can compile.
|
|
baseTools = with pkgs; [
|
|
ripgrep
|
|
fd
|
|
git
|
|
tree-sitter
|
|
stdenv.cc
|
|
];
|
|
|
|
# rustup supplies cargo, rustfmt, clippy and rust-analyzer (and the nightly
|
|
# toolchain fff builds with), so those are not listed separately.
|
|
fullTools = with pkgs; [
|
|
lazygit
|
|
rustup
|
|
cargo-nextest
|
|
llama-cpp
|
|
|
|
# snacks.image: magick converts, gs renders PDFs, tectonic LaTeX, mmdc mermaid
|
|
imagemagick
|
|
ghostscript
|
|
tectonic
|
|
mermaid-cli
|
|
|
|
nixd
|
|
nixfmt
|
|
lua-language-server
|
|
stylua
|
|
bash-language-server
|
|
shfmt
|
|
shellcheck
|
|
yaml-language-server
|
|
vscode-langservers-extracted
|
|
marksman
|
|
prettierd
|
|
|
|
go
|
|
gopls
|
|
gotools
|
|
gofumpt
|
|
golangci-lint
|
|
delve
|
|
|
|
gomodifytags # gopher.nvim
|
|
gotests
|
|
iferr
|
|
impl
|
|
|
|
bacon
|
|
|
|
tinymist # typst LSP and typst-preview.nvim
|
|
websocat
|
|
typst
|
|
|
|
vtsls
|
|
vscode-js-debug
|
|
|
|
basedpyright
|
|
ruff
|
|
|
|
intelephense # unfree: the host must allow it
|
|
mago # php formatter and linter
|
|
jq # json formatter
|
|
];
|
|
|
|
# nixpkgs' mago 1.59 fails to build: zstd-sys finds no libzstd via pkg-config.
|
|
# shortcut: drop once nixpkgs adds zstd to mago.
|
|
mago = pkgs.mago.overrideAttrs (old: {
|
|
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.pkg-config ];
|
|
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.zstd ];
|
|
});
|
|
|
|
# Kept out of home.packages to avoid colliding with other pythons/nodes.
|
|
debugpy = pkgs.python3.withPackages (ps: [ ps.debugpy ]);
|
|
lldb = pkgs.vscode-extensions.vadimcn.vscode-lldb;
|
|
phpDebug = pkgs.vscode-extensions.xdebug.php-debug;
|
|
in
|
|
{
|
|
options.programs.nvim-config = {
|
|
enable = lib.mkEnableOption "the nvim-config Neovim setup";
|
|
|
|
profile = lib.mkOption {
|
|
type = lib.types.enum [
|
|
"full"
|
|
"slim"
|
|
];
|
|
default = "full";
|
|
description = "full for dev machines, slim for servers.";
|
|
};
|
|
|
|
checkout = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.str;
|
|
default = null;
|
|
example = "/Users/johannes/Repos/nvim";
|
|
description = ''
|
|
Absolute path to a local checkout. When set, ~/.config/nvim links to it
|
|
out of store so edits apply without a switch. When null, it links to
|
|
the flake source in the Nix store.
|
|
'';
|
|
};
|
|
|
|
minuetEndpoint = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "http://127.0.0.1:8012";
|
|
description = "Base URL of the llama-server used for AI completion.";
|
|
};
|
|
|
|
agent = {
|
|
command = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "agent";
|
|
description = "Command sidekick.nvim runs for the agent tool.";
|
|
};
|
|
package = lib.mkOption {
|
|
type = lib.types.nullOr lib.types.package;
|
|
default = null;
|
|
description = "Package providing the agent binary.";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
home.packages = [
|
|
pkgs.neovim
|
|
]
|
|
++ baseTools
|
|
++ lib.optionals full fullTools
|
|
++ lib.optional (full && cfg.agent.package != null) cfg.agent.package;
|
|
|
|
home.sessionVariables = {
|
|
NVIM_PROFILE = cfg.profile;
|
|
}
|
|
// lib.optionalAttrs full {
|
|
MINUET_ENDPOINT = cfg.minuetEndpoint;
|
|
NVIM_AGENT_CMD = cfg.agent.command;
|
|
NVIM_CODELLDB = "${lldb}/share/vscode/extensions/vadimcn.vscode-lldb/adapter/codelldb";
|
|
NVIM_DEBUGPY_PYTHON = "${debugpy}/bin/python3";
|
|
NVIM_PHP_DEBUG = "${phpDebug}/share/vscode/extensions/xdebug.php-debug/out/phpDebug.js";
|
|
NVIM_NODE = "${pkgs.nodejs}/bin/node";
|
|
};
|
|
|
|
xdg.configFile."nvim".source =
|
|
if cfg.checkout != null then config.lib.file.mkOutOfStoreSymlink cfg.checkout else src;
|
|
};
|
|
}
|