prepare basic structure
This commit is contained in:
parent
3fcc13077d
commit
188ace87db
4 changed files with 74 additions and 28 deletions
39
default.nix
39
default.nix
|
@ -1,39 +1,22 @@
|
|||
{ wrapNeovim, neovim-unwrapped, vimPlugins, ... }:
|
||||
{ callPackage, wrapNeovim, neovim-unwrapped, vimPlugins, ... }:
|
||||
|
||||
let
|
||||
lib = import ./lib.nix;
|
||||
|
||||
plugins = [
|
||||
(callPackage ./syntax { })
|
||||
];
|
||||
|
||||
in
|
||||
wrapNeovim neovim-unwrapped {
|
||||
withPython3 = false;
|
||||
withNodeJs = false;
|
||||
withRuby = false;
|
||||
|
||||
configure = {
|
||||
customRC = ''
|
||||
lua << EOF
|
||||
require("nvim-treesitter.configs").setup({
|
||||
-- A list of parser names, or "all"
|
||||
ensure_installed = {},
|
||||
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = false,
|
||||
|
||||
highlight = {
|
||||
enable = true,
|
||||
},
|
||||
|
||||
indent = {
|
||||
enable = true,
|
||||
},
|
||||
})
|
||||
EOF
|
||||
'';
|
||||
customRC = lib.mkLuaRc (lib.extractAttrs "luaConfig" plugins);
|
||||
|
||||
packages.myVimPackages =
|
||||
{
|
||||
start = with vimPlugins; [
|
||||
(nvim-treesitter.withPlugins
|
||||
(ts: [
|
||||
ts.tree-sitter-nix
|
||||
]))
|
||||
];
|
||||
};
|
||||
{ start = lib.extractAttrs "plugins" plugins; };
|
||||
};
|
||||
}
|
||||
|
|
39
lib.nix
Normal file
39
lib.nix
Normal file
|
@ -0,0 +1,39 @@
|
|||
rec {
|
||||
#############################################################################
|
||||
# Helpers
|
||||
|
||||
# Source: https://github.com/NixOS/nixpkgs/blob/d61bc96d16ca288c69b798b8e31eca64050098e3/lib/lists.nix
|
||||
foldr = op: nul: list:
|
||||
let
|
||||
len = builtins.length list;
|
||||
fold' = n:
|
||||
if n == len
|
||||
then nul
|
||||
else op (builtins.elemAt list n) (fold' (n + 1));
|
||||
in
|
||||
fold' 0;
|
||||
|
||||
extractAttrs = attr: list:
|
||||
let
|
||||
getAttr' = builtins.getAttr attr;
|
||||
hasAttr' = builtins.hasAttr attr;
|
||||
filteredList = builtins.filter hasAttr' list;
|
||||
in
|
||||
builtins.map getAttr' filteredList;
|
||||
|
||||
#############################################################################
|
||||
# Lua
|
||||
|
||||
mkLuaHeredoc = content: ''
|
||||
lua << EOF
|
||||
${content}
|
||||
EOF
|
||||
'';
|
||||
|
||||
mkLuaRc = contents:
|
||||
let
|
||||
concat = (a: b: a + b);
|
||||
luaHeredors = builtins.map mkLuaHeredoc contents;
|
||||
in
|
||||
foldr concat "" luaHeredors;
|
||||
}
|
12
syntax/default.nix
Normal file
12
syntax/default.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
{ vimPlugins, ... }:
|
||||
|
||||
{
|
||||
luaConfig = builtins.readFile ./treesitter.lua;
|
||||
|
||||
plugins = [
|
||||
(vimPlugins.nvim-treesitter.withPlugins
|
||||
(ts: [
|
||||
ts.tree-sitter-nix
|
||||
]))
|
||||
];
|
||||
}
|
12
syntax/treesitter.lua
Normal file
12
syntax/treesitter.lua
Normal file
|
@ -0,0 +1,12 @@
|
|||
require("nvim-treesitter.configs").setup({
|
||||
ensure_installed = {},
|
||||
sync_install = false,
|
||||
|
||||
highlight = {
|
||||
enable = true,
|
||||
},
|
||||
|
||||
indent = {
|
||||
enable = true,
|
||||
},
|
||||
})
|
Reference in a new issue