Compare commits

..
56 changed files with 1556 additions and 2716 deletions

View file

@ -1,5 +0,0 @@
if (Sys.getenv("RNVIM_TMPDIR") == "") {
options(defaultPackages = c("utils", "grDevices", "graphics", "stats", "methods"))
} else {
options(defaultPackages = c("utils", "grDevices", "graphics", "stats", "methods", "nvimcom"))
}

7
.github/dependapot.yml vendored Normal file
View file

@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"

View file

@ -5,20 +5,12 @@ on:
paths:
- 'flake.lock'
- 'flake.nix'
- 'modules/**'
- 'plugin/**'
- 'lua/**'
- 'overlays/**'
- 'ftplugin/**'
- 'modules'
pull_request:
paths:
- 'flake.lock'
- 'flake.nix'
- 'modules/**'
- 'plugin/**'
- 'lua/**'
- 'overlays/**'
- 'ftplugin/**'
- 'modules'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
@ -29,7 +21,7 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v7
- uses: actions/checkout@v4
- uses: wimpysworld/nothing-but-nix@main
if: runner.os == 'Linux'
with:
@ -37,11 +29,11 @@ jobs:
- uses: cachix/install-nix-action@v31
with:
github_access_token: ${{ secrets.GH_TOKEN }}
- uses: cachix/cachix-action@v17
- uses: cachix/cachix-action@v14
with:
name: rde
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
extraPullNames: rstats-on-nix, nix-community
- run: nix build
- run: nix develop -c echo ok
- run: nix develop
- run: nix flake check

View file

@ -10,7 +10,7 @@ jobs:
id-token: "write"
contents: "read"
steps:
- uses: "actions/checkout@v7"
- uses: "actions/checkout@v5"
with:
persist-credentials: false
- uses: "DeterminateSystems/determinate-nix-action@v3"

View file

@ -10,13 +10,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v7
uses: actions/checkout@v4
- uses: wimpysworld/nothing-but-nix@main
with:
hatchet-protocol: 'carve'
- name: Install Determinate Nix
uses: DeterminateSystems/determinate-nix-action@v3
- uses: cachix/cachix-action@v17
- uses: cachix/cachix-action@v14
with:
name: rde
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'

3
.gitignore vendored
View file

@ -3,6 +3,3 @@
*.R
.Rlibs
.nvimcom
.commandcode
.commandcode/
.r-*

343
README.md
View file

@ -1,343 +0,0 @@
# nvimConfig
Modular Neovim wrapper config. Defines a wrapped `vv` binary with per-category packages, plugins, and environment variables. Available as NixOS module, Home Manager module, or single-starflake import.
## Quick start (imported into another flake)
```nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rixpkgs.url = "github:dwinkler1/rixpkgs/af2dd3f7b4b172077747c0869d4e30702fb71b0e";
fran = {
url = "github:dwinkler1/fran";
inputs.nixpkgs.follows = "rixpkgs";
};
nvimConfig = {
url = "github:dwinkler1/nvimConfig";
inputs = {
nixpkgs.follows = "nixpkgs";
rixpkgs.follows = "rixpkgs";
fran.follows = "fran";
};
};
};
outputs = { self, nixpkgs, nvimConfig, ... } @ inputs: let
systems = ["aarch64-darwin" "x86_64-linux" "aarch64-linux"];
forAllSystems = nixpkgs.lib.genAttrs systems;
in {
packages = forAllSystems (system: let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [ nvimConfig.overlays.dependencies ];
};
evalResult = nvimConfig.lib.eval {
inherit pkgs;
modules = [ projectSettings ]; # see below
};
in {
default = evalResult.config.wrap { inherit pkgs; };
});
devShells = forAllSystems (system: let
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [ nvimConfig.overlays.dependencies ];
};
evalResult = nvimConfig.lib.eval {
inherit pkgs;
modules = [ projectSettings ];
};
nv = evalResult.config.wrap { inherit pkgs; };
in {
default = pkgs.mkShell {
packages = [ nv ] ++ nvimConfig.lib.devShellPackages evalResult.config;
shellHook = nvimConfig.lib.shellHook evalResult.config;
};
});
};
}
```
## Home Manager module
```nix
{ inputs, ... }: {
home.packages = [
(inputs.nvimConfig.homeModules.default { inherit pkgs; })
# Or via the overlay:
# pkgs.vv
];
}
```
## NixOS module
```nix
{ inputs, ... }: {
environment.systemPackages = [
(inputs.nvimConfig.nixosModules.default { inherit pkgs; })
];
}
```
## Overriding settings
Define a `projectSettings` attrset and pass it to `nvimConfig.lib.eval` or `nvimConfig.lib.mkWrapper`. The helper injects your overlaid `pkgs` automatically, so downstream consumers do not need to wire `specialArgs` themselves. Every option in `nvimConfig.wrapperConfigs.default` can be overridden here. Local `packages.default`, local `devShells.default`, downstream helper usage, and `pkgs.vv` all resolve the same module defaults unless you override them.
### Basic downstream flake example
This example enables a few cats, adds runtime tools to the shared wrapper/devShell package set, and appends language libraries to the default Python and R environments.
```nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rixpkgs.url = "github:dwinkler1/rixpkgs/af2dd3f7b4b172077747c0869d4e30702fb71b0e";
fran = {
url = "github:dwinkler1/fran";
inputs.nixpkgs.follows = "rixpkgs";
};
nvimConfig = {
url = "github:dwinkler1/nvimConfig";
inputs = {
nixpkgs.follows = "nixpkgs";
rixpkgs.follows = "rixpkgs";
fran.follows = "fran";
};
};
};
outputs = { nixpkgs, nvimConfig, ... }: let
system = "aarch64-darwin";
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [ nvimConfig.overlays.dependencies ];
};
projectSettings = {
cats = {
python = true;
r = true;
nix = true;
markdown = true;
optional = true;
};
settings.lang_packages = {
python = with pkgs.python3Packages; [
pandas
pyarrow
];
r = with pkgs.rpkgs.rPackages; [
fixest
modelsummary
];
};
catPkgs = {
python = [
(pkgs.python3.withPackages (ps:
ps
++ (with ps; [
pandas
pyarrow
])))
pkgs.ruff
pkgs.basedpyright
pkgs.uv
pkgs.nodejs
];
nix = [
pkgs.alejandra
pkgs.nil
];
optional = [
pkgs.git
pkgs.fd
pkgs.ripgrep
];
};
};
evalResult = nvimConfig.lib.eval {
inherit pkgs;
modules = [ projectSettings ];
};
nv = evalResult.config.wrap { inherit pkgs; };
in {
packages.${system}.default = nv;
devShells.${system}.default = pkgs.mkShell {
packages = [ nv ] ++ nvimConfig.lib.devShellPackages evalResult.config;
shellHook = nvimConfig.lib.shellHook evalResult.config;
};
};
}
```
### Categories
Enable only the cats you need. Defaults are listed in `modules/module/settings/cats.nix`.
```nix
projectSettings = {
cats = {
python = true; # enable Python tooling
r = false; # disable R
nix = true;
lua = false;
markdown = false;
optional = false;
gitPlugins = false;
};
};
```
### Language packages (module defaults)
Add Python/R/Julia libraries. These are appended to the built-in defaults, which
always apply (see `settings.langPackageDefaults` in `modules/module/settings/lang-packages.nix`):
- Python: `duckdb`, `polars`
- R: `arrow`, `broom`, `data_table`, `janitor`, `styler`
- Julia: `DataFramesMeta`, `QuackIO`
```nix
projectSettings = {
settings.lang_packages = {
python = with pkgs.python3Packages; [ pandas numpy ];
r = with pkgs.rpkgs.rPackages; [ fixest data_table ];
julia = [ "StatsBase" "Plots" ];
};
};
```
Use `lib.mkForce` to replace other `lang_packages` assignments; the built-in defaults still apply.
To exclude defaults, override `catPkgs.<cat>` instead:
```nix
projectSettings = {
settings.lang_packages = {
python = pkgs.lib.mkForce (with pkgs.python3Packages; [ polars duckdb ]);
};
};
```
### Runtime dependencies (per-cat packages)
Override `catPkgs` to change the full runtime tool lists that appear in both the wrapper PATH and the devShell. Use normal assignments to merge list values, or `lib.mkForce` to replace them.
```nix
projectSettings = {
catPkgs = {
nix = [ pkgs.nil pkgs.nixfmt ];
python = [
(pkgs.python3.withPackages (ps: [ ps.pandas ps.duckdb ]))
pkgs.ruff
];
};
};
```
### Direct runtimePkgs override (always-on)
Add packages to `catPkgs.always` for tools that should always be available regardless of other cat toggles.
```nix
projectSettings = {
catPkgs = {
always = [ pkgs.git pkgs.curl pkgs.pre-commit ];
};
};
```
### Runtime env vars
```nix
projectSettings = {
env = {
MY_PROJECT_VAR = "some-value";
};
envDefault = {
EDITOR = "vv";
};
};
```
`env` values are forced; `envDefault` values can be overridden by the user's shell.
### Choosing the right override surface
- Use `cats` to enable or disable a whole language or tooling category.
- Use `settings.lang_packages` to add or replace Python, R, or Julia libraries within a language environment.
- Use `catPkgs` to change the full runtime tool list for a category. `config.runtimePkgs` drives wrapper PATH composition, while `nvimConfig.lib.devShellPackages config` returns the package-only list suitable for `mkShell`.
- Use `env` or `envDefault` for wrapper environment variables.
- Use `specs` for plugin additions or custom runtime behavior.
### Neovim settings
```nix
projectSettings = {
settings = {
colorscheme = "kanagawa";
background = "dark";
wrapRc = true;
config_directory = ./nvim; # path to init.lua + lua/ dir
aliases = [ "v" "nvim" ]; # extra binary names (default: [ "vvim" ])
};
binName = "nv"; # binary name (default: vv)
};
```
## Adding plugins
```nix
projectSettings = {
specs = {
extraPlugins = {
data = with pkgs.vimPlugins; [
telescope-nvim
which-key-nvim
];
};
extraLazy = {
lazy = true;
data = with pkgs.vimPlugins; [ dashboard-nvim ];
};
# Inject Lua config at startup
extraLua = {
data = pkgs.writeText "extra.lua" ''
vim.opt.number = true
vim.opt.relativenumber = true
'';
before = ["INIT_MAIN"];
};
};
};
```
## Architecture
```
settings/lang-packages.nix ──► settings.lang_packages
│
cats.nix ───────────────► config.cats │
│ │
▼ ▼
cat-packages.nix ───────► config.catPkgs.<cat>
│ │
├──────────────┐ │
▼ ▼ ▼
deps.nix PATH wrapper.config.wrap devShells.default
```
- **Overlays** (`overlays/`) inject dependency package sets into nixpkgs (`rpkgs`, `baseRPackages`, `basePythonPackages`, plugins). Top-level `rWrapper` and `quarto` are compatibility conveniences, but `pkgs.rpkgs` is the canonical R surface for downstream configuration.
- **cat-packages.nix** is the single source of truth for per-category packages. Each list is gated by its cat toggle.
- **deps.nix** wires `catPkgs` into the wrapper's runtime PATH.
- **settings.lang_packages** holds project-specific language libraries appended to the built-in `settings.langPackageDefaults`, used by local outputs and downstream module consumers.
- **flake.nix** exports `lib.eval`, `lib.mkWrapper`, `lib.devShellPackages`, and `lib.shellHook` as the canonical downstream helpers, and builds `packages.default` and `devShells.default` from the same module config.

67
flake.lock generated
View file

@ -7,11 +7,11 @@
]
},
"locked": {
"lastModified": 1787729487,
"narHash": "sha256-3A5rKxnceQ+inWqeQDUrxoVPXr67JMrdIIfbLStx06s=",
"lastModified": 1776413584,
"narHash": "sha256-xqqv46MTveuT4yJH2YihmbHGy5mdLnnLFDebVmUws/E=",
"owner": "dwinkler1",
"repo": "fran",
"rev": "b77635aeb1e70fffd09e5823dde5b76abb3df991",
"rev": "da09626e4dd8f0f57078b3a04e0443a8c20defa1",
"type": "github"
},
"original": {
@ -22,11 +22,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1788179007,
"narHash": "sha256-hn1oU2rue2SYK8dAr8+WNZWtbsz1S2W5mnHlSEuh3bo=",
"lastModified": 1776169885,
"narHash": "sha256-l/iNYDZ4bGOAFQY2q8y5OAfBBtrDAaPuRQqWaFHVRXM=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "34ab99075ac4f7e40cf037eef32cb1c360bb85e9",
"rev": "4bd9165a9165d7b5e33ae57f3eecbcb28fb231c9",
"type": "github"
},
"original": {
@ -52,35 +52,29 @@
"type": "github"
}
},
"r-nvim-nix": {
"inputs": {
"nixpkgs": [
"rixpkgs"
],
"rnvimsrc": "rnvimsrc"
},
"plugins-r": {
"flake": false,
"locked": {
"lastModified": 1784867506,
"narHash": "sha256-5zXVJLG7+Gi9sgb4Dn7P6O/ywQQxpvcjjoHSJXZEuVo=",
"owner": "dwinkler1",
"repo": "r_nvim_nix",
"rev": "1d26452e3c940153271fc57fbad0b295fcb0e04f",
"lastModified": 1776340770,
"narHash": "sha256-o/8UZIc/Bq9dWTjA+MpSR5uMUpE7KHTErk+TwWID8Ww=",
"owner": "R-nvim",
"repo": "R.nvim",
"rev": "b9cfffeb9b4e484aa9e13f01c0eb80230aada455",
"type": "github"
},
"original": {
"owner": "dwinkler1",
"ref": "v1.0.0",
"repo": "r_nvim_nix",
"owner": "R-nvim",
"repo": "R.nvim",
"type": "github"
}
},
"rixpkgs": {
"locked": {
"lastModified": 1788208780,
"narHash": "sha256-ouq3GjmTOXtWVufLOhMqLAEJXxrlkhDYtZJt3YfN5oU=",
"lastModified": 1771303851,
"narHash": "sha256-tgveHozOJ2D/mi3LxVy/FcmLFDlM5XKZxsNB2XpvzaM=",
"owner": "dwinkler1",
"repo": "rixpkgs",
"rev": "f3d00cb8f39262e6ca15c2046bd29ca8a52aae31",
"rev": "af2dd3f7b4b172077747c0869d4e30702fb71b0e",
"type": "github"
},
"original": {
@ -90,29 +84,12 @@
"type": "github"
}
},
"rnvimsrc": {
"flake": false,
"locked": {
"lastModified": 1783264911,
"narHash": "sha256-FywUL3mV2+kfu+rO6uUFyUv80EflbdgSkYuSnW965UE=",
"owner": "R-nvim",
"repo": "R.nvim",
"rev": "c56ebe0f8445e251673981c40ac2d74659ecd6ed",
"type": "github"
},
"original": {
"owner": "R-nvim",
"ref": "v1.0.0",
"repo": "R.nvim",
"type": "github"
}
},
"root": {
"inputs": {
"fran": "fran",
"nixpkgs": "nixpkgs",
"plugins-cmp-pandoc-references": "plugins-cmp-pandoc-references",
"r-nvim-nix": "r-nvim-nix",
"plugins-r": "plugins-r",
"rixpkgs": "rixpkgs",
"wrappers": "wrappers"
}
@ -124,11 +101,11 @@
]
},
"locked": {
"lastModified": 1787722691,
"narHash": "sha256-bWBt7v2FhgG6WTLgSi8nYGi1zXaTdA+vTdCRdvR2vcw=",
"lastModified": 1776375800,
"narHash": "sha256-/SSAR77Brr9fbapsh1cb2K47JXCbvwS1GjM4yyDxle8=",
"owner": "BirdeeHub",
"repo": "nix-wrapper-modules",
"rev": "04ef216559b18214853879df862f493a9e6bb8cf",
"rev": "f11469ca69068bac13d9e163b2bd268cc06dff57",
"type": "github"
},
"original": {

266
flake.nix
View file

@ -1,23 +1,17 @@
# Copyright (c) 2026 BirdeeHub & Daniel
# Copyright (c) 2026 BirdeeHub
# Licensed under the MIT license
{
description = "Daniel's NixCats";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
#nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
wrappers = {
url = "github:BirdeeHub/nix-wrapper-modules";
inputs.nixpkgs.follows = "nixpkgs";
};
rixpkgs.url = "github:dwinkler1/rixpkgs/nixpkgs";
r-nvim-nix = {
url = "github:dwinkler1/r_nvim_nix/v1.0.0";
inputs = {
nixpkgs.follows = "rixpkgs";
};
};
fran = {
url = "github:dwinkler1/fran";
inputs = {
@ -25,6 +19,11 @@
};
};
"plugins-r" = {
url = "github:R-nvim/R.nvim";
flake = false;
};
"plugins-cmp-pandoc-references" = {
url = "github:jmbuhr/cmp-pandoc-references";
flake = false;
@ -37,42 +36,46 @@
wrappers,
...
} @ inputs: let
devShellCatOrder = [
"always"
"clickhouse"
"external"
"julia"
"lua"
"markdown"
"nix"
"optional"
"python"
"r"
"treesitterParsers"
];
evalWithPkgs = pkgs: extraModules:
wrappers.lib.evalModules {
specialArgs = {
wrapperSettings = pkgs: let
def = pkgs.lib.mkDefault;
in
wrapper.config.wrap {
inherit pkgs;
cats = {
clickhouse = def false;
gitPlugins = def true;
julia = def false;
lua = def true;
markdown = def false;
nix = def true;
optional = def false;
python = def false;
r = def false;
};
modules =
[
module
]
++ extraModules;
settings = {
lang_packages = {
python = with pkgs.python3Packages; [
duckdb
polars
];
r = with pkgs.rpkgs.rPackages; [
arrow
broom
data_table
janitor
styler
];
julia = ["DataFramesMeta" "QuackIO"];
};
colorscheme = def "cyberdream";
background = def "dark";
wrapRc = def true;
};
binName = def "vv";
};
mkDevShellPackages = config:
builtins.concatLists (map (name: config.catPkgs.${name} or []) devShellCatOrder);
mkShellHook = config:
''
echo 'I am a NixShell'
''
+ nixpkgs.lib.optionalString (config.cats.r or false) ''
export R_HOME=$(R RHOME)
export R_LIBS_SITE=$(strings "$(command -v R)" | rg -o '/nix/store/[^:]+/library' | sort -u | paste -sd: -)
export R_LIBS_USER="$PWD/.r-libs"
mkdir -p "$R_LIBS_USER"
'';
systems = [
"aarch64-darwin"
@ -82,49 +85,54 @@
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 = {allowUnfree = true;};
overlays = [
overlayDefs.dependencyOverlay
];
config = extra_pkg_config;
overlays = [dependencyOverlay];
};
module = (import ./modules/neovim.nix) inputs;
module = nixpkgs.lib.modules.importApply ./modules/neovim.nix inputs;
wrapper = wrappers.lib.evalModule module;
in {
lib = {
eval = {pkgs, modules ? []}: evalWithPkgs pkgs modules;
mkWrapper = {pkgs, modules ? []}: (evalWithPkgs pkgs modules).config.wrap {inherit pkgs;};
devShellPackages = config: mkDevShellPackages config;
shellHook = config: mkShellHook config;
};
overlays = {
# overlay `vv` wraps the module with default settings only.
# It is evaluated against the final package set so module defaults can
# depend on overlays such as rixpkgs-backed `pkgs.rpkgs`.
default = nixpkgs.lib.composeManyExtensions [
overlayDefs.dependencyOverlay
dependencyOverlay
(final: prev: {
vv = (evalWithPkgs final []).config.wrap {pkgs = final;};
vv = wrapper.config.wrap {pkgs = final;};
})
];
dependencies = overlayDefs.dependencyOverlay;
dependencies = dependencyOverlay;
vv = self.overlays.default;
};
wrapperModules.default = module;
wrapperConfigs.default = {pkgs, modules ? []}: (self.lib.eval {inherit pkgs modules;}).config;
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 = self.lib.mkWrapper {
inherit pkgs;
};
default = nvimPkg;
vv = nvimPkg;
}
);
@ -138,13 +146,14 @@
devShells = forAllSystems (
system: let
pkgs = mkPkgs system;
config = (self.lib.eval {inherit pkgs;}).config;
nvimPkg = config.wrap {inherit pkgs;};
nvimPkg = wrapperSettings pkgs;
in {
default = pkgs.mkShell {
name = "vShell";
packages = [nvimPkg] ++ self.lib.devShellPackages config;
shellHook = mkShellHook config;
packages = [nvimPkg];
nativeBuildInputs = with pkgs; [] ++ (pkgs.lib.optionals self.wrappers.default.cats.optional [devenv]);
inputsFrom = [];
shellHook = "";
};
}
);
@ -152,34 +161,20 @@
checks = forAllSystems (
system: let
pkgs = mkPkgs system;
defaultConfig = (self.lib.eval {inherit pkgs;}).config;
defaultNvimPkg = defaultConfig.wrap {inherit pkgs;};
defaultShellHook = mkShellHook defaultConfig;
overrideConfig =
(self.lib.eval {
inherit pkgs;
modules = [
{
cats = {
r = true;
python = true;
};
settings.lang_packages.python = nixpkgs.lib.mkForce (with pkgs.python3Packages; [
polars
]);
catPkgs.nix = nixpkgs.lib.mkForce [
pkgs.alejandra
];
}
];
}).config;
overrideShellHook = mkShellHook overrideConfig;
nvimPkg = wrapperSettings pkgs;
in {
default = pkgs.runCommand "check-vv" {} ''
BINARY_PATH="${defaultNvimPkg}/bin/vv"
default = nvimPkg;
module-eval = let
_ = wrapper.config;
in
pkgs.runCommand "check-module-eval" {} ''
echo "Module evaluation successful" > $out
'';
package-build = pkgs.runCommand "check-vv" {} ''
BINARY_PATH="${nvimPkg}/bin/vv"
if [ ! -x "$BINARY_PATH" ]; then
echo "Error: Binary not found or not executable"
echo "Error: Binary n not found or not executable"
exit 1
fi
@ -192,97 +187,18 @@
cat version_output.txt >> $out
fi
'';
module-eval = let
_ = (self.lib.eval {inherit pkgs;}).config;
in
pkgs.runCommand "check-module-eval" {} ''
echo "Module evaluation successful" > $out
'';
downstream-overrides = let
overrideNix = builtins.map (p: p.pname or p.name) overrideConfig.catPkgs.nix;
defaultAssertions = [
(defaultConfig.cats.r or false)
(builtins.match ".*R RHOME.*" defaultShellHook != null)
(builtins.length (self.lib.devShellPackages defaultConfig) > 0)
];
overrideAssertions = [
(overrideConfig.cats.r or false)
(builtins.length overrideNix == 1)
((builtins.head overrideNix) == "alejandra")
(builtins.match ".*R RHOME.*" overrideShellHook != null)
];
in
pkgs.runCommand "check-downstream-overrides" {
pass =
if builtins.all (x: x) (defaultAssertions ++ overrideAssertions)
then "1"
else "";
} ''
if [ -z "$pass" ]; then
echo "Downstream override assertions failed" >&2
exit 1
fi
echo "Downstream override assertions passed" > $out
'';
lua-test = pkgs.runCommand "lua-test" {
buildInputs = [ pkgs.neovim-unwrapped ];
} ''
nvim --headless -u NONE -c "set runtimepath+=${./.}" -l ${./tests/init.lua}
touch $out
'';
# Downstream modules assign settings.lang_packages.<lang> plainly. The
# module system replaces same-option defaults, so built-in defaults must
# live in langPackageDefaults and be composed at the consumption sites.
# This check fails if someone moves defaults back into lang_packages:
# then a downstream assignment would silently drop lintr etc.
append-semantics = let
downstreamCfg = (self.lib.eval {
inherit pkgs;
modules = [
{
cats.r = true;
settings.lang_packages.r = [ pkgs.rpkgs.rPackages.fixest ];
}
];
}).config;
rWrapperPkg = builtins.head downstreamCfg.catPkgs.r;
in
pkgs.runCommand "check-lang-packages-append" { } ''
script=$(readlink -f "${rWrapperPkg}/bin/R")
grep -q "r-lintr-" "$script" || {
echo "default R packages were dropped by a downstream lang_packages assignment" >&2
exit 1
}
grep -q "r-fixest-" "$script" || {
echo "downstream lang_packages.r additions were not appended" >&2
exit 1
}
echo "lang_packages append semantics OK" > $out
'';
smoke-test = pkgs.runCommand "smoke-test" {} ''
# The Nix build sandbox has a read-only HOME; point XDG dirs at a
# writable location so vim.lsp/shaDa can write state headlessly.
export XDG_CONFIG_HOME=$TMPDIR/xdg-config
export XDG_STATE_HOME=$TMPDIR/xdg-state
export XDG_CACHE_HOME=$TMPDIR/xdg-cache
export XDG_DATA_HOME=$TMPDIR/xdg-data
BINARY_PATH="${defaultNvimPkg}/bin/vv"
"$BINARY_PATH" --headless -c "luafile ${./tests/smoke.lua}" -c "qa!"
touch $out
'';
}
);
nixosModules.default = wrappers.lib.getInstallModule {
nixosModules.default = wrappers.lib.mkInstallModule {
name = "vModule";
value = module;
};
homeModules.default = wrappers.lib.getInstallModule {
homeModules.default = wrappers.lib.mkInstallModule {
name = "vModule";
value = module;
loc = ["home" "packages"];
};
};
}

View file

@ -1,7 +1,5 @@
-- Add the key mappings only for Markdown files in a zk notebook.
local nix = require("config.nix")
if nix.get_cat("markdown", false) then
if require("zk.util").notebook_root(vim.fn.expand('%:p')) ~= nil then
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 })
@ -31,5 +29,4 @@ if nix.get_cat("markdown", false) then
map("v", "<leader>za", ":'<,'>lua vim.lsp.buf.range_code_action()<CR>",
{ noremap = true, silent = false, buffer = true, desc = "Code actions" })
end
end

View file

@ -1,28 +1,23 @@
local quarto_ok, quarto = pcall(require, 'quarto')
if quarto_ok then
vim.keymap.set('n', '<leader>qp', quarto.quartoPreview, { silent = true, noremap = true, buffer = true })
end
local quarto = require('quarto')
quarto.setup()
vim.keymap.set('n', '<leader>qp', quarto.quartoPreview, { silent = true, noremap = true })
if vim.bo.filetype == "r" then
vim.keymap.set("n", "<Enter>", "<Plug>RDSendLine", { buffer = true })
vim.keymap.set("v", "<Enter>", "<Plug>RSendSelection", { buffer = true })
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 })
-- 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 })
end
-- Pipe operator (;;)
vim.keymap.set("i", ";;", "<Cmd>lua MiniTrailspace.trim()<CR><Plug>RInsertPipe<CR>", { buffer = true, noremap = true })
local runner_ok, runner = pcall(require, "quarto.runner")
if runner_ok then
vim.keymap.set("n", "<localleader>a", runner.run_cell, { desc = "run cell", silent = true, buffer = true })
vim.keymap.set("n", "<localleader>A", runner.run_all, { desc = "run all cells", silent = true, buffer = true })
vim.keymap.set("n", "<localleader>RA", function()
local runner = require("quarto.runner")
vim.keymap.set("n", "<localleader>a", runner.run_cell, { desc = "run cell", silent = true })
vim.keymap.set("n", "<localleader>A", runner.run_all, { desc = "run all cells", silent = true })
vim.keymap.set("n", "<localleader>RA", function()
runner.run_all(true)
end, { desc = "run all cells of all languages", silent = true, buffer = true })
end
end, { desc = "run all cells of all languages", silent = true })

View file

@ -1,5 +1,7 @@
local Config = require('config')
_G.Config = Config -- keep global alias for keymaps/backward compatibility
_G.Config = {}
local nix = require('config.nix').init { non_nix_value = true }
Config.isNixCats = nix.is_nix
Config.nixConfig = nix
require('lze').register_handlers(require('nixCatsUtils.lzUtils').for_cat)
@ -10,11 +12,8 @@ if not Config.isNixCats then
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')
-- Pin to the stable branch for reproducible non-Nix installs.
-- Change the tag/branch here if you need a newer version.
local mini_nvim_tag = 'stable'
local clone_cmd = {
'git', 'clone', '--filter=blob:none', '--branch=' .. mini_nvim_tag,
'git', 'clone', '--filter=blob:none',
'https://github.com/echasnovski/mini.nvim', mini_path
}
vim.fn.system(clone_cmd)

View file

@ -1,10 +0,0 @@
--- Shared configuration / state table.
--- Plugin submodules attach their helpers to this table at runtime.
local M = {}
-- Detect whether this Neovim was launched via nixCats.
local nix = require('config.nix').init { non_nix_value = true }
M.isNixCats = nix.is_nix
M.nixConfig = nix
return M

View file

@ -1,44 +0,0 @@
local Config = require('config')
-- Basic mappings =============================================================
-- NOTE: Most basic mappings come from 'mini.basics'
-- Shorter version of the most frequent way of going outside of terminal window
vim.keymap.set('t', '<C-h>', [[<C-\><C-N><C-w>h]])
-- Select all
-- vim.keymap.set({ "n", "v", "x" }, "<C-a>", "gg3vG$", { noremap = true, silent = true, desc = "Select all" })
-- Escape deletes highlights
vim.keymap.set("n", "<Esc>", "<cmd>nohlsearch<CR>")
-- Paste before/after linewise
local cmd = vim.fn.has('nvim-0.12') == 1 and 'iput' or 'put'
vim.keymap.set({ 'n', 'x' }, '[p', '<Cmd>exe "' .. cmd .. '! " . v:register<CR>', { desc = 'Paste Above' })
vim.keymap.set({ 'n', 'x' }, ']p', '<Cmd>exe "' .. cmd .. ' " . v:register<CR>', { desc = 'Paste Below' })
vim.keymap.set({ "n", "v", "x" }, "<leader>p", '"+p', { noremap = true, silent = true, desc = "Paste from clipboard" })
vim.keymap.set({ "n", "v", "x" }, "<leader>y", '"+y', { noremap = true, silent = true, desc = "Copy toclipboard" })
-- Create global tables with information about clue group in certain modes
-- Structure of tables is taken to be compatible with 'mini.clue'.
Config.leader_group_clues = {
{ mode = 'n', keys = '<Leader>a', desc = '+AI' },
{ mode = 'n', keys = '<Leader>b', desc = '+Buffer' },
{ mode = 'n', keys = '<Leader>e', desc = '+Explore' },
{ mode = 'n', keys = '<Leader>f', desc = '+Find' },
{ mode = 'n', keys = '<Leader>fl', desc = '+LSP' },
{ mode = 'n', keys = '<Leader>fa', desc = '+Git' },
{ mode = 'n', keys = '<Leader>g', desc = '+Git' },
{ mode = 'n', keys = '<Leader>l', desc = '+LSP' },
{ mode = 'n', keys = '<Leader>L', desc = '+Lua/Log' },
{ mode = 'n', keys = '<Leader>o', desc = '+Other' },
{ mode = 'n', keys = '<Leader>r', desc = '+R' },
{ mode = 'n', keys = '<Leader>s', desc = '+Send' },
{ mode = 'n', keys = '<Leader>d', desc = '+Debug' },
{ mode = 'n', keys = '<Leader>t', desc = '+Terminal' },
{ mode = 'n', keys = '<Leader>u', desc = '+UI' },
{ mode = 'n', keys = '<Leader>v', desc = '+Visits' },
{ mode = 'n', keys = '<Leader>w', desc = '+Windows' },
{ mode = 'x', keys = '<Leader>l', desc = '+LSP' },
{ mode = 'x', keys = '<Leader>r', desc = '+R' },
{ mode = 'n', keys = '<Leader>z', desc = '+ZK' },
{ mode = 'n', keys = '<Leader>zr', desc = '+Reviews' },
{ mode = 'x', keys = '<Leader>a', desc = '+AI' },
}

