mirror of
https://github.com/dwinkler1/nvimConfig.git
synced 2026-11-22 07:44:40 -05:00
init wrapper-module config
This commit is contained in:
commit
91755583fd
46 changed files with 4277 additions and 0 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
use flake
|
||||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
.DS_Store
|
||||||
|
.direnv
|
||||||
133
flake.lock
generated
Normal file
133
flake.lock
generated
Normal file
|
|
@ -0,0 +1,133 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"fran": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"rixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1768802006,
|
||||||
|
"narHash": "sha256-czGb4RwTBahNNK9S7ySXeTWIrn/jKH+74hN/uIS2XrM=",
|
||||||
|
"owner": "dwinkler1",
|
||||||
|
"repo": "fran",
|
||||||
|
"rev": "a3879317519fd3685f3b7679a1de4c5ae65a7cb9",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "dwinkler1",
|
||||||
|
"repo": "fran",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1769598131,
|
||||||
|
"narHash": "sha256-e7VO/kGLgRMbWtpBqdWl0uFg8Y2XWFMdz0uUJvlML8o=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "fa83fd837f3098e3e678e6cf017b2b36102c7211",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "nixos-25.11",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"plugins-cmp-pandoc-references": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1743491695,
|
||||||
|
"narHash": "sha256-XsdneGNJzmRBggk8lz9JNDQYk7wbYfUAF2oZLXzFb9c=",
|
||||||
|
"owner": "jmbuhr",
|
||||||
|
"repo": "cmp-pandoc-references",
|
||||||
|
"rev": "130eae4f75029d6495808e0ea4b769fa1ce4c9ac",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "jmbuhr",
|
||||||
|
"repo": "cmp-pandoc-references",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"plugins-cmp-r": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1764700377,
|
||||||
|
"narHash": "sha256-xb7VFWM/BKAkN7fg62y8n618t2qkQjdYbPwhBhLJwtk=",
|
||||||
|
"owner": "R-nvim",
|
||||||
|
"repo": "cmp-r",
|
||||||
|
"rev": "70bfe8f4c062acc10266e24825439c009a0b1b89",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "R-nvim",
|
||||||
|
"repo": "cmp-r",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"plugins-r": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1769736135,
|
||||||
|
"narHash": "sha256-T4QgcBL+LCXvrEiRE2JW4jtUKl8DKzFHk8czGUO1jgY=",
|
||||||
|
"owner": "R-nvim",
|
||||||
|
"repo": "R.nvim",
|
||||||
|
"rev": "2701ec64f5485e17c0e057081a9ae2058d776464",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "R-nvim",
|
||||||
|
"repo": "R.nvim",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1768825970,
|
||||||
|
"narHash": "sha256-m/BI9IO7tMuOSdVNSqr0knQ4V9R6rgSXyGQOp3FovSA=",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/rstats-on-nix/nixpkgs/archive/2026-01-19.tar.gz"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/rstats-on-nix/nixpkgs/archive/2026-01-19.tar.gz"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"fran": "fran",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"plugins-cmp-pandoc-references": "plugins-cmp-pandoc-references",
|
||||||
|
"plugins-cmp-r": "plugins-cmp-r",
|
||||||
|
"plugins-r": "plugins-r",
|
||||||
|
"rixpkgs": "rixpkgs",
|
||||||
|
"wrappers": "wrappers"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"wrappers": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1769731670,
|
||||||
|
"narHash": "sha256-iHq0bwOsDI5IkJuxVsljdztZdVKIBb8yO0RBRMrco68=",
|
||||||
|
"owner": "BirdeeHub",
|
||||||
|
"repo": "nix-wrapper-modules",
|
||||||
|
"rev": "4622dd5ef8e152475fce48307d3bc77211249c6a",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "BirdeeHub",
|
||||||
|
"repo": "nix-wrapper-modules",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
202
flake.nix
Normal file
202
flake.nix
Normal file
|
|
@ -0,0 +1,202 @@
|
||||||
|
# Copyright (c) 2026 BirdeeHub
|
||||||
|
# Licensed under the MIT license
|
||||||
|
{
|
||||||
|
description = "Daniel's NixCats";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
|
||||||
|
wrappers = {
|
||||||
|
url = "github:BirdeeHub/nix-wrapper-modules";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
rixpkgs.url = "https://github.com/rstats-on-nix/nixpkgs/archive/2026-01-19.tar.gz";
|
||||||
|
|
||||||
|
fran = {
|
||||||
|
url = "github:dwinkler1/fran";
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.follows = "rixpkgs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
"plugins-r" = {
|
||||||
|
url = "github:R-nvim/R.nvim";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
"plugins-cmp-r" = {
|
||||||
|
url = "github:R-nvim/cmp-r";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
"plugins-cmp-pandoc-references" = {
|
||||||
|
url = "github:jmbuhr/cmp-pandoc-references";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = {
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
wrappers,
|
||||||
|
...
|
||||||
|
} @ inputs: let
|
||||||
|
wrapperSettings = pkgs:
|
||||||
|
wrapper.config.wrap {
|
||||||
|
inherit pkgs;
|
||||||
|
cats = {
|
||||||
|
clickhouse = false;
|
||||||
|
gitPlugins = false;
|
||||||
|
julia = false;
|
||||||
|
lua = false;
|
||||||
|
markdown = false;
|
||||||
|
nix = true;
|
||||||
|
optional = false;
|
||||||
|
python = false;
|
||||||
|
r = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
settings.lang_packages = {
|
||||||
|
python = with pkgs.python3Packages; [
|
||||||
|
duckdb
|
||||||
|
polars
|
||||||
|
];
|
||||||
|
|
||||||
|
r = with pkgs.rpkgs.rPackages; [
|
||||||
|
arrow
|
||||||
|
broom
|
||||||
|
data_table
|
||||||
|
duckdb
|
||||||
|
janitor
|
||||||
|
styler
|
||||||
|
tidyverse
|
||||||
|
];
|
||||||
|
|
||||||
|
julia = ["DataFramesMeta" "QuackIO"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systems = [
|
||||||
|
"aarch64-darwin"
|
||||||
|
"x86_64-linux"
|
||||||
|
"aarch64-linux"
|
||||||
|
];
|
||||||
|
|
||||||
|
forAllSystems = nixpkgs.lib.genAttrs systems;
|
||||||
|
|
||||||
|
extra_pkg_config = {
|
||||||
|
# allowUnfree = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
overlayDefs = import ./overlays inputs;
|
||||||
|
|
||||||
|
dependencyOverlays = overlayDefs.dependencyOverlays;
|
||||||
|
|
||||||
|
dependencyOverlay = overlayDefs.dependencyOverlay;
|
||||||
|
|
||||||
|
mkPkgs = system:
|
||||||
|
import nixpkgs {
|
||||||
|
inherit system;
|
||||||
|
config = extra_pkg_config;
|
||||||
|
overlays = [dependencyOverlay];
|
||||||
|
};
|
||||||
|
|
||||||
|
module = nixpkgs.lib.modules.importApply ./modules/neovim.nix inputs;
|
||||||
|
wrapper = wrappers.lib.evalModule module;
|
||||||
|
in {
|
||||||
|
overlays = {
|
||||||
|
default = nixpkgs.lib.composeManyExtensions [
|
||||||
|
dependencyOverlay
|
||||||
|
(final: prev: {
|
||||||
|
n = wrapper.config.wrap {pkgs = final;};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
dependencies = dependencyOverlay;
|
||||||
|
n = self.overlays.default;
|
||||||
|
};
|
||||||
|
|
||||||
|
wrapperModules = {
|
||||||
|
default = module;
|
||||||
|
neovim = self.wrapperModules.default;
|
||||||
|
};
|
||||||
|
|
||||||
|
wrappers = {
|
||||||
|
default = wrapper.config;
|
||||||
|
neovim = self.wrappers.default;
|
||||||
|
};
|
||||||
|
|
||||||
|
packages = forAllSystems (
|
||||||
|
system: let
|
||||||
|
pkgs = mkPkgs system;
|
||||||
|
nvimPkg = wrapperSettings pkgs;
|
||||||
|
in {
|
||||||
|
default = nvimPkg;
|
||||||
|
n = nvimPkg;
|
||||||
|
vim = nvimPkg;
|
||||||
|
nvim = nvimPkg;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
formatter = forAllSystems (
|
||||||
|
system: let
|
||||||
|
pkgs = mkPkgs system;
|
||||||
|
in
|
||||||
|
pkgs.nixfmt-tree
|
||||||
|
);
|
||||||
|
|
||||||
|
devShells = forAllSystems (
|
||||||
|
system: let
|
||||||
|
pkgs = mkPkgs system;
|
||||||
|
nvimPkg = wrapperSettings pkgs;
|
||||||
|
in {
|
||||||
|
default = pkgs.mkShell {
|
||||||
|
name = "n";
|
||||||
|
packages = [nvimPkg];
|
||||||
|
nativeBuildInputs = with pkgs; [] ++ (pkgs.lib.optionals self.wrappers.default.cats.optional [devenv]);
|
||||||
|
inputsFrom = [];
|
||||||
|
shellHook = "";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
checks = forAllSystems (
|
||||||
|
system: let
|
||||||
|
pkgs = mkPkgs system;
|
||||||
|
nvimPkg = wrapperSettings pkgs;
|
||||||
|
in {
|
||||||
|
default = nvimPkg;
|
||||||
|
module-eval = let
|
||||||
|
_ = wrapper.config;
|
||||||
|
in
|
||||||
|
pkgs.runCommand "check-module-eval" {} ''
|
||||||
|
echo "Module evaluation successful" > $out
|
||||||
|
'';
|
||||||
|
package-build = pkgs.runCommand "check-n" {} ''
|
||||||
|
BINARY_PATH="${nvimPkg}/bin/n"
|
||||||
|
|
||||||
|
if [ ! -x "$BINARY_PATH" ]; then
|
||||||
|
echo "Error: Binary n not found or not executable"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
"$BINARY_PATH" --version > version_output.txt 2>&1 || true
|
||||||
|
|
||||||
|
echo "Package validation successful" > $out
|
||||||
|
echo "Binary location: $BINARY_PATH" >> $out
|
||||||
|
if [ -s version_output.txt ]; then
|
||||||
|
echo "Version output:" >> $out
|
||||||
|
cat version_output.txt >> $out
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
nixosModules.default = wrappers.lib.mkInstallModule {
|
||||||
|
name = "n";
|
||||||
|
value = module;
|
||||||
|
};
|
||||||
|
|
||||||
|
homeModules.default = wrappers.lib.mkInstallModule {
|
||||||
|
name = "n";
|
||||||
|
value = module;
|
||||||
|
loc = ["home" "packages"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
6
ftplugin/julia.lua
Normal file
6
ftplugin/julia.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
vim.b.slime_cell_delimiter = vim.b.slime_cell_delimiter or "# %%"
|
||||||
|
|
||||||
|
local ts_lib = Config.treesitter_helpers
|
||||||
|
|
||||||
|
local global_nodes_julia = { 'source_file', 'module_definition' }
|
||||||
|
ts_lib.setup_keybindings(global_nodes_julia)
|
||||||
32
ftplugin/markdown.lua
Normal file
32
ftplugin/markdown.lua
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
-- Add the key mappings only for Markdown files in a zk notebook.
|
||||||
|
if require("zk.util").notebook_root(vim.fn.expand('%:p')) ~= nil then
|
||||||
|
local map = vim.keymap.set
|
||||||
|
-- Open the link under the caret.
|
||||||
|
map("n", "<CR>", "<Cmd>lua vim.lsp.buf.definition()<CR>", { noremap = true, silent = false, buffer = true })
|
||||||
|
|
||||||
|
-- Create a new note after asking for its title.
|
||||||
|
-- This overrides the global `<leader>zn` mapping to create the note in the same directory as the current buffer.
|
||||||
|
map("n", "<leader>zhn", "<Cmd>ZkNew { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<CR>",
|
||||||
|
{ noremap = true, silent = false, buffer = true, desc = "Note (here)" })
|
||||||
|
-- Create a new note in the same directory as the current buffer, using the current selection for title.
|
||||||
|
map("v", "<leader>zhnt", ":'<,'>ZkNewFromTitleSelection { dir = vim.fn.expand('%:p:h') }<CR>",
|
||||||
|
{ noremap = true, silent = false, buffer = true, desc = "Note from selection (title)" })
|
||||||
|
-- Create a new note in the same directory as the current buffer, using the current selection for note content and asking for its title.
|
||||||
|
map("v", "<leader>zhnc",
|
||||||
|
":'<,'>ZkNewFromContentSelection { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<CR>",
|
||||||
|
{ noremap = true, silent = false, buffer = true, desc = "Note from selection (content)" })
|
||||||
|
|
||||||
|
-- Open notes linking to the current buffer.
|
||||||
|
map("n", "<leader>zb", "<Cmd>ZkBacklinks<CR>", { noremap = true, silent = false, buffer = true, desc = "Backlinks" })
|
||||||
|
-- Alternative for backlinks using pure LSP and showing the source context.
|
||||||
|
--map('n', '<leader>zb', '<Cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||||
|
-- Open notes linked by the current buffer.
|
||||||
|
map("n", "<leader>zL", "<Cmd>ZkLinks<CR>", { noremap = true, silent = false, buffer = true, desc = "Links" })
|
||||||
|
map("n", "<leader>zi", "<Cmd>ZkInsertLink<CR>", { noremap = true, silent = false, buffer = true, desc = "Insert link" })
|
||||||
|
|
||||||
|
-- Preview a linked note.
|
||||||
|
-- Open the code actions for a visual selection.
|
||||||
|
map("v", "<leader>za", ":'<,'>lua vim.lsp.buf.range_code_action()<CR>",
|
||||||
|
{ noremap = true, silent = false, buffer = true, desc = "Code actions" })
|
||||||
|
|
||||||
|
end
|
||||||
20
ftplugin/python.lua
Normal file
20
ftplugin/python.lua
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
vim.g.slime_python_ipython = 1
|
||||||
|
vim.b.slime_cell_delimiter = vim.b.slime_cell_delimiter or "# %%"
|
||||||
|
|
||||||
|
local ts_lib = Config.treesitter_helpers
|
||||||
|
local global_nodes_python = { 'module' }
|
||||||
|
ts_lib.setup_keybindings(global_nodes_python)
|
||||||
|
|
||||||
|
local conform_format_group =
|
||||||
|
vim.api.nvim_create_augroup("PythonConformFormat_" .. vim.api.nvim_get_current_buf(), { clear = true })
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
|
group = conform_format_group,
|
||||||
|
buffer = 0,
|
||||||
|
callback = function()
|
||||||
|
require("conform").format({
|
||||||
|
timeout_ms = 1000,
|
||||||
|
lsp_format = "prefer",
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
})
|
||||||
56
ftplugin/r.lua
Normal file
56
ftplugin/r.lua
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
vim.b.slime_cell_delimiter = vim.b.slime_cell_delimiter or "## ----"
|
||||||
|
|
||||||
|
local assign_action = function()
|
||||||
|
if vim.bo.filetype ~= "r" then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local ok, r_edit = pcall(require, "r.edit")
|
||||||
|
if not ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if MiniTrailspace and MiniTrailspace.trim then
|
||||||
|
MiniTrailspace.trim()
|
||||||
|
end
|
||||||
|
r_edit.assign()
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_buf_create_user_command(0, "RAssign", assign_action, { desc = "Trim trailing space and insert <-" })
|
||||||
|
-- Settings
|
||||||
|
vim.bo.comments = [[:#',:####,:###,:##,:#]]
|
||||||
|
|
||||||
|
-- Keymaps
|
||||||
|
-- Note: These use <Plug> mappings provided by R.nvim
|
||||||
|
vim.keymap.set("n", "<Enter>", "<Plug>RDSendLine", { buffer = true })
|
||||||
|
vim.keymap.set("v", "<Enter>", "<Plug>RSendSelection", { buffer = true })
|
||||||
|
|
||||||
|
-- Assignment operator (--)
|
||||||
|
vim.keymap.set("i", "--", "<Cmd>lua MiniTrailspace.trim()<CR><Plug>RInsertAssign", { buffer = true, noremap = true })
|
||||||
|
|
||||||
|
-- Pipe operator (;;)
|
||||||
|
vim.keymap.set("i", ";;", "<Cmd>lua MiniTrailspace.trim()<CR><Plug>RInsertPipe<CR>", { buffer = true, noremap = true })
|
||||||
|
|
||||||
|
-- MiniClue / WhichKey hints
|
||||||
|
local r_clues = {
|
||||||
|
{ mode = "n", keys = "<localleader>a", desc = "+batch" },
|
||||||
|
{ mode = "n", keys = "<localleader>b", desc = "+between/debug" },
|
||||||
|
{ mode = "n", keys = "<localleader>c", desc = "+substitute" },
|
||||||
|
{ mode = "n", keys = "<localleader>f", desc = "+functions" },
|
||||||
|
{ mode = "n", keys = "<localleader>i", desc = "+install" },
|
||||||
|
{ mode = "n", keys = "<localleader>k", desc = "+knit" },
|
||||||
|
{ mode = "n", keys = "<localleader>p", desc = "+paragraph" },
|
||||||
|
{ mode = "n", keys = "<localleader>r", desc = "+regular" },
|
||||||
|
{ mode = "n", keys = "<localleader>s", desc = "+selection" },
|
||||||
|
{ mode = "n", keys = "<localleader>t", desc = "+dput" },
|
||||||
|
{ mode = "n", keys = "<localleader>u", desc = "+undebug" },
|
||||||
|
}
|
||||||
|
|
||||||
|
vim.b.miniclue_config = {
|
||||||
|
clues = {
|
||||||
|
r_clues,
|
||||||
|
},
|
||||||
|
triggers = {
|
||||||
|
{ mode = "n", keys = "<localleader>", desc = "+R" },
|
||||||
|
},
|
||||||
|
}
|
||||||
11
ftplugin/sql.lua
Normal file
11
ftplugin/sql.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
vim.g.omni_sql_default_compl_type = "syntax"
|
||||||
|
|
||||||
|
local ts_lib = Config.treesitter_helpers
|
||||||
|
local global_nodes_sql = { 'program', 'cte' }
|
||||||
|
ts_lib.setup_keybindings(global_nodes_sql)
|
||||||
|
|
||||||
|
-- SQL specific keybindings
|
||||||
|
vim.keymap.set({ 'n' }, '<localleader>;', function()
|
||||||
|
vim.api.nvim_call_function('slime#send', { ";\n" })
|
||||||
|
end,
|
||||||
|
{ noremap = true, silent = true, desc = "SQL statment return", buffer = true })
|
||||||
28
init.lua
Normal file
28
init.lua
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
_G.Config = {}
|
||||||
|
local nix = require('config.nix').init { non_nix_value = true }
|
||||||
|
Config.isNixCats = nix.is_nix
|
||||||
|
|
||||||
|
|
||||||
|
require('lze').register_handlers(require('nixCatsUtils.lzUtils').for_cat)
|
||||||
|
|
||||||
|
local mini_deps = require('mini.deps')
|
||||||
|
|
||||||
|
if not Config.isNixCats then
|
||||||
|
local path_package = vim.fn.stdpath('data') .. '/site/'
|
||||||
|
local mini_path = path_package .. 'pack/deps/start/mini.nvim'
|
||||||
|
if not vim.uv.fs_stat(mini_path) then
|
||||||
|
vim.cmd('echo "Installing `mini.nvim`" | redraw')
|
||||||
|
local clone_cmd = {
|
||||||
|
'git', 'clone', '--filter=blob:none',
|
||||||
|
'https://github.com/echasnovski/mini.nvim', mini_path
|
||||||
|
}
|
||||||
|
vim.fn.system(clone_cmd)
|
||||||
|
vim.cmd('packadd mini.nvim | helptags ALL')
|
||||||
|
vim.cmd('echo "Installed `mini.nvim`" | redraw')
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Set up 'mini.deps' (customize to your liking)
|
||||||
|
mini_deps.setup({ path = { package = path_package } })
|
||||||
|
else
|
||||||
|
mini_deps.setup()
|
||||||
|
end
|
||||||
166
lua/config/nix.lua
Normal file
166
lua/config/nix.lua
Normal file
|
|
@ -0,0 +1,166 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
local function detect_nix()
|
||||||
|
if vim.g.nix_info_plugin_name ~= nil then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
if vim.g[ [[nixCats-special-rtp-entry-nixCats]] ] ~= nil then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
M.is_nix = detect_nix()
|
||||||
|
M.non_nix_default = true
|
||||||
|
|
||||||
|
local function setup_nixcats(non_nix_value)
|
||||||
|
if M.is_nix then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local ok, utils = pcall(require, "nixCatsUtils")
|
||||||
|
if ok and utils and utils.setup then
|
||||||
|
utils.setup { non_nix_value = non_nix_value }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function init_from_nix_info()
|
||||||
|
if vim.g.nix_info_plugin_name == nil then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local ok, nix_info = pcall(require, vim.g.nix_info_plugin_name)
|
||||||
|
if not ok or not nix_info then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local function cat_lookup(cat)
|
||||||
|
if type(cat) == "table" then
|
||||||
|
for _, name in ipairs(cat) do
|
||||||
|
if nix_info(false, "settings", "cats", name) or nix_info(false, "info", "cats", name) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
return nix_info(false, "settings", "cats", cat) or nix_info(false, "info", "cats", cat)
|
||||||
|
end
|
||||||
|
|
||||||
|
local nc = setmetatable({
|
||||||
|
cats = nix_info.settings and nix_info.settings.cats or {},
|
||||||
|
settings = nix_info.settings or {},
|
||||||
|
get = function(_, default, ...) return nix_info(default, ...) end,
|
||||||
|
}, {
|
||||||
|
__call = function(_, default, ...)
|
||||||
|
if select("#", ...) == 0 then
|
||||||
|
return cat_lookup(default)
|
||||||
|
end
|
||||||
|
return nix_info(default, ...)
|
||||||
|
end,
|
||||||
|
__index = nix_info,
|
||||||
|
})
|
||||||
|
|
||||||
|
_G.nixCats = nc
|
||||||
|
package.preload['nixCats.cats'] = function()
|
||||||
|
return setmetatable(_G.nixCats.cats or {}, getmetatable(_G.nixCats))
|
||||||
|
end
|
||||||
|
|
||||||
|
return nc
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_nixcats()
|
||||||
|
if _G.nixCats then
|
||||||
|
return _G.nixCats
|
||||||
|
end
|
||||||
|
|
||||||
|
local nc = init_from_nix_info()
|
||||||
|
if nc then
|
||||||
|
return nc
|
||||||
|
end
|
||||||
|
|
||||||
|
local ok, nc_module = pcall(require, "nixCats")
|
||||||
|
if ok and nc_module then
|
||||||
|
return nc_module
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.init(opts)
|
||||||
|
local non_nix_value = true
|
||||||
|
if type(opts) == "table" and type(opts.non_nix_value) == "boolean" then
|
||||||
|
non_nix_value = opts.non_nix_value
|
||||||
|
end
|
||||||
|
|
||||||
|
M.non_nix_default = non_nix_value
|
||||||
|
setup_nixcats(non_nix_value)
|
||||||
|
get_nixcats()
|
||||||
|
M.is_nix = detect_nix()
|
||||||
|
return M
|
||||||
|
end
|
||||||
|
|
||||||
|
local function cat_enabled(nc, cat, default)
|
||||||
|
if not nc then
|
||||||
|
return default
|
||||||
|
end
|
||||||
|
|
||||||
|
if type(cat) == "table" then
|
||||||
|
for _, name in ipairs(cat) do
|
||||||
|
if nc(name) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return default
|
||||||
|
end
|
||||||
|
|
||||||
|
local val = nc(cat)
|
||||||
|
if val == nil then
|
||||||
|
return default
|
||||||
|
end
|
||||||
|
return val
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.get_cat(cat, default)
|
||||||
|
if default == nil then
|
||||||
|
default = M.non_nix_default
|
||||||
|
end
|
||||||
|
if not M.is_nix then
|
||||||
|
return default
|
||||||
|
end
|
||||||
|
local nc = get_nixcats()
|
||||||
|
return cat_enabled(nc, cat, default)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.get_setting(default, ...)
|
||||||
|
if not M.is_nix then
|
||||||
|
return default
|
||||||
|
end
|
||||||
|
local nc = get_nixcats()
|
||||||
|
if not nc then
|
||||||
|
return default
|
||||||
|
end
|
||||||
|
|
||||||
|
local value = nc(default, "settings", ...)
|
||||||
|
if value == nil then
|
||||||
|
return default
|
||||||
|
end
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.get_info(default, ...)
|
||||||
|
if not M.is_nix then
|
||||||
|
return default
|
||||||
|
end
|
||||||
|
local nc = get_nixcats()
|
||||||
|
if not nc then
|
||||||
|
return default
|
||||||
|
end
|
||||||
|
|
||||||
|
local value = nc(default, "info", ...)
|
||||||
|
if value == nil then
|
||||||
|
return default
|
||||||
|
end
|
||||||
|
return value
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
129
lua/nixCatsUtils/init.lua
Normal file
129
lua/nixCatsUtils/init.lua
Normal file
|
|
@ -0,0 +1,129 @@
|
||||||
|
--[[
|
||||||
|
This directory is the luaUtils template.
|
||||||
|
You can choose what things from it that you would like to use.
|
||||||
|
And then delete the rest.
|
||||||
|
Everything in this directory is optional.
|
||||||
|
--]]
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
--[[
|
||||||
|
This file is for making your config still work WITHOUT nixCats.
|
||||||
|
When you don't use nixCats to load your config,
|
||||||
|
you wont have the nixCats plugin.
|
||||||
|
|
||||||
|
The setup function defined here defines a mock nixCats plugin when nixCats wasnt used to load the config.
|
||||||
|
This will help avoid indexing errors when the nixCats plugin doesnt exist.
|
||||||
|
|
||||||
|
NOTE: If you only ever use nixCats to load your config, you don't need this file.
|
||||||
|
--]]
|
||||||
|
|
||||||
|
---@type boolean
|
||||||
|
M.isNixCats = vim.g.nix_info_plugin_name ~= nil or vim.g[ [[nixCats-special-rtp-entry-nixCats]] ] ~= nil
|
||||||
|
|
||||||
|
---@class nixCatsSetupOpts
|
||||||
|
---@field non_nix_value boolean|nil
|
||||||
|
|
||||||
|
---This function will setup a mock nixCats plugin when not using nix
|
||||||
|
---It will help prevent you from running into indexing errors without a nixCats plugin from nix.
|
||||||
|
---If you loaded the config via nix, it does nothing
|
||||||
|
---non_nix_value defaults to true if not provided or is not a boolean.
|
||||||
|
---@param v nixCatsSetupOpts
|
||||||
|
function M.setup(v)
|
||||||
|
if not M.isNixCats then
|
||||||
|
local nixCats_default_value
|
||||||
|
if type(v) == "table" and type(v.non_nix_value) == "boolean" then
|
||||||
|
nixCats_default_value = v.non_nix_value
|
||||||
|
else
|
||||||
|
nixCats_default_value = true
|
||||||
|
end
|
||||||
|
local mk_with_meta = function (tbl)
|
||||||
|
return setmetatable(tbl, {
|
||||||
|
__call = function(_, attrpath)
|
||||||
|
local strtable = {}
|
||||||
|
if type(attrpath) == "table" then
|
||||||
|
strtable = attrpath
|
||||||
|
elseif type(attrpath) == "string" then
|
||||||
|
for key in attrpath:gmatch("([^%.]+)") do
|
||||||
|
table.insert(strtable, key)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
print("function requires a table of strings or a dot separated string")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
return vim.tbl_get(tbl, unpack(strtable));
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
package.preload['nixCats'] = function ()
|
||||||
|
local ncsub = {
|
||||||
|
get = function(_) return nixCats_default_value end,
|
||||||
|
cats = mk_with_meta({
|
||||||
|
nixCats_config_location = vim.fn.stdpath('config'),
|
||||||
|
wrapRc = false,
|
||||||
|
}),
|
||||||
|
settings = mk_with_meta({
|
||||||
|
nixCats_config_location = vim.fn.stdpath('config'),
|
||||||
|
configDirName = os.getenv("NVIM_APPNAME") or "nvim",
|
||||||
|
wrapRc = false,
|
||||||
|
}),
|
||||||
|
petShop = mk_with_meta({}),
|
||||||
|
extra = mk_with_meta({}),
|
||||||
|
pawsible = mk_with_meta({
|
||||||
|
allPlugins = {
|
||||||
|
start = {},
|
||||||
|
opt = {},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
configDir = vim.fn.stdpath('config'),
|
||||||
|
packageBinPath = os.getenv('NVIM_WRAPPER_PATH_NIX') or vim.v.progpath
|
||||||
|
}
|
||||||
|
return setmetatable(ncsub, {__call = function(_, cat) return ncsub.get(cat) end})
|
||||||
|
end
|
||||||
|
_G.nixCats = require('nixCats')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---allows you to guarantee a boolean is returned, and also declare a different
|
||||||
|
---default value than specified in setup when not using nix to load the config
|
||||||
|
---@overload fun(v: string|string[]): boolean
|
||||||
|
---@overload fun(v: string|string[], default: boolean): boolean
|
||||||
|
function M.enableForCategory(v, default)
|
||||||
|
if M.isNixCats or default == nil then
|
||||||
|
if nixCats(v) then
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return default
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---if nix, return value of nixCats(v) else return default
|
||||||
|
---Exists to specify a different non_nix_value than the one in setup()
|
||||||
|
---@param v string|string[]
|
||||||
|
---@param default any
|
||||||
|
---@return any
|
||||||
|
function M.getCatOrDefault(v, default)
|
||||||
|
if M.isNixCats then
|
||||||
|
return nixCats(v)
|
||||||
|
else
|
||||||
|
return default
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
---for conditionally disabling build steps on nix, as they are done via nix
|
||||||
|
---I should probably have named it dontAddIfCats or something.
|
||||||
|
---@overload fun(v: any): any|nil
|
||||||
|
---Will return the second value if nix, otherwise the first
|
||||||
|
---@overload fun(v: any, o: any): any
|
||||||
|
function M.lazyAdd(v, o)
|
||||||
|
if M.isNixCats then
|
||||||
|
return o
|
||||||
|
else
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
37
lua/nixCatsUtils/lzUtils.lua
Normal file
37
lua/nixCatsUtils/lzUtils.lua
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
--[[
|
||||||
|
This directory is the luaUtils template.
|
||||||
|
You can choose what things from it that you would like to use.
|
||||||
|
And then delete the rest.
|
||||||
|
Everything in this directory is optional.
|
||||||
|
--]]
|
||||||
|
|
||||||
|
local M = {}
|
||||||
|
local nix = require('config.nix')
|
||||||
|
-- A nixCats specific lze handler that you can use to conditionally enable by category easier.
|
||||||
|
-- at the start of your config, register with
|
||||||
|
-- require('lze').register_handlers(require('nixCatsUtils.lzUtils').for_cat)
|
||||||
|
-- before any calls to require('lze').load using the handler have been made.
|
||||||
|
-- accepts:
|
||||||
|
-- for_cat = { "your" "cat" };
|
||||||
|
-- for_cat = { cat = { "your" "cat" }, default = bool }
|
||||||
|
-- for_cat = "your.cat";
|
||||||
|
-- for_cat = { cat = "your.cat", default = bool }
|
||||||
|
-- where default is an alternate value for when nixCats was NOT used to install the config
|
||||||
|
M.for_cat = {
|
||||||
|
spec_field = "for_cat",
|
||||||
|
set_lazy = false,
|
||||||
|
modify = function(plugin)
|
||||||
|
if type(plugin.for_cat) == "table" and plugin.for_cat.cat ~= nil then
|
||||||
|
local default = plugin.for_cat.default
|
||||||
|
if default == nil then
|
||||||
|
default = false
|
||||||
|
end
|
||||||
|
plugin.enabled = nix.get_cat(plugin.for_cat.cat, default)
|
||||||
|
else
|
||||||
|
plugin.enabled = nix.get_cat(plugin.for_cat, false)
|
||||||
|
end
|
||||||
|
return plugin
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
return M
|
||||||
196
lua/nix_smart_send.lua
Normal file
196
lua/nix_smart_send.lua
Normal file
|
|
@ -0,0 +1,196 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
-- Helper function to check if value exists in list (optimized with early return)
|
||||||
|
local function is_in_list(list, value)
|
||||||
|
if not list or not value then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, v in ipairs(list) do
|
||||||
|
if v == value then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Define comment node types as constants
|
||||||
|
local COMMENT_TYPES = {
|
||||||
|
comment = true,
|
||||||
|
block_comment = true,
|
||||||
|
line_comment = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
function M.get_current_node()
|
||||||
|
local ts_utils = require('nvim-treesitter.ts_utils')
|
||||||
|
local cur_win = vim.api.nvim_get_current_win()
|
||||||
|
return ts_utils.get_node_at_cursor(cur_win, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.detect_global_node()
|
||||||
|
local cur_node = M.get_current_node()
|
||||||
|
local root
|
||||||
|
|
||||||
|
if not cur_node then
|
||||||
|
-- print("No node detected")
|
||||||
|
local parser = vim.treesitter.get_parser()
|
||||||
|
if not parser then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
root = parser:parse()[1]:root()
|
||||||
|
else
|
||||||
|
root = cur_node:root()
|
||||||
|
end
|
||||||
|
|
||||||
|
if not root then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
return root:type()
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.move_to_next_non_empty_line()
|
||||||
|
local ts_utils = require('nvim-treesitter.ts_utils')
|
||||||
|
-- Search for the next non-empty line
|
||||||
|
local line_num = vim.fn.search("[^;\\s]", "W")
|
||||||
|
|
||||||
|
if line_num <= 0 then
|
||||||
|
-- print("No non-empty line found below the current position")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get the line content and find first non-whitespace character
|
||||||
|
local line_content = vim.api.nvim_buf_get_lines(0, line_num - 1, line_num, false)[1]
|
||||||
|
local first_non_ws = line_content:find("%S") or 1
|
||||||
|
vim.api.nvim_win_set_cursor(0, { line_num, first_non_ws - 1 })
|
||||||
|
|
||||||
|
local node = M.get_current_node()
|
||||||
|
if not node or not node:type() then
|
||||||
|
-- print("No node found")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local global_node_type = M.detect_global_node()
|
||||||
|
|
||||||
|
-- Skip comments and global nodes
|
||||||
|
while node and (COMMENT_TYPES[node:type()] or node:type() == global_node_type) do
|
||||||
|
line_num = line_num + 1
|
||||||
|
local max_lines = vim.api.nvim_buf_line_count(0)
|
||||||
|
|
||||||
|
if line_num > max_lines then
|
||||||
|
-- print("Reached end of buffer")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get the line content and find first non-whitespace character
|
||||||
|
line_content = vim.api.nvim_buf_get_lines(0, line_num - 1, line_num, false)[1]
|
||||||
|
first_non_ws = line_content:find("%S") or 1
|
||||||
|
vim.api.nvim_win_set_cursor(0, { line_num, first_non_ws - 1 })
|
||||||
|
node = ts_utils.get_node_at_cursor()
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.vselect_node(node)
|
||||||
|
local ts_utils = require('nvim-treesitter.ts_utils')
|
||||||
|
if not node then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local cur_buf = vim.api.nvim_get_current_buf()
|
||||||
|
ts_utils.update_selection(cur_buf, node, "V")
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.select_until_global(global_nodes)
|
||||||
|
local ts_utils = require('nvim-treesitter.ts_utils')
|
||||||
|
local root_node = M.detect_global_node()
|
||||||
|
if not root_node and global_nodes then
|
||||||
|
root_node = global_nodes[1]
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Use empty table if no global nodes provided
|
||||||
|
global_nodes = global_nodes or {}
|
||||||
|
|
||||||
|
local node = ts_utils.get_node_at_cursor()
|
||||||
|
if not node then
|
||||||
|
-- print("No syntax node found at cursor position")
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local node_type = node:type()
|
||||||
|
|
||||||
|
if node_type == root_node then
|
||||||
|
-- print("Cursor is on the root " .. root_node .. " node or in an empty area.")
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if current node is a global
|
||||||
|
if is_in_list(global_nodes, node_type) then
|
||||||
|
if M.vselect_node(node) then
|
||||||
|
return node
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Traverse up the tree until we find a global node or reach the root
|
||||||
|
local parent = node:parent()
|
||||||
|
local parent_type = parent:type() or ""
|
||||||
|
if parent and is_in_list(global_nodes, parent_type) then
|
||||||
|
if M.vselect_node(node) then
|
||||||
|
return node
|
||||||
|
end
|
||||||
|
end
|
||||||
|
while parent and not is_in_list(global_nodes, parent:type()) do
|
||||||
|
node = parent
|
||||||
|
parent = node:parent()
|
||||||
|
end
|
||||||
|
|
||||||
|
if M.vselect_node(node) then
|
||||||
|
return node
|
||||||
|
end
|
||||||
|
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.slime_send_region()
|
||||||
|
-- Check if slime plugin is available
|
||||||
|
if not vim.fn.exists('*slime#send_op') then
|
||||||
|
vim.notify("slime plugin not available", vim.log.levels.ERROR)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local slime_command = ":<C-u>call slime#send_op(visualmode(), 1)<CR>"
|
||||||
|
local termcodes = vim.api.nvim_replace_termcodes(slime_command, true, true, true)
|
||||||
|
|
||||||
|
vim.api.nvim_feedkeys(termcodes, "x", true)
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.send_repl(global_nodes)
|
||||||
|
local ts_utils = require('nvim-treesitter.ts_utils')
|
||||||
|
local cur_node = M.get_current_node()
|
||||||
|
|
||||||
|
if not cur_node then
|
||||||
|
M.move_to_next_non_empty_line()
|
||||||
|
else
|
||||||
|
local cur_type = cur_node:type()
|
||||||
|
if COMMENT_TYPES[cur_type] or is_in_list(global_nodes, cur_type) then
|
||||||
|
M.move_to_next_non_empty_line()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local sel_node = M.select_until_global(global_nodes)
|
||||||
|
if not sel_node then
|
||||||
|
-- print("No node selected for REPL")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Send the selected text to the terminal using vim-slime
|
||||||
|
M.slime_send_region()
|
||||||
|
|
||||||
|
-- Move cursor and continue
|
||||||
|
ts_utils.goto_node(sel_node, true)
|
||||||
|
M.move_to_next_non_empty_line()
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
||||||
51
modules/module/settings/cats.nix
Normal file
51
modules/module/settings/cats.nix
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
options.cats = lib.mkOption {
|
||||||
|
type = lib.types.attrsOf lib.types.bool;
|
||||||
|
description = ''
|
||||||
|
Category toggles used to enable/disable specs by name.
|
||||||
|
|
||||||
|
Keys map directly to specs (e.g., `python` controls `specs.python`).
|
||||||
|
Set a category to `false` to skip its dependency/plugin specs.
|
||||||
|
|
||||||
|
Available categories:
|
||||||
|
- clickhouse: Clickhouse client and tools
|
||||||
|
- customPlugins: local plugin specs
|
||||||
|
- external: external tools and integrations
|
||||||
|
- general: core Neovim plugins/features
|
||||||
|
- gitPlugins: git-related plugins
|
||||||
|
- julia: Julia tooling and packages
|
||||||
|
- lua: Lua tooling and LSPs
|
||||||
|
- markdown: markdown tooling and plugins
|
||||||
|
- nix: Nix tooling and plugins
|
||||||
|
- optional: optional tools and utilities
|
||||||
|
- python: Python tooling and plugins
|
||||||
|
- r: R tooling and plugins
|
||||||
|
- test: test-only tooling (disabled by default)
|
||||||
|
- treesitterParsers: Treesitter parsers
|
||||||
|
- utils: general utilities
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
config.cats = {
|
||||||
|
clickhouse = lib.mkDefault false;
|
||||||
|
customPlugins = lib.mkDefault true;
|
||||||
|
external = lib.mkDefault true;
|
||||||
|
general = lib.mkDefault true;
|
||||||
|
gitPlugins = lib.mkDefault true;
|
||||||
|
julia = lib.mkDefault false;
|
||||||
|
lua = lib.mkDefault false;
|
||||||
|
markdown = lib.mkDefault false;
|
||||||
|
nix = lib.mkDefault false;
|
||||||
|
optional = lib.mkDefault false;
|
||||||
|
python = lib.mkDefault false;
|
||||||
|
r = lib.mkDefault false;
|
||||||
|
test = lib.mkDefault false;
|
||||||
|
treesitterParsers = lib.mkDefault true;
|
||||||
|
utils = lib.mkDefault true;
|
||||||
|
};
|
||||||
|
}
|
||||||
35
modules/module/settings/core.nix
Normal file
35
modules/module/settings/core.nix
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
# Point to the directory containing init.lua, plugin/, lua/, etc.
|
||||||
|
config.settings.config_directory = ../../..;
|
||||||
|
|
||||||
|
# Default colorscheme and background
|
||||||
|
config.settings.colorscheme = "kanagawa";
|
||||||
|
config.settings.background = "dark";
|
||||||
|
|
||||||
|
# Enable RC wrapping (allows neovim to find the config)
|
||||||
|
config.settings.wrapRc = true;
|
||||||
|
|
||||||
|
# Lua packages available to neovim (for :lua require())
|
||||||
|
config.settings.nvim_lua_env = lp:
|
||||||
|
lib.optionals (config.cats.general or false) [ lp.tiktoken_core ];
|
||||||
|
|
||||||
|
# Binary name for the wrapper
|
||||||
|
config.binName = "n";
|
||||||
|
|
||||||
|
# Prevent neovim from loading system-wide config
|
||||||
|
config.settings.block_normal_config = true;
|
||||||
|
|
||||||
|
# Don't symlink the config (we wrap it instead)
|
||||||
|
config.settings.dont_link = false;
|
||||||
|
|
||||||
|
# Create additional aliases for the binary
|
||||||
|
config.settings.aliases = [ "vim" ];
|
||||||
|
|
||||||
|
# Enable wrapper handling of spec runtimeDeps (template pattern).
|
||||||
|
config.settings.autowrapRuntimeDeps = true;
|
||||||
|
}
|
||||||
27
modules/module/settings/env.nix
Normal file
27
modules/module/settings/env.nix
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
# Environment variables set for the wrapper.
|
||||||
|
# These are available when running neovim.
|
||||||
|
config.env = lib.mkMerge [
|
||||||
|
(lib.mkIf (config.cats.r or false) {
|
||||||
|
R_LIBS_USER = "./.Rlibs";
|
||||||
|
})
|
||||||
|
(lib.mkIf (config.cats.python or false) {
|
||||||
|
UV_PYTHON_DOWNLOADS = "never";
|
||||||
|
UV_PYTHON = pkgs.python.interpreter;
|
||||||
|
})
|
||||||
|
(lib.mkIf (config.cats.test or false) {
|
||||||
|
TESTVAR = "It worked!";
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
# Environment variables with defaults (can be overridden by user)
|
||||||
|
config.envDefault = lib.mkIf (config.cats.test or false) {
|
||||||
|
TESTVAR2 = "It worked again!";
|
||||||
|
};
|
||||||
|
}
|
||||||
57
modules/module/settings/hosts.nix
Normal file
57
modules/module/settings/hosts.nix
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
config.hosts = lib.mkMerge [
|
||||||
|
{
|
||||||
|
node.nvim-host.enable = true;
|
||||||
|
perl.nvim-host.enable = true;
|
||||||
|
ruby.nvim-host.enable = true;
|
||||||
|
|
||||||
|
g = {
|
||||||
|
nvim-host.enable = true;
|
||||||
|
nvim-host.package = "${pkgs.neovide}/bin/neovide";
|
||||||
|
nvim-host.argv0 = "neovide";
|
||||||
|
nvim-host.flags."--neovim-bin" = "${placeholder "out"}/bin/${config.binName}";
|
||||||
|
};
|
||||||
|
|
||||||
|
m = {
|
||||||
|
nvim-host.enable = false;
|
||||||
|
nvim-host.package = "${pkgs.uv}/bin/uv";
|
||||||
|
nvim-host.argv0 = "uv";
|
||||||
|
nvim-host.addFlag = [
|
||||||
|
"run"
|
||||||
|
"marimo"
|
||||||
|
"edit"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
(lib.mkIf (config.cats.julia or true) {
|
||||||
|
jl = {
|
||||||
|
nvim-host.enable = true;
|
||||||
|
nvim-host.package = "${pkgs.julia-bin}/bin/julia";
|
||||||
|
nvim-host.argv0 = "julia";
|
||||||
|
nvim-host.addFlag = [
|
||||||
|
"--project=@."
|
||||||
|
];
|
||||||
|
};
|
||||||
|
})
|
||||||
|
(lib.mkIf (config.cats.python or true) {
|
||||||
|
python3.nvim-host.enable = true;
|
||||||
|
})
|
||||||
|
(lib.mkIf (config.cats.r or true) {
|
||||||
|
r = {
|
||||||
|
nvim-host.enable = true;
|
||||||
|
nvim-host.package = "${pkgs.rWrapper}/bin/R";
|
||||||
|
nvim-host.argv0 = "R";
|
||||||
|
nvim-host.addFlag = [
|
||||||
|
"--no-save"
|
||||||
|
"--no-restore"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
39
modules/module/settings/lang-packages.nix
Normal file
39
modules/module/settings/lang-packages.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
options.settings.lang_packages = lib.mkOption {
|
||||||
|
type = lib.types.submodule {
|
||||||
|
options = {
|
||||||
|
python = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.package;
|
||||||
|
default = [ ];
|
||||||
|
description = "Additional Python-related packages appended to the python spec (overlay defaults remain).";
|
||||||
|
};
|
||||||
|
r = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.package;
|
||||||
|
default = [ ];
|
||||||
|
description = "Additional R-related packages appended to the r spec (overlay defaults remain).";
|
||||||
|
};
|
||||||
|
julia = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ ];
|
||||||
|
description = "Additional Julia packages (names) passed to julia-bin.withPackages.";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
default = { };
|
||||||
|
description = ''
|
||||||
|
Language-specific package overrides appended to each language spec's extraPackages.
|
||||||
|
Intended for flake.nix overrides via wrapper.config.wrap.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
config.settings.lang_packages = {
|
||||||
|
python = lib.mkDefault [ ];
|
||||||
|
r = lib.mkDefault [ ];
|
||||||
|
julia = lib.mkDefault [ ];
|
||||||
|
};
|
||||||
|
}
|
||||||
35
modules/module/settings/runtime-path.nix
Normal file
35
modules/module/settings/runtime-path.nix
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
collect_runtime_packages = runtime_deps_type:
|
||||||
|
config.specCollect
|
||||||
|
(acc: spec:
|
||||||
|
let
|
||||||
|
is_enabled = if spec ? enable then spec.enable else true;
|
||||||
|
has_runtime_deps = (spec.runtimeDeps or false) == runtime_deps_type;
|
||||||
|
packages = spec.extraPackages or [ ];
|
||||||
|
in
|
||||||
|
acc ++ lib.optionals (is_enabled && has_runtime_deps) packages
|
||||||
|
)
|
||||||
|
[ ];
|
||||||
|
|
||||||
|
prefix_packages = collect_runtime_packages "prefix";
|
||||||
|
suffix_packages = collect_runtime_packages "suffix";
|
||||||
|
|
||||||
|
to_path_specs = packages: [
|
||||||
|
{
|
||||||
|
data = [
|
||||||
|
"PATH"
|
||||||
|
":"
|
||||||
|
"${lib.makeBinPath packages}"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config.prefixVar = lib.optionals (prefix_packages != [ ]) (to_path_specs prefix_packages);
|
||||||
|
config.suffixVar = lib.optionals (suffix_packages != [ ]) (to_path_specs suffix_packages);
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue