Compare commits

...

3 Commits

6 changed files with 270 additions and 42 deletions

View File

@ -1,5 +1,21 @@
{
"nodes": {
"catppuccin": {
"flake": false,
"locked": {
"lastModified": 1713105352,
"narHash": "sha256-yTVou/WArEWygBBs2NFPI9Dm9iSGfwVftKFbOAGl8tk=",
"owner": "catppuccin",
"repo": "nvim",
"rev": "a1439ad7c584efb3d0ce14ccb835967f030450fe",
"type": "github"
},
"original": {
"owner": "catppuccin",
"repo": "nvim",
"type": "github"
}
},
"cmp-luasnip": {
"flake": false,
"locked": {
@ -373,6 +389,7 @@
},
"root": {
"inputs": {
"catppuccin": "catppuccin",
"cmp-luasnip": "cmp-luasnip",
"cmp-nvim-lsp": "cmp-nvim-lsp",
"cmp-tabby": "cmp-tabby",
@ -398,8 +415,7 @@
"plenary-nvim": "plenary-nvim",
"tabby-nvim": "tabby-nvim",
"telescope-live-grep-args-nvim": "telescope-live-grep-args-nvim",
"telescope-nvim": "telescope-nvim",
"theme": "theme"
"telescope-nvim": "telescope-nvim"
}
},
"systems": {
@ -464,22 +480,6 @@
"repo": "telescope.nvim",
"type": "github"
}
},
"theme": {
"flake": false,
"locked": {
"lastModified": 1695478950,
"narHash": "sha256-SV5DTVwcVv6YIb7TGNYwq6rtIG5pFKubK07snXhV7z8=",
"owner": "catppuccin",
"repo": "nvim",
"rev": "3d9a5ed556e289bce6c1fb0af89ec838360641b2",
"type": "github"
},
"original": {
"owner": "catppuccin",
"repo": "nvim",
"type": "github"
}
}
},
"root": "root",

View File

@ -126,7 +126,7 @@
};
# https://github.com/catppuccin/nvim
theme = {
catppuccin = {
url = "github:catppuccin/nvim";
flake = false;
};
@ -191,7 +191,7 @@
"lualine-nvim"
"lualine-lsp-progress"
"nvim-web-devicons"
"theme"
"catppuccin"
# ux
"hop-nvim"
"nvim-orgmode"
@ -238,29 +238,27 @@
} //
flake-utils.lib.eachDefaultSystem (system:
let
inherit (builtins) mapAttrs;
pkgs = import nixpkgs { inherit system; };
minimalNeovim = mkNeovim pkgs;
recommendedNeovim = minimalNeovim.override {
recommendedNeovim = minimalNeovim.override (prev: {
modules = {
catppuccin = { };
nvim-tree-lua = {
configs = {
renderer = {
group_empty = true;
full_name = true;
};
configs.renderer = {
group_empty = true;
full_name = true;
};
keymaps = [
{ mode = "n"; bind = "<leader>nt"; command = "<CMD>NvimTreeToggle<CR>"; }
{ mode = "n"; bind = "<leader>nf"; command = "<CMD>NvimTreeFindFile<CR>"; }
];
};
nvim-treesitter = { };
};
plugins = with minimalNeovim.nix2lua; {
plugins = with prev.nix2lua.lib; {
lualine-nvim = pipe [
(require "lualine")
(call "setup" [{
@ -278,7 +276,7 @@
}])
];
};
};
});
fullNeovim = recommendedNeovim.override {
plugins = recommendedNeovim.plugins // (with minimalNeovim.nix2lua; {

13
modules/catppuccin.nix Normal file
View File

@ -0,0 +1,13 @@
{ nix2lua, ... }:
{ flavour ? "frappe" }:
with nix2lua.lib;
{
catppuccin = [
(set "vim.g.catppuccin_flavour" flavour)
(pipe [ (require "catppuccin") (call "setup" [ ]) ])
(call "vim.cmd" [ "colorscheme catppuccin" ])
];
}

View File

@ -1,4 +1,4 @@
{ nix2lua }:
{ nix2lua, ... }:
{ configs ? { }
, keymaps ? [
@ -14,6 +14,8 @@ let
isEmptyVar = name: eq "" (var name);
in
{
nvim-web-devicons = true;
nvim-tree-lua = (
[
(pipe [ (require "nvim-tree") (call "setup" [ configs ]) ])

208
modules/nvim-treesitter.nix Normal file
View File

@ -0,0 +1,208 @@
{ nix2lua, pkgs }:
let
defaultGrammars = g: [
# g.agda
# g.arduino
# g.astro
g.awk
g.bash
# g.beancount
# g.bibtex
# g.blueprint
# g.c
# g.c_sharp
# g.clojure
g.cmake
g.comment
# g.commonlisp
# g.cooklang
# g.cpp
# g.css
# g.cuda
# g.d
# g.d2
# g.dart
# g.devicetree
g.diff
# g.dockerfile
# g.dot
# g.eex
# g.elixir
# g.elm
# g.elvish
g.embedded_template
# g.erlang
# g.fennel
# g.fish
# g.foam
# g.fortran
# g.fusion
# g.gdscript
g.git_rebase
g.gitattributes
g.gitignore
# g.gleam
# g.glimmer
# g.glsl
# g.go
# g.godot_resource
# g.gomod
# g.gowork
# g.graphql
# g.hack
# g.haskell
# g.hcl
# g.heex
# g.hjson
# g.hlsl
# g.hocon
# g.html
g.http
# g.java
# g.javascript
g.jq
g.jsdoc
g.json
# g.json5
# g.jsonc
# g.jsonnet
# g.julia
# g.kotlin
# g.lalrpop
# g.latex
# g.ledger
# g.llvm
# g.lua
# g.m68k
g.make
g.markdown
g.markdown_inline
# g.menhir
# g.meson
# g.nickel
# g.ninja
g.nix
# g.norg
# g.ocaml
# g.ocaml_interface
# g.ocamllex
# g.org
# g.pascal
# g.perl
# g.php
# g.phpdoc
# g.pioasm
# g.prisma
# g.proto
# g.pug
# g.python
# g.ql
# g.qmljs
g.query
# g.r
# g.racket
# g.rasi
g.regex
# g.rego
# g.rnoweb
# g.rst
# g.ruby
# g.rust
# g.scala
g.scheme
# g.scss
# g.slint
# g.solidity
# g.sparql
# g.sql
# g.supercollider
# g.surface
# g.svelte
# g.swift
# g.sxhkdrc
# g.teal
# g.tiger
# g.tlaplus
g.todotxt
# g.toml
# g.tsx
# g.turtle
# g.twig
# g.typescript
# g.v
# g.vala
# g.verilog
# g.vhs
# g.vim
# g.vue
# g.wgsl
g.yaml
# g.yang
# g.zig
];
in
{ allGrammars ? false
, withGrammars ? defaultGrammars
}:
with nix2lua.lib;
let
extraGrammars = {
tree-sitter-d2 = {
language = "d2";
version = "2023-06-21";
src = pkgs.fetchFromGitea {
domain = "git.pleshevski.ru";
owner = "pleshevskiy";
repo = "tree-sitter-d2";
rev = "8a9d50043d58eedf1e375b0e2059e43efd856902";
sha256 = "sha256-ZhVjxo7Xi7DaHN3qabUcykflY74bUqPcOA410fA3zRk=";
};
};
};
tree-sitter = pkgs.tree-sitter.override { inherit extraGrammars; };
customGrammars = tree-sitter.withPlugins (g: [ g.tree-sitter-d2 ]);
nvimTreesitterWithGrammars =
if allGrammars then pkgs.vimPlugins.nvim-treesitter.withAllGrammars
else pkgs.vimPlugins.nvim-treesitter.withPlugins withGrammars;
finalNvimTreesitter = nvimTreesitterWithGrammars.overrideAttrs (oldAttrs: {
passthru.dependencies = oldAttrs.passthru.dependencies ++ [
(pkgs.runCommand "nvim-treesitter-d2-grammar" { } ''
mkdir -p $out/parser
ln -s ${customGrammars}/d2.so $out/parser/d2.so
'')
];
postPatch = ''
ln -s ${extraGrammars.tree-sitter-d2.src}/queries queries/d2
'';
});
in
{
override' = {
nvim-treesitter = finalNvimTreesitter;
};
nvim-treesitter = [
(local (set "parser_config"
(pipe [ (require "nvim-treesitter.parsers") (call "get_parser_configs" [ ]) ])
))
(set "parser_config.d2" { })
(pipe [
(require "nvim-treesitter.configs")
(call "setup" [{
ensure_installed = { };
sync_install = false;
highlight.enable = true;
indent.enable = true;
}])
])
];
}

View File

@ -4,8 +4,8 @@
, extraLuaConfig ? ""
, wrapNeovim
, neovim-unwrapped
, tree-sitter
, neovimPlugins
, pkgs
, lib
, nix2lua
, plugins ? { }
@ -16,6 +16,7 @@
let
plugins' = plugins;
modules' = modules;
mergeAttrs = v:
if builtins.isList v then
@ -28,18 +29,23 @@ let
in
let
plugins = mergeAttrs plugins';
modules = mergeAttrs modules';
importModule = moduleName: import (./modules + "/${moduleName}.nix") { inherit nix2lua; };
importModule = moduleName: import (./modules + "/${moduleName}.nix") { inherit nix2lua pkgs; };
allModules = mergeAttrs (lib.mapAttrsToList importModule modules);
pluginsWithModules = mergeAttrs [ allModules plugins ];
# Type: excludeOverride :: AttrSet -> AttrSet
excludeOverride = lib.filterAttrs (n: v: n != "override'");
# Type: pluginsWithModules :: AttrSet
pluginsWithModules = mergeAttrs [ (excludeOverride allModules) plugins ];
overridedNeovimPlugins =
if allModules ? override' then neovimPlugins // allModules.override'
else neovimPlugins;
/*
Type: getPluginByName :: string -> derivation
*/
getPluginByName = lib.flip lib.getAttr neovimPlugins;
# Type: getPluginByName :: string -> derivation
getPluginByName = lib.flip lib.getAttr overridedNeovimPlugins;
# Type: allPlugins :: AttrSet -> [derivation]
allPlugins = map getPluginByName (lib.attrNames pluginsWithModules);
/*
@ -49,9 +55,10 @@ let
with nix2lua.lib;
"-- Plugin: ${builtins.trace "Plugin: ${name}" name}\n"
+ (if lib.isString cfg then cfg
else if lib.isAttrs cfg then toLua cfg
else if lib.isAttrs cfg && cfg ? _type then toLua cfg
else if lib.isList cfg then toLua (concatLines cfg)
else abort "[neovim] mkPluginLuaConfig: unsupported type");
else if lib.isBool cfg then "" # Just skip lua config. Only enable the plugin.
else abort "[neovim] mkPluginLuaConfig: '${name}' has unsupported type '${builtins.typeOf cfg}'");
pluginLuaConfigs = lib.mapAttrsToList mkPluginLuaConfig pluginsWithModules;
basicLuaConfigs = map builtins.readFile [ ./config/basic.lua ];
@ -84,6 +91,6 @@ in
}).overrideAttrs (oldAttrs: {
passthru = oldAttrs.passthru // {
nix2lua = nix2lua.lib;
inherit plugins;
inherit plugins modules;
};
})