View file

@ -1,25 +0,0 @@
local M = {}
---Create a normal-mode `<Leader>` mapping.
function M.nmap_leader(suffix, rhs, desc, opts)
opts = opts or {}
opts.desc = desc
vim.keymap.set('n', '<Leader>' .. suffix, rhs, opts)
end
---Create a visual-mode `<Leader>` mapping.
function M.xmap_leader(suffix, rhs, desc, opts)
opts = opts or {}
opts.desc = desc
vim.keymap.set('x', '<Leader>' .. suffix, rhs, opts)
end
---Create a normal-mode LSP keymap with an "(LSP)" suffix in the description.
function M.nmap_lsp(keys, func, desc)
if desc then
desc = desc .. "(LSP)"
end
vim.keymap.set("n", keys, func, { desc = desc })
end
return M

View file

@ -1,294 +0,0 @@
local Config = require('config')
local helpers = require('keymap.helpers')
local nmap_leader = helpers.nmap_leader
local xmap_leader = helpers.xmap_leader
local nmap_lsp = helpers.nmap_lsp
-- stylua: ignore start
-- Switch buffers
nmap_leader('<Tab>', '<Cmd>bnext<CR>', 'Next buffer')
nmap_leader('<S-Tab>', '<Cmd>bprev<CR>', 'Prev buffer')
-- a is for 'AI'
nmap_leader("aa", function()
require("opencode").ask("@this: ")
end, "Ask OpenCode about this")
nmap_leader("ab", function()
require("opencode").prompt("Analyse @buffer")
end, "Analyse buffer")
nmap_leader("aB", function()
require("opencode").prompt("Analyse @buffers")
end, "Analyse open buffers")
nmap_leader("ad", function()
require("opencode").prompt("Explain @diagnostics and fix the underlying issue")
end, "Explain/fix diagnostics")
nmap_leader("an", function()
require("opencode").command("session.new")
end, "New OpenCode session")
nmap_leader("ap", function()
require("opencode").ask("@")
end, "Ask OpenCode with context")
nmap_leader("as", function()
require("opencode").select()
end, "Select OpenCode action")
xmap_leader("aa", function()
require("opencode").ask("@this: ")
end, "Ask OpenCode about selection")
xmap_leader("af", function()
require("opencode").prompt("Fix the selected code and preserve its surrounding API:\n@this")
end, "Fix selection")
xmap_leader("ap", function()
require("opencode").ask("@")
end, "Ask OpenCode with context")
xmap_leader("as", function()
require("opencode").select()
end, "Select OpenCode action")
-- b is for 'buffer'
nmap_leader('bb', '<Cmd>b#<CR>', 'Alternate')
nmap_leader('bd', '<Cmd>lua MiniBufremove.delete()<CR>', 'Delete')
nmap_leader('bD', '<Cmd>lua MiniBufremove.delete(0, true)<CR>', 'Delete!')
nmap_leader('bs', '<Cmd>lua Config.new_scratch_buffer()<CR>', 'Scratch')
nmap_leader('bw', '<Cmd>lua MiniBufremove.wipeout()<CR>', 'Wipeout')
nmap_leader('bW', '<Cmd>lua MiniBufremove.wipeout(0, true)<CR>', 'Wipeout!')
nmap_leader('bq', '<Cmd>qall<CR>', 'Quit all')
-- e is for 'explore' and 'edit'
nmap_leader('ed', '<Cmd>lua MiniFiles.open()<CR>', 'Directory')
nmap_leader('ef', '<Cmd>lua Config.try_opendir()<CR>', 'File directory')
nmap_leader('es', '<Cmd>lua MiniSessions.select()<CR>', 'Sessions')
nmap_leader('eq', '<Cmd>lua Config.toggle_quickfix()<CR>', 'Quickfix')
nmap_leader('ez', '<Cmd>lua MiniFiles.open(os.getenv("ZK_NOTEBOOK_DIR"))<CR>', 'Notes directory')
-- f is for 'fuzzy find'
nmap_leader('f/', '<Cmd>Pick history scope="/"<CR>', '"/" history')
nmap_leader('f:', '<Cmd>Pick history scope=":"<CR>', '":" history')
nmap_leader('f,', '<Cmd>Pick visit_labels<CR>', 'Visit labels')
nmap_leader('faa', '<Cmd>Pick git_hunks scope="staged"<CR>', 'Added hunks (all)')
nmap_leader('faA', '<Cmd>Pick git_hunks path="%" scope="staged"<CR>', 'Added hunks (current)')
nmap_leader('fb', '<Cmd>Pick buffers<CR>', 'Buffers')
nmap_leader(',', '<Cmd>Pick buffers<CR>', 'Buffers')
nmap_leader('fac', '<Cmd>Pick git_commits<CR>', 'Commits (all)')
nmap_leader('faC', '<Cmd>Pick git_commits path="%"<CR>', 'Commits (current)')
nmap_leader('fd', '<Cmd>Pick diagnostic scope="all"<CR>', 'Diagnostic workspace')
nmap_leader('fD', '<Cmd>Pick diagnostic scope="current"<CR>', 'Diagnostic buffer')
nmap_leader('ff', '<Cmd>Pick files<CR>', 'Files')
nmap_leader('fg', '<Cmd>Pick grep_live<CR>', 'Grep live')
nmap_leader('fG', '<Cmd>Pick grep pattern="<cword>"<CR>', 'Grep current word')
nmap_leader('fh', '<Cmd>Pick help<CR>', 'Help tags')
nmap_leader('fH', '<Cmd>Pick hl_groups<CR>', 'Highlight groups')
nmap_leader('fj', '<Cmd>Pick buf_lines scope="all"<CR>', 'Lines (all)')
nmap_leader('fJ', '<Cmd>Pick buf_lines scope="current"<CR>', 'Lines (current)')
nmap_leader('fam', '<Cmd>Pick git_hunks<CR>', 'Modified hunks (all)')
nmap_leader('faM', '<Cmd>Pick git_hunks path="%"<CR>', 'Modified hunks (current)')
nmap_leader('fm', '<Cmd>Pick marks<CR>', 'Marks')
nmap_leader('fn', '<cmd>ZkNotes<CR>', "Notes")
nmap_leader('fk', '<Cmd>Pick keymaps<CR>', 'Keymaps')
nmap_leader('fR', '<Cmd>Pick resume<CR>', 'Resume')
nmap_leader('fp', '<Cmd>Pick files<CR>', 'Files')
nmap_leader('fq', '<Cmd>Pick list scope="quickfix"<CR>', 'Quickfix')
nmap_leader('fr', '<Cmd>Pick lsp scope="references"<CR>', 'References (LSP)')
nmap_leader('flr', '<Cmd>Pick lsp scope="references"<CR>', 'References (LSP)')
nmap_leader('fS', '<Cmd>Pick lsp scope="workspace_symbol"<CR>', 'Symbols workspace (LSP)')
nmap_leader('flS', '<Cmd>Pick lsp scope="workspace_symbol"<CR>', 'Symbols workspace (LSP)')
nmap_leader('fs', '<Cmd>Pick lsp scope="document_symbol"<CR>', 'Symbols buffer (LSP)')
nmap_leader('fls', '<Cmd>Pick lsp scope="document_symbol"<CR>', 'Symbols buffer (LSP)')
nmap_leader('fld', '<Cmd>Pick lsp scope="definition"<CR>', 'Definition (LSP)')
nmap_leader('flD', '<Cmd>Pick lsp scope="declaration"<CR>', 'Declaration (LSP)')
nmap_leader('flt', '<Cmd>Pick lsp scope="type_definition"<CR>', 'Type Definition (LSP)')
nmap_leader('fv', '<Cmd>Pick visit_paths cwd=""<CR>', 'Visit paths (all)')
nmap_leader('fV', '<Cmd>Pick visit_paths<CR>', 'Visit paths (cwd)')
-- g is for git
local git_log_cmd = [[Git log --pretty=format:\%h\ \%as\ │\ \%s --topo-order]]
nmap_leader('gc', '<Cmd>Git commit<CR>', 'Commit')
nmap_leader('gC', '<Cmd>Git commit --amend<CR>', 'Commit amend')
nmap_leader('gd', '<Cmd>Git diff<CR>', 'Diff')
nmap_leader('gD', '<Cmd>Git diff -- %<CR>', 'Diff buffer')
nmap_leader("gg", "<cmd>Neogit<cr>", "Open Neogit UI")
nmap_leader('gl', '<Cmd>' .. git_log_cmd .. '<CR>', 'Log')
nmap_leader('gL', '<Cmd>' .. git_log_cmd .. ' --follow -- %<CR>', 'Log buffer')
nmap_leader('go', '<Cmd>lua MiniDiff.toggle_overlay()<CR>', 'Toggle overlay')
nmap_leader('gp', '<Cmd>Git pull<CR>', 'Pull')
nmap_leader('gP', '<Cmd>Git push<CR>', 'Push')
nmap_leader('gs', '<Cmd>lua MiniGit.show_at_cursor()<CR>', 'Show at cursor')
xmap_leader('gs', '<Cmd>lua MiniGit.show_at_cursor()<CR>', 'Show at selection')
-- j/k navigate quickfix
nmap_leader("j", '<cmd>cnext<CR>zz', "Quickfix next")
nmap_leader("k", '<cmd>cprev<CR>zz', "Quickfix prev")
-- l is for 'LSP' (Language Server Protocol)
vim.keymap.set({ 'n' }, 'grd', '<Cmd>lua vim.lsp.buf.definition()<CR>', { desc = 'Definition' })
vim.keymap.set({ 'n' }, 'grk', '<Cmd>lua vim.lsp.buf.hover()<CR>', { desc = 'Documentation' })
vim.keymap.set({ 'n' }, 'gre', '<Cmd>lua vim.diagnostic.open_float()<CR>', { desc = 'Diagnostics' })
nmap_lsp("K", '<Cmd>lua vim.lsp.buf.hover()<CR>', "Documentation")
local formatting_cmd = '<Cmd>lua require("conform").format({ lsp_format = "fallback" })<CR>'
nmap_leader('la', '<Cmd>lua vim.lsp.buf.code_action()<CR>', 'Actions')
nmap_leader('le', '<Cmd>lua vim.diagnostic.open_float()<CR>', 'Diagnostics popup')
nmap_leader('lf', formatting_cmd, 'Format')
nmap_leader('lk', '<Cmd>lua vim.lsp.buf.hover()<CR>', 'Documentation')
nmap_leader('li', '<Cmd>lua vim.lsp.buf.implementation()<CR>', 'Information')
-- use ]d and [d
--nmap_leader('lj', '<Cmd>lua vim.diagnostic.goto_next()<CR>', 'Next diagnostic')
--nmap_leader('lk', '<Cmd>lua vim.diagnostic.goto_prev()<CR>', 'Prev diagnostic')
nmap_leader('lR', '<Cmd>lua vim.lsp.buf.references()<CR>', 'References')
nmap_leader('lr', '<Cmd>lua vim.lsp.buf.rename()<CR>', 'Rename')
nmap_leader('ls', '<Cmd>lua vim.lsp.buf.definition()<CR>', 'Source definition')
xmap_leader('lf', formatting_cmd, 'Format selection')
-- L is for 'Lua'
nmap_leader('Lc', '<Cmd>lua Config.log_clear()<CR>', 'Clear log')
nmap_leader('LL', '<Cmd>luafile %<CR><Cmd>echo "Sourced lua"<CR>', 'Source buffer')
nmap_leader('Ls', '<Cmd>lua Config.log_print()<CR>', 'Show log')
nmap_leader('Lx', '<Cmd>lua Config.execute_lua_line()<CR>', 'Execute `lua` line')
-- m is for 'mark' (checkbox toggling)
nmap_leader('mc', '<Cmd>ToggleCheckbox<CR>', 'Toggle checkbox')
-- o is for 'other'
local trailspace_toggle_command = '<Cmd>lua vim.b.minitrailspace_disable = not vim.b.minitrailspace_disable<CR>'
nmap_leader('oh', '<Cmd>normal gxiagxila<CR>', 'Move arg left')
nmap_leader('ol', '<Cmd>normal gxiagxina<CR>', 'Move arg right')
nmap_leader('or', '<Cmd>lua MiniMisc.resize_window()<CR>', 'Resize to default width')
nmap_leader('ot', '<Cmd>lua MiniTrailspace.trim()<CR>', 'Trim trailspace')
nmap_leader('oT', trailspace_toggle_command, 'Trailspace hl toggle')
nmap_leader('oz', '<Cmd>lua MiniMisc.zoom()<CR>', 'Zoom toggle')
nmap_leader('ow',
"<Cmd>lua MiniSessions.write(vim.fn.input('Session name: ', string.match(vim.fn.getcwd(), \"[^/]+$\") .. '-session.vim'))<CR>",
'Write session')
-- r is for 'R'
nmap_leader('rc', '<Cmd>RSend devtools::check()<CR>', 'Check')
nmap_leader('rC', '<Cmd>RSend devtools::test_coverage()<CR>', 'Coverage')
nmap_leader('rd', '<Cmd>RSend devtools::document()<CR>', 'Document')
nmap_leader('ri', '<Cmd>RSend devtools::install(keep_source=TRUE)<CR>', 'Install')
nmap_leader('rk', '<Cmd>RSend quarto::quarto_preview("%")<CR>', 'Knit file')
nmap_leader('rl', '<Cmd>RSend devtools::load_all()<CR>', 'Load all')
nmap_leader('rL', '<Cmd>RSend devtools::load_all(recompile=TRUE)<CR>', 'Load all recompile')
nmap_leader('rm', '<Cmd>RSend Rcpp::compileAttributes()<CR>', 'Run examples')
nmap_leader('rT', '<Cmd>RSend testthat::test_file("%")<CR>', 'Test file')
nmap_leader('rt', '<Cmd>RSend devtools::test()<CR>', 'Test')
-- Visual `<leader>r` bindings (dispatched by the filetype-aware REPL
-- runner in `lua/keymap/repl.lua`). Previously the visual clue group was
-- empty, so this restores parity between the visual and normal `r`-group.
xmap_leader('rr', function() require('keymap.repl').send_selection() end, 'Send selection to REPL')
-- - Copy to clipboard and make reprex (which itself is loaded to clipboard)
xmap_leader('rx', '"+y :RSend reprex::reprex()<CR>', 'Reprex selection')
-- s is for 'send' (Send text to the active REPL/runner)
nmap_leader('s', function() require('keymap.repl').send_line() end, 'Send to REPL')
xmap_leader('s', function() require('keymap.repl').send_selection() end, 'Send selection to REPL')
-- d is for 'debug' (nvim-dap)
nmap_leader('db', '<Cmd>lua require("dap").toggle_breakpoint()<CR>', 'Toggle breakpoint')
nmap_leader('dB', '<Cmd>lua require("dap").set_breakpoint(vim.fn.input("Condition: "))<CR>', 'Conditional breakpoint')
nmap_leader('dc', '<Cmd>lua require("dap").continue()<CR>', 'Continue')
nmap_leader('do', '<Cmd>lua require("dap").step_over()<CR>', 'Step over')
nmap_leader('di', '<Cmd>lua require("dap").step_into()<CR>', 'Step into')
nmap_leader('dO', '<Cmd>lua require("dap").step_out()<CR>', 'Step out')
nmap_leader('dr', '<Cmd>lua require("dap").repl.open()<CR>', 'Open DAP REPL')
nmap_leader('du', '<Cmd>lua require("dapui").toggle()<CR>', 'Toggle DAP UI')
nmap_leader('dK', '<Cmd>lua require("dapui").eval()<CR>', 'Evaluate expression')
-- u is for UI
nmap_leader('ut', '<Cmd>TSContext toggle<CR>', 'Toggle TScontext')
nmap_leader('ua', '<Cmd>Copilot toggle<CR>', 'Toggle AI completion')
-- v is for 'visits'
nmap_leader('vv', '<Cmd>lua MiniVisits.add_label("core")<CR>', 'Add "core" label')
nmap_leader('vV', '<Cmd>lua MiniVisits.remove_label("core")<CR>', 'Remove "core" label')
nmap_leader('vl', '<Cmd>lua MiniVisits.add_label()<CR>', 'Add label')
nmap_leader('vL', '<Cmd>lua MiniVisits.remove_label()<CR>', 'Remove label')
local map_pick_core = function(keys, cwd, desc)
local rhs = function()
local sort_latest = MiniVisits.gen_sort.default({ recency_weight = 1 })
MiniExtra.pickers.visit_paths({
cwd = cwd,
filter = 'core',
sort = sort_latest
}, { source = { name = desc } })
end
nmap_leader(keys, rhs, desc)
end
map_pick_core('vc', '', 'Core visits (all)')
map_pick_core('vC', nil, 'Core visits (cwd)')
-- w is for 'windows'
nmap_leader("wh", "<C-w>h", "Go to Left Window", { remap = true })
nmap_leader("wj", "<C-w>j", "Go to Lower Window", { remap = true })
nmap_leader("wk", "<C-w>k", "Go to Upper Window", { remap = true })
nmap_leader("wl", "<C-w>l", "Go to Right Window", { remap = true })
nmap_leader("w>", "<Cmd>vertical resize +5<CR>", "Increase Window Width")
nmap_leader("w<lt>", "<Cmd>vertical resize -5<CR>", "Decrease Window Width")
local function set_window_width_percent(percent)
return function()
local target_width = math.max(1, math.floor(vim.o.columns * percent / 100 + 0.5))
vim.api.nvim_win_set_width(0, target_width)
end
end
for i = 1, 9 do
local percent = i * 10
nmap_leader(
"w" .. i,
set_window_width_percent(percent),
string.format("Set Window Width to %d%%", percent)
)
end
nmap_leader("_", "<C-W>s", "Split Window Below", { remap = true })
nmap_leader("|", "<C-W>v", "Split Window Right", { remap = true })
nmap_leader("wd", "<C-W>c", "Delete Window", { remap = true })
nmap_leader("wo", "<C-W>o", "Delete Other Windows", { remap = true })
-- z is for 'ZettelKasten'
nmap_leader("zo", '<Cmd>ZkNotes<CR>', "Notes")
nmap_leader("zt", '<Cmd>ZkTags<cr>', "Tags")
nmap_leader(
"zrd",
'<Cmd>ZkNew { group = "dreviews" }<CR>',
"Daily Review"
)
nmap_leader(
"zrw",
'<Cmd>ZkNew { group = "wreviews" }<CR>',
"Weekly Review"
)
nmap_leader(
"zn",
'<Cmd>ZkNew { group = "inbox", title = vim.fn.input("Title: ") }<CR>',
"New"
)
nmap_leader(
"zp",
"<Cmd>ZkNew { group = 'permanent', title = vim.fn.input('Title: ') }<CR>",
"Permanent"
)
nmap_leader(
"zl",
"<Cmd>ZkNew { group = 'literature', title = vim.fn.input('Title: '), extra.author = vim.fn.input('Author: '), extra.year = vim.fn.input('Year: ') }<CR>",
"Literature"
)
nmap_leader(
"zd",
"<Cmd>ZkNew { group = 'dashboard', title = vim.fn.input('Title: ') }<CR>",
"Dashboard"
)
nmap_leader(
"zP",
"<Cmd>ZkNew { group = 'project', title = vim.fn.input('Title: ')}<CR>",
"Project"
)
-- stylua: ignore end

View file

@ -1,101 +0,0 @@
--- Filetype-aware REPL/runner dispatcher.
--- Keeps the existing terminal setup intact; it only decides *which* runner
--- to use for the current buffer/filetype.
local M = {}
--- Resolve the filetype to use for dispatching.
--- Quarto buffers report `quarto`; R buffers report `r`. Fallback to the
--- actual filetype if no special handling is needed.
local function dispatch_ft()
local ft = vim.bo.filetype
if ft == "quarto" or ft == "rmd" or ft == "markdown" then
return "quarto"
end
return ft
end
--- Send the current line to the active REPL/runner.
function M.send_line()
local ft = dispatch_ft()
if ft == "r" then
-- R.nvim v1+ exposes a Lua API; try the modern `r.send` module first,
-- then fall back to the older `r.run` module, and finally to <Plug>.
local ok, rmod = pcall(require, "r.send")
if not ok or not rmod then
ok, rmod = pcall(require, "r.run")
end
if ok and rmod then
if type(rmod.line) == "function" then
rmod.line()
return
elseif type(rmod.send_line) == "function" then
rmod.send_line()
return
end
end
vim.api.nvim_feedkeys(
vim.api.nvim_replace_termcodes("<Plug>RDSendLine", true, false, true),
"m",
false
)
return
end
if ft == "quarto" then
local ok, runner = pcall(require, "quarto.runner")
if ok and runner then
if runner.run_line then
runner.run_line()
elseif runner.run_cell then
runner.run_cell()
end
return
end
end
-- Default: vim-slime (terminal).
local line = vim.api.nvim_get_current_line()
vim.fn["slime#send"](line .. "\n")
-- Move to the next line, matching the previous behaviour.
vim.cmd("normal! j")
end
--- Send the current visual selection to the active REPL/runner.
function M.send_selection()
local ft = dispatch_ft()
if ft == "r" then
-- Prefer R.nvim v1+ Lua API; try the modern `r.send` module first,
-- then fall back to the older `r.run` module, and finally to <Plug>.
local ok, rmod = pcall(require, "r.send")
if not ok or not rmod then
ok, rmod = pcall(require, "r.run")
end
if ok and rmod then
if type(rmod.selection) == "function" then
rmod.selection()
return
elseif type(rmod.send_selection) == "function" then
rmod.send_selection()
return
end
end
vim.api.nvim_feedkeys(
vim.api.nvim_replace_termcodes("<Plug>RSendSelection", true, false, true),
"m",
false
)
return
end
-- For Quarto/others, fall back to vim-slime's visual send.
vim.api.nvim_feedkeys(
vim.api.nvim_replace_termcodes("<Plug>SlimeRegionSend", true, false, true),
"m",
false
)
end
return M

View file

@ -1,17 +0,0 @@
local Config = require('config')
local helpers = require('keymap.helpers')
local nmap_leader = helpers.nmap_leader
-- Exit terminal insert mode with <Esc>
vim.keymap.set("t", "<Esc>", [[<C-\><C-n>]], { desc = "Exit terminal mode" })
-- t is for 'terminal'
nmap_leader("tc", '<Cmd>lua Config.terminal.open_clickhouse_client()<CR>', 'Open Clickhouse client')
nmap_leader("tl", '<Cmd>lua Config.terminal.open_clickhouse_local()<CR>', 'Open Clickhouse local')
nmap_leader("tp", '<Cmd>lua Config.terminal.open_python()<CR>', 'Open Python')
nmap_leader("tj", '<Cmd>lua Config.terminal.open_julia()<CR>', 'Open Julia')
nmap_leader("td", '<Cmd>lua Config.terminal.open_duckdb();Config.terminal.toggle_bracket()<CR>', 'Open DuckDB')
nmap_leader("tx", '<Cmd>lua Config.terminal.open_in_terminal()<CR>', 'Terminal Command')
nmap_leader("tt", '<Cmd>lua Config.terminal.open_shell()<CR>', 'Terminal')
nmap_leader("tb", '<Cmd>lua Config.terminal.toggle_bracket()<CR>', 'Toggle bracketed paste')
nmap_leader("up", '<Cmd>lua Config.terminal.toggle_bracket()<CR>', 'Toggle bracketed paste')

View file

@ -1,12 +1,5 @@
local M = {}
-- Define comment node types as constants
local COMMENT_TYPES = {
comment = true,
block_comment = true,
line_comment = true,
}
-- 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
@ -21,153 +14,183 @@ local function is_in_list(list, value)
return false
end
-- Safely get the Tree-sitter node under the cursor.
-- Define comment node types as constants
local COMMENT_TYPES = {
comment = true,
block_comment = true,
line_comment = true,
}
function M.get_current_node()
local ok, node = pcall(vim.treesitter.get_node, { ignore_injections = false })
return ok and node or nil
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
-- Detect the root node type of the current buffer's Tree-sitter tree.
function M.detect_global_node()
local cur_node = M.get_current_node()
local root
if not cur_node then
local ok, parser = pcall(vim.treesitter.get_parser)
if not ok or not parser then
-- print("No node detected")
local parser = vim.treesitter.get_parser()
if not parser then
return nil
end
local trees = parser:parse()
if not trees or not trees[1] then
return nil
end
root = trees[1]:root()
root = parser:parse()[1]:root()
else
root = cur_node:root()
end
return root and root:type() or nil
end
-- Ascend the tree from the current node until we hit a node whose parent is a
-- "global" node (or the root). This is the unit of code we want to send.
local function get_target_node(global_nodes)
local root_type = M.detect_global_node()
global_nodes = global_nodes or {}
local node = M.get_current_node()
if not node then
if not root then
return nil
end
while node do
local parent = node:parent()
if not parent then
break
end
local p_type = parent:type()
if is_in_list(global_nodes, p_type) or p_type == root_type then
break
end
node = parent
end
return node
return root:type()
end
-- Move the cursor to the next named sibling that is not a comment.
-- Operates on the Tree-sitter AST instead of scanning lines, so it is fast and
-- language-agnostic.
function M.move_to_next_non_empty_line(current_node)
local node = current_node
if not node then
node = get_target_node({})
end
if not node then
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
-- Walk up the tree until we find a node with a next named sibling,
-- so we escape nested blocks when we are on the last statement.
while node and not node:next_named_sibling() do
node = node:parent()
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 })
node = node:next_named_sibling()
while node do
if not COMMENT_TYPES[node:type()] then
local start_row, start_col = node:range()
pcall(vim.api.nvim_win_set_cursor, 0, { start_row + 1, start_col })
return true, node
end
node = node:next_named_sibling()
end
return false
end
function M.vselect_node(node)
if not node then
local node = M.get_current_node()
if not node or not node:type() then
-- print("No node found")
return false
end
local start_row, _, end_row, _ = node:range()
local global_node_type = M.detect_global_node()
vim.api.nvim_win_set_cursor(0, { start_row + 1, 0 })
vim.cmd("normal! V")
vim.api.nvim_win_set_cursor(0, { end_row + 1, 0 })
-- 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 target = get_target_node(global_nodes)
if not target then
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
if M.vselect_node(target) then
return target
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()
vim.api.nvim_feedkeys(
vim.api.nvim_replace_termcodes("<Plug>SlimeRegionSend", true, false, true),
"m",
false
)
-- 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 target_node = get_target_node(global_nodes)
if not target_node then
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
-- If sitting on a comment, step forward first so we don't send comments.
if COMMENT_TYPES[target_node:type()] then
local moved, next_node = M.move_to_next_non_empty_line(target_node)
if not moved or not next_node then
return
end
target_node = next_node
end
-- Send the selected text to the terminal using vim-slime
M.slime_send_region()
-- Extract node text and send directly to avoid visual-mode/feedkeys races.
local ok, text = pcall(vim.treesitter.get_node_text, target_node, 0)
if not ok or not text then
vim.notify("Could not extract code from Tree-sitter node", vim.log.levels.WARN)
return
end
vim.fn["slime#send"](text .. "\n")
-- Jump to the next relevant AST node instead of scanning lines
M.move_to_next_non_empty_line(target_node)
-- Move cursor and continue
ts_utils.goto_node(sel_node, true)
M.move_to_next_non_empty_line()
end
return M

View file

@ -1,55 +0,0 @@
-- omp bridge: expose an RPC socket so the omp harness can read this Neovim
-- instance's buffers on demand. Read-only on the agent side; this module only
-- owns the socket lifecycle.
--
-- Contract
-- * Socket path: $NVIM_OMP_SOCKET if set, else <stdpath('state')>/omp.sock
-- (~/.local/state/nvim/omp.sock on macOS, ~/.local/state/nvim/omp.sock
-- elsewhere). The omp-side tool in .omp/tools/nvim_buffers.mjs resolves the
-- *same* path, so the two sides agree without configuration.
-- * The agent reads buffers by evaluating read-only nvim API expressions over
-- the socket with `nvim --server <path> --remote-expr 'json_encode(...)'`.
-- Nothing here writes buffers or executes model-supplied commands.
local M = {}
local SOCKET_NAME = "omp.sock"
-- Resolve the deterministic socket path. Copies the rule on the omp side; keep
-- the two files in sync when changing the fallback or env override.
function M.socket_path()
local env = vim.env.NVIM_OMP_SOCKET
if env and env ~= "" then
return env
end
return vim.fn.stdpath("state") .. "/" .. SOCKET_NAME
end
-- Start the RPC listener. Returns the live socket path, or nil.
-- A second instance cannot bind the same address. This function deliberately
-- never removes an existing socket file: a failed liveness probe must not
-- disconnect another live Neovim instance.
-- If a crash leaves a stale socket, remove it manually only after confirming
-- that no Neovim process owns the path, then restart vv.
function M.start()
if vim.v.headless == 1 then
-- Headless runs (tests, CI) get no socket; nothing should depend on one.
return nil
end
local path = M.socket_path()
local ok, res = pcall(vim.fn.serverstart, path)
if ok and type(res) == "string" and res ~= "" then
-- serverstart returns the bound address string (e.g. "/tmp/omp.sock").
vim.notify("nvim_omp: RPC socket ready at " .. path, vim.log.levels.INFO)
return path
end
vim.notify(
"nvim_omp: could not bind RPC socket at " .. path
.. "; another instance may own it or a stale socket needs manual cleanup.",
vim.log.levels.WARN
)
return nil
end
return M

Some files were not shown because too many files have changed in this diff Show more