mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
tests/plugins: refactor (#235)
This commit is contained in:
parent
89f54be73a
commit
db5061b4db
38 changed files with 485 additions and 744 deletions
|
@ -67,8 +67,9 @@
|
|||
extractRustAnalyzerPkg = pkgs.callPackage extractRustAnalyzer {};
|
||||
in {
|
||||
checks =
|
||||
(import ./tests/checks.nix {
|
||||
(import ./tests {
|
||||
inherit pkgs;
|
||||
inherit (pkgs) lib;
|
||||
makeNixvim = self.legacyPackages."${system}".makeNixvim;
|
||||
})
|
||||
// {
|
||||
|
|
|
@ -57,7 +57,7 @@ with lib; let
|
|||
{
|
||||
event = [ "BufEnter" "BufWinEnter" ];
|
||||
pattern = [ "*.c" "*.h" ];
|
||||
callback = { __raw = "function() print("This buffer enters") end"; };
|
||||
callback = { __raw = "function() print('This buffer enters') end"; };
|
||||
}
|
||||
'';
|
||||
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
{
|
||||
makeNixvim,
|
||||
pkgs,
|
||||
} @ args: let
|
||||
tests = import ./plugins {inherit (pkgs) lib;};
|
||||
check = import ../lib/check.nix args;
|
||||
checkConfig = check.checkNvim;
|
||||
in
|
||||
# We attempt to build & execute all configurations
|
||||
builtins.mapAttrs (
|
||||
name: config: let
|
||||
testAttributes =
|
||||
if builtins.hasAttr "tests" config
|
||||
then config.tests
|
||||
else {
|
||||
dontRun = false;
|
||||
};
|
||||
nvim = makeNixvim (pkgs.lib.attrsets.filterAttrs (n: _: n != "tests") config);
|
||||
in
|
||||
checkConfig {
|
||||
inherit name nvim;
|
||||
inherit (testAttributes) dontRun;
|
||||
}
|
||||
)
|
||||
tests
|
16
tests/default.nix
Normal file
16
tests/default.nix
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
makeNixvim,
|
||||
lib,
|
||||
pkgs,
|
||||
}: let
|
||||
fetchTests = import ./fetch-tests.nix;
|
||||
mkTestDerivation = import ./test-derivation.nix {inherit pkgs makeNixvim;};
|
||||
|
||||
# List of files containing configurations
|
||||
testFiles = fetchTests {
|
||||
inherit lib pkgs;
|
||||
root = ./test-sources;
|
||||
};
|
||||
in
|
||||
# We attempt to build & execute all configurations
|
||||
builtins.mapAttrs mkTestDerivation testFiles
|
67
tests/fetch-tests.nix
Normal file
67
tests/fetch-tests.nix
Normal file
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
root,
|
||||
lib,
|
||||
pkgs,
|
||||
}: let
|
||||
# Handle an entry from readDir and either extract the configuration if its a regular file,
|
||||
# or continue to recurse if it's a directory. While recursing maintain a list of the traversed
|
||||
# directories
|
||||
handleEntry = relativePath: namespace: name: type: let
|
||||
file = "${root}/${relativePath}/${name}";
|
||||
in
|
||||
if type == "regular"
|
||||
then [
|
||||
{
|
||||
namespace = namespace ++ [(lib.strings.removeSuffix ".nix" name)];
|
||||
cases = import file;
|
||||
}
|
||||
]
|
||||
else parseDirectories file (namespace ++ [name]);
|
||||
|
||||
# Recurse into all directories, extracting files as we find them. This returs a deeply nested
|
||||
# list, where each non list element is a set of test cases.
|
||||
parseDirectories = path: namespace: let
|
||||
relativePath = lib.removePrefix "${root}" "${path}";
|
||||
|
||||
children = builtins.readDir path;
|
||||
childrenFiltered =
|
||||
lib.attrsets.filterAttrs (n: v: v != "symlink") children;
|
||||
|
||||
childrenRecursed =
|
||||
lib.attrsets.mapAttrsToList (handleEntry relativePath namespace) childrenFiltered;
|
||||
in
|
||||
childrenRecursed;
|
||||
|
||||
# Remove the nesting
|
||||
testsList = lib.lists.flatten (parseDirectories root []);
|
||||
|
||||
testsListEvaluated = builtins.map ({
|
||||
cases,
|
||||
namespace,
|
||||
} @ args:
|
||||
if builtins.isAttrs cases
|
||||
then args
|
||||
else {
|
||||
# cases = cases {inherit pkgs;};
|
||||
cases = cases {inherit pkgs;};
|
||||
inherit namespace;
|
||||
})
|
||||
testsList;
|
||||
|
||||
# Take a list of test cases (i.e the content of a file) and prepare a test case that can be
|
||||
# handled by mkTestDerivation
|
||||
handleTestFile = {
|
||||
namespace,
|
||||
cases,
|
||||
}:
|
||||
lib.attrsets.mapAttrs' (case: config: {
|
||||
name = lib.strings.concatStringsSep "-" (namespace ++ [case]);
|
||||
value = config;
|
||||
})
|
||||
cases;
|
||||
|
||||
# Helper function that calls `//` for each attrset of a list
|
||||
concatMany = list: lib.lists.foldr lib.mergeAttrs {} list;
|
||||
# An attrset of 'test-name' -> 'test-config'
|
||||
in
|
||||
concatMany (builtins.map handleTestFile testsListEvaluated)
|
334
tests/flake.lock
generated
334
tests/flake.lock
generated
|
@ -1,334 +0,0 @@
|
|||
{
|
||||
"nodes": {
|
||||
"beautysh": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixvim",
|
||||
"nixpkgs"
|
||||
],
|
||||
"poetry2nix": "poetry2nix",
|
||||
"utils": "utils"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1669854260,
|
||||
"narHash": "sha256-Z8NAL3g4i5LAhxveNGJhrVDHxIBbUf1lVIy/Thr2RMU=",
|
||||
"owner": "lovesegfault",
|
||||
"repo": "beautysh",
|
||||
"rev": "d616eb8d9d05ee4fb33de9c5521d99c3f0695d52",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "lovesegfault",
|
||||
"repo": "beautysh",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"beautysh_2": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixvim-stable",
|
||||
"nixpkgs"
|
||||
],
|
||||
"poetry2nix": "poetry2nix_2",
|
||||
"utils": "utils_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1669854260,
|
||||
"narHash": "sha256-Z8NAL3g4i5LAhxveNGJhrVDHxIBbUf1lVIy/Thr2RMU=",
|
||||
"owner": "lovesegfault",
|
||||
"repo": "beautysh",
|
||||
"rev": "d616eb8d9d05ee4fb33de9c5521d99c3f0695d52",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "lovesegfault",
|
||||
"repo": "beautysh",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"build-ts": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1669771646,
|
||||
"narHash": "sha256-IfH9zCq0+QpAB8D1ClhISfWcR59mSDsi91/2NW0RWfs=",
|
||||
"owner": "pta2002",
|
||||
"repo": "build-ts-grammar.nix",
|
||||
"rev": "bba8a5b14a4632f25411dbf0fb01de69e999ce82",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "pta2002",
|
||||
"repo": "build-ts-grammar.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_3": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_4": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gleam": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1672454845,
|
||||
"narHash": "sha256-h/5SpMD725BasD2+5J0B7OCDzoWlDBGDm7ywTEYmQbk=",
|
||||
"owner": "gleam-lang",
|
||||
"repo": "tree-sitter-gleam",
|
||||
"rev": "3eb2e1783f3bf6f85c16cdd150e2f256b2f6844e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "gleam-lang",
|
||||
"repo": "tree-sitter-gleam",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1671108576,
|
||||
"narHash": "sha256-6ggOL6KoaELNA1562tnPjtAnQ9SwsKRTgeuaXvPzCwI=",
|
||||
"path": "/nix/store/iscn1qzhdwvb3mkr5kvsy9gvyhkdnzl3-source",
|
||||
"rev": "0f5996b524c91677891a432cc99c7567c7c402b1",
|
||||
"type": "path"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs-stable": {
|
||||
"locked": {
|
||||
"lastModified": 1672580127,
|
||||
"narHash": "sha256-3lW3xZslREhJogoOkjeZtlBtvFMyxHku7I/9IVehhT8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0874168639713f547c05947c76124f78441ea46c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-22.05",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1671108576,
|
||||
"narHash": "sha256-6ggOL6KoaELNA1562tnPjtAnQ9SwsKRTgeuaXvPzCwI=",
|
||||
"path": "/nix/store/iscn1qzhdwvb3mkr5kvsy9gvyhkdnzl3-source",
|
||||
"rev": "0f5996b524c91677891a432cc99c7567c7c402b1",
|
||||
"type": "path"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1673606088,
|
||||
"narHash": "sha256-wdYD41UwNwPhTdMaG0AIe7fE1bAdyHe6bB4HLUqUvck=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "37b97ae3dd714de9a17923d004a2c5b5543dfa6d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixvim": {
|
||||
"inputs": {
|
||||
"beautysh": "beautysh",
|
||||
"flake-utils": "flake-utils_3",
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 0,
|
||||
"narHash": "sha256-7N6OttwH7E7URRmQ79MacpMu4eSzxYlRgW06FOP/lWg=",
|
||||
"path": "/nix/store/s8ql6s1cwxm1ah1pi4y6h4xv2mz2j4v1-source",
|
||||
"type": "path"
|
||||
},
|
||||
"original": {
|
||||
"path": "/nix/store/s8ql6s1cwxm1ah1pi4y6h4xv2mz2j4v1-source",
|
||||
"type": "path"
|
||||
}
|
||||
},
|
||||
"nixvim-stable": {
|
||||
"inputs": {
|
||||
"beautysh": "beautysh_2",
|
||||
"flake-utils": "flake-utils_4",
|
||||
"nixpkgs": [
|
||||
"nixpkgs-stable"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 0,
|
||||
"narHash": "sha256-7N6OttwH7E7URRmQ79MacpMu4eSzxYlRgW06FOP/lWg=",
|
||||
"path": "/nix/store/s8ql6s1cwxm1ah1pi4y6h4xv2mz2j4v1-source",
|
||||
"type": "path"
|
||||
},
|
||||
"original": {
|
||||
"path": "/nix/store/s8ql6s1cwxm1ah1pi4y6h4xv2mz2j4v1-source",
|
||||
"type": "path"
|
||||
}
|
||||
},
|
||||
"poetry2nix": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"nixvim",
|
||||
"beautysh",
|
||||
"utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixvim",
|
||||
"beautysh",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1658665240,
|
||||
"narHash": "sha256-/wkx7D7enyBPRjIkK0w7QxLQhzEkb3UxNQnjyc3FTUI=",
|
||||
"owner": "nix-community",
|
||||
"repo": "poetry2nix",
|
||||
"rev": "8b8edc85d24661d5a6d0d71d6a7011f3e699780f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "poetry2nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"poetry2nix_2": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"nixvim-stable",
|
||||
"beautysh",
|
||||
"utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixvim-stable",
|
||||
"beautysh",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1658665240,
|
||||
"narHash": "sha256-/wkx7D7enyBPRjIkK0w7QxLQhzEkb3UxNQnjyc3FTUI=",
|
||||
"owner": "nix-community",
|
||||
"repo": "poetry2nix",
|
||||
"rev": "8b8edc85d24661d5a6d0d71d6a7011f3e699780f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "poetry2nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"build-ts": "build-ts",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"gleam": "gleam",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"nixpkgs-stable": "nixpkgs-stable",
|
||||
"nixvim": "nixvim",
|
||||
"nixvim-stable": "nixvim-stable"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils_2": {
|
||||
"locked": {
|
||||
"lastModified": 1667395993,
|
||||
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
318
tests/flake.nix
318
tests/flake.nix
|
@ -1,318 +0,0 @@
|
|||
{
|
||||
description = "A set of test configurations for nixvim";
|
||||
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
inputs.nixvim.url = "./..";
|
||||
|
||||
inputs.build-ts.url = "github:pta2002/build-ts-grammar.nix";
|
||||
inputs.gleam.url = "github:gleam-lang/tree-sitter-gleam";
|
||||
inputs.gleam.flake = false;
|
||||
|
||||
inputs.nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-22.05";
|
||||
inputs.nixvim-stable = {
|
||||
url = "./..";
|
||||
inputs.nixpkgs.follows = "nixpkgs-stable";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixvim,
|
||||
nixvim-stable,
|
||||
nixpkgs,
|
||||
flake-utils,
|
||||
nixpkgs-stable,
|
||||
build-ts,
|
||||
gleam,
|
||||
...
|
||||
}:
|
||||
(flake-utils.lib.eachDefaultSystem
|
||||
(system: let
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
pkgs-stable = import nixpkgs-stable {inherit system;};
|
||||
build = nixvim.legacyPackages.${system}.makeNixvim;
|
||||
build-stable = nixvim-stable.legacyPackages.${system}.makeNixvim;
|
||||
in rec {
|
||||
# A plain nixvim configuration
|
||||
packages = {
|
||||
plain = build {};
|
||||
|
||||
# Should print "Hello!" when starting up
|
||||
hello = build {
|
||||
extraConfigLua = "print(\"Hello!\")";
|
||||
};
|
||||
|
||||
simple-plugin = build {
|
||||
extraPlugins = [pkgs.vimPlugins.vim-surround];
|
||||
};
|
||||
|
||||
gruvbox = build {
|
||||
extraPlugins = [pkgs.vimPlugins.gruvbox];
|
||||
colorscheme = "gruvbox";
|
||||
};
|
||||
|
||||
gruvbox-module = build {
|
||||
colorschemes.gruvbox.enable = true;
|
||||
};
|
||||
|
||||
treesitter = build {
|
||||
plugins.treesitter.enable = true;
|
||||
};
|
||||
|
||||
treesitter-nonix = build {
|
||||
plugins.treesitter = {
|
||||
enable = true;
|
||||
nixGrammars = false;
|
||||
};
|
||||
};
|
||||
elixir-ls = build {
|
||||
plugins.lsp.enable = true;
|
||||
plugins.lsp.servers.elixirls.enable = true;
|
||||
};
|
||||
|
||||
lsp-lines = build-stable {
|
||||
plugins.lsp-lines.enable = true;
|
||||
};
|
||||
|
||||
trouble = build {
|
||||
plugins.lsp = {
|
||||
enable = true;
|
||||
servers.clangd.enable = true;
|
||||
};
|
||||
|
||||
plugins.trouble.enable = true;
|
||||
};
|
||||
|
||||
beautysh = build {
|
||||
plugins.null-ls = {
|
||||
enable = true;
|
||||
sources.formatting.beautysh.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
keymaps = build {
|
||||
maps.normal."," = "<cmd>echo \"test\"<cr>";
|
||||
};
|
||||
|
||||
issue-40 = build-stable {
|
||||
plugins = {
|
||||
nix.enable = true;
|
||||
nvim-autopairs.enable = true;
|
||||
|
||||
lualine = {
|
||||
enable = true;
|
||||
|
||||
sectionSeparators = {
|
||||
left = "";
|
||||
right = "";
|
||||
};
|
||||
|
||||
componentSeparators = {
|
||||
left = "";
|
||||
right = "";
|
||||
};
|
||||
|
||||
theme = "auto";
|
||||
};
|
||||
|
||||
goyo = {
|
||||
enable = true;
|
||||
showLineNumbers = false;
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = true;
|
||||
servers = {
|
||||
rust-analyzer.enable = true;
|
||||
rnix-lsp.enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
options = {
|
||||
# Indentation
|
||||
autoindent = true;
|
||||
tabstop = 4;
|
||||
shiftwidth = 4;
|
||||
expandtab = true;
|
||||
backspace = "indent,eol,start";
|
||||
|
||||
# Text
|
||||
showmatch = true;
|
||||
mouse = "a";
|
||||
number = true;
|
||||
relativenumber = false;
|
||||
ttyfast = true;
|
||||
clipboard = "unnamedplus";
|
||||
|
||||
# Colors
|
||||
background = "dark";
|
||||
termguicolors = true;
|
||||
};
|
||||
};
|
||||
|
||||
issue-65 = build {
|
||||
colorschemes.gruvbox = {
|
||||
enable = true;
|
||||
contrastLight = "hard";
|
||||
contrastDark = "hard";
|
||||
};
|
||||
|
||||
options = {
|
||||
number = true;
|
||||
shiftwidth = 2;
|
||||
tabstop = 2;
|
||||
guifont = "FiraCode\ Nerd\ Font\ Mono:h14";
|
||||
};
|
||||
|
||||
plugins = {
|
||||
lsp = {
|
||||
enable = true;
|
||||
servers.rnix-lsp.enable = true;
|
||||
servers.rust-analyzer.enable = true;
|
||||
servers.jsonls.enable = true;
|
||||
};
|
||||
|
||||
nvim-tree = {
|
||||
enable = true;
|
||||
openOnSetup = true;
|
||||
openOnTab = true;
|
||||
};
|
||||
|
||||
telescope = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
nvim-cmp = {
|
||||
formatting = {
|
||||
format = ''
|
||||
require("lspkind").cmp_format({
|
||||
mode="symbol",
|
||||
maxwidth = 50,
|
||||
ellipsis_char = "..."
|
||||
})
|
||||
'';
|
||||
};
|
||||
|
||||
auto_enable_sources = true;
|
||||
snippet = {
|
||||
expand = ''
|
||||
function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
end
|
||||
'';
|
||||
};
|
||||
enable = true;
|
||||
sources = [
|
||||
{name = "nvim_lsp";}
|
||||
{
|
||||
name = "luasnip";
|
||||
option = {
|
||||
show_autosnippets = true;
|
||||
};
|
||||
}
|
||||
{name = "path";}
|
||||
{name = "buffer";}
|
||||
];
|
||||
};
|
||||
barbar.enable = true;
|
||||
};
|
||||
|
||||
globals.mapleader = " ";
|
||||
extraPlugins = with pkgs.vimPlugins; [
|
||||
which-key-nvim
|
||||
# leap-nvim
|
||||
vim-flutter
|
||||
plenary-nvim
|
||||
fidget-nvim
|
||||
luasnip
|
||||
lspkind-nvim
|
||||
];
|
||||
|
||||
# extraConfigLua = (builtins.readFile ./nvim-extra-lua.lua);
|
||||
};
|
||||
|
||||
issue-71 = build {
|
||||
maps.normal."<leader>hb" = "<cmd>lua require('gitsigns').blame_line{full=true}<cr>";
|
||||
};
|
||||
|
||||
lspkind = build {
|
||||
plugins = {
|
||||
lsp = {
|
||||
enable = true;
|
||||
servers.clangd.enable = true;
|
||||
};
|
||||
nvim-cmp.enable = true;
|
||||
lspkind.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
highlight = build {
|
||||
options.termguicolors = true;
|
||||
highlight = {
|
||||
Normal.fg = "#ff0000";
|
||||
};
|
||||
};
|
||||
|
||||
autoCmd = build {
|
||||
autoCmd = [
|
||||
{
|
||||
event = ["BufEnter" "BufWinEnter"];
|
||||
pattern = ["*.c" "*.h"];
|
||||
command = "echo 'Entering a C or C++ file'";
|
||||
}
|
||||
{
|
||||
event = "InsertEnter";
|
||||
command = "norm zz";
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
ts-custom = build {
|
||||
plugins.treesitter = {
|
||||
enable = true;
|
||||
nixGrammars = true;
|
||||
grammarPackages = [
|
||||
(build-ts.lib.buildGrammar pkgs {
|
||||
language = "gleam";
|
||||
version = "0.25.0";
|
||||
source = gleam;
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}))
|
||||
// {
|
||||
nixosConfigurations.nixvim-machine = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
({pkgs, ...}: {
|
||||
environment.systemPackages = [
|
||||
(nixvim.build pkgs {colorschemes.gruvbox.enable = true;})
|
||||
];
|
||||
})
|
||||
];
|
||||
};
|
||||
nixosConfigurations.container = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
({pkgs, ...}: {
|
||||
boot.isContainer = true;
|
||||
|
||||
# Let 'nixos-version --json' know about the Git revision
|
||||
# of this flake.
|
||||
system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;
|
||||
|
||||
imports = [
|
||||
nixvim.nixosModules.x86_64-linux.nixvim
|
||||
];
|
||||
|
||||
programs.nixvim = {
|
||||
enable = true;
|
||||
colorschemes.gruvbox.enable = true;
|
||||
};
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
{lib}: let
|
||||
# List of files containing configurations
|
||||
pluginFiles =
|
||||
builtins.filter (p: p != "default.nix") (builtins.attrNames (builtins.readDir ./.));
|
||||
|
||||
/*
|
||||
Create a list of tests. The list is of the form:
|
||||
[ { name = "<plugin>-<test_name>"; value = { ... }; } ]
|
||||
*/
|
||||
makePluginTests = pluginFile: let
|
||||
pluginName = builtins.head (lib.strings.splitString "." pluginFile);
|
||||
pluginConfigs = import (./. + "/${pluginFile}");
|
||||
in
|
||||
lib.attrsets.mapAttrsToList (testName: testConfig: {
|
||||
name = "${pluginName}-${testName}";
|
||||
value = testConfig;
|
||||
})
|
||||
pluginConfigs;
|
||||
|
||||
# A list of lists of test cases for each plugin
|
||||
pluginTests = builtins.map makePluginTests pluginFiles;
|
||||
in
|
||||
builtins.listToAttrs (lib.lists.flatten pluginTests)
|
|
@ -1,39 +0,0 @@
|
|||
{
|
||||
empty = {
|
||||
plugins.lsp.enable = true;
|
||||
};
|
||||
|
||||
test = {
|
||||
plugins.lsp = {
|
||||
enable = true;
|
||||
|
||||
keymaps = {
|
||||
silent = true;
|
||||
diagnostic = {
|
||||
"<leader>k" = "goto_prev";
|
||||
"<leader>j" = "goto_next";
|
||||
};
|
||||
|
||||
lspBuf = {
|
||||
"gd" = "definition";
|
||||
"gD" = "references";
|
||||
"gt" = "type_definition";
|
||||
"gi" = "implementation";
|
||||
"K" = "hover";
|
||||
};
|
||||
};
|
||||
|
||||
servers = {
|
||||
bashls.enable = true;
|
||||
clangd.enable = true;
|
||||
nil_ls.enable = true;
|
||||
rust-analyzer.enable = true;
|
||||
pylsp = {
|
||||
enable = true;
|
||||
filetypes = ["python"];
|
||||
autostart = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,5 +1,10 @@
|
|||
{pkgs, ...}: {
|
||||
checkNvim = {
|
||||
{
|
||||
pkgs,
|
||||
makeNixvim,
|
||||
}: let
|
||||
# Create a nix derivation from a nixvim executable.
|
||||
# The build phase simply consists in running the provided nvim binary.
|
||||
mkTestDerivationFromNvim = {
|
||||
name,
|
||||
nvim,
|
||||
dontRun,
|
||||
|
@ -32,4 +37,21 @@
|
|||
mkdir $out
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
||||
# Create a nix derivation from a nixvim configuration.
|
||||
# The build phase simply consists in running neovim with the given configuration.
|
||||
mkTestDerivation = name: config: let
|
||||
testAttributes =
|
||||
if builtins.hasAttr "tests" config
|
||||
then config.tests
|
||||
else {
|
||||
dontRun = false;
|
||||
};
|
||||
nvim = makeNixvim (pkgs.lib.attrsets.filterAttrs (n: _: n != "tests") config);
|
||||
in
|
||||
mkTestDerivationFromNvim {
|
||||
inherit name nvim;
|
||||
inherit (testAttributes) dontRun;
|
||||
};
|
||||
in
|
||||
mkTestDerivation
|
143
tests/test-sources/example-configurations/issues.nix
Normal file
143
tests/test-sources/example-configurations/issues.nix
Normal file
|
@ -0,0 +1,143 @@
|
|||
{pkgs}: {
|
||||
"40" = {
|
||||
plugins = {
|
||||
nix.enable = true;
|
||||
nvim-autopairs.enable = true;
|
||||
|
||||
lualine = {
|
||||
enable = true;
|
||||
|
||||
sectionSeparators = {
|
||||
left = "";
|
||||
right = "";
|
||||
};
|
||||
|
||||
componentSeparators = {
|
||||
left = "";
|
||||
right = "";
|
||||
};
|
||||
|
||||
theme = "auto";
|
||||
};
|
||||
|
||||
goyo = {
|
||||
enable = true;
|
||||
showLineNumbers = false;
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = true;
|
||||
servers = {
|
||||
rust-analyzer.enable = true;
|
||||
rnix-lsp.enable = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
options = {
|
||||
# Indentation
|
||||
autoindent = true;
|
||||
tabstop = 4;
|
||||
shiftwidth = 4;
|
||||
expandtab = true;
|
||||
backspace = "indent,eol,start";
|
||||
|
||||
# Text
|
||||
showmatch = true;
|
||||
mouse = "a";
|
||||
number = true;
|
||||
relativenumber = false;
|
||||
ttyfast = true;
|
||||
clipboard = "unnamedplus";
|
||||
|
||||
# Colors
|
||||
background = "dark";
|
||||
termguicolors = true;
|
||||
};
|
||||
};
|
||||
|
||||
"65" = {
|
||||
colorschemes.gruvbox = {
|
||||
enable = true;
|
||||
contrastLight = "hard";
|
||||
contrastDark = "hard";
|
||||
};
|
||||
|
||||
options = {
|
||||
number = true;
|
||||
shiftwidth = 2;
|
||||
tabstop = 2;
|
||||
guifont = "FiraCode\ Nerd\ Font\ Mono:h14";
|
||||
};
|
||||
|
||||
plugins = {
|
||||
lsp = {
|
||||
enable = true;
|
||||
servers.rnix-lsp.enable = true;
|
||||
servers.rust-analyzer.enable = true;
|
||||
servers.jsonls.enable = true;
|
||||
};
|
||||
|
||||
nvim-tree = {
|
||||
enable = true;
|
||||
openOnSetup = true;
|
||||
openOnTab = true;
|
||||
};
|
||||
|
||||
telescope = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
nvim-cmp = {
|
||||
formatting = {
|
||||
format = ''
|
||||
require("lspkind").cmp_format({
|
||||
mode="symbol",
|
||||
maxwidth = 50,
|
||||
ellipsis_char = "..."
|
||||
})
|
||||
'';
|
||||
};
|
||||
|
||||
autoEnableSources = true;
|
||||
snippet = {
|
||||
expand.__raw = ''
|
||||
function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
end
|
||||
'';
|
||||
};
|
||||
enable = true;
|
||||
sources = [
|
||||
{name = "nvim_lsp";}
|
||||
{
|
||||
name = "luasnip";
|
||||
option = {
|
||||
show_autosnippets = true;
|
||||
};
|
||||
}
|
||||
{name = "path";}
|
||||
{name = "buffer";}
|
||||
];
|
||||
};
|
||||
barbar.enable = true;
|
||||
};
|
||||
|
||||
globals.mapleader = " ";
|
||||
extraPlugins = with pkgs.vimPlugins; [
|
||||
which-key-nvim
|
||||
# leap-nvim
|
||||
vim-flutter
|
||||
plenary-nvim
|
||||
fidget-nvim
|
||||
luasnip
|
||||
lspkind-nvim
|
||||
];
|
||||
|
||||
# extraConfigLua = (builtins.readFile ./nvim-extra-lua.lua);
|
||||
};
|
||||
|
||||
"71" = {
|
||||
maps.normal."<leader>hb" = "<cmd>lua require('gitsigns').blame_line{full=true}<cr>";
|
||||
};
|
||||
}
|
12
tests/test-sources/examples.nix
Normal file
12
tests/test-sources/examples.nix
Normal file
|
@ -0,0 +1,12 @@
|
|||
{pkgs}: {
|
||||
plain = {};
|
||||
|
||||
simple-plugin = {
|
||||
extraPlugins = [pkgs.vimPlugins.vim-surround];
|
||||
};
|
||||
|
||||
gruvbox-raw-method = {
|
||||
extraPlugins = [pkgs.vimPlugins.gruvbox];
|
||||
colorscheme = "gruvbox";
|
||||
};
|
||||
}
|
15
tests/test-sources/modules/autocmd.nix
Normal file
15
tests/test-sources/modules/autocmd.nix
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
example = {
|
||||
autoCmd = [
|
||||
{
|
||||
event = ["BufEnter" "BufWinEnter"];
|
||||
pattern = ["*.c" "*.h"];
|
||||
callback = {__raw = "function() print('This buffer enters') end";};
|
||||
}
|
||||
{
|
||||
event = "InsertEnter";
|
||||
command = "norm zz";
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
8
tests/test-sources/modules/highlight.nix
Normal file
8
tests/test-sources/modules/highlight.nix
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
example = {
|
||||
options.termguicolors = true;
|
||||
highlight = {
|
||||
Normal.fg = "#ff0000";
|
||||
};
|
||||
};
|
||||
}
|
5
tests/test-sources/modules/keymaps.nix
Normal file
5
tests/test-sources/modules/keymaps.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
example = {
|
||||
maps.normal."," = "<cmd>echo \"test\"<cr>";
|
||||
};
|
||||
}
|
5
tests/test-sources/plugins/colorschemes/gruvbox.nix
Normal file
5
tests/test-sources/plugins/colorschemes/gruvbox.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
empty = {
|
||||
colorschemes.gruvbox.enable = true;
|
||||
};
|
||||
}
|
|
@ -1,4 +1,9 @@
|
|||
{
|
||||
# Empty configuration
|
||||
empty = {
|
||||
colorschemes.tokyonight.enable = true;
|
||||
};
|
||||
|
||||
# All the upstream default options of tokyonight
|
||||
defaults = {
|
||||
colorschemes.tokyonight = {
|
|
@ -4,6 +4,17 @@
|
|||
plugins.lspkind.enable = true;
|
||||
};
|
||||
|
||||
example = {
|
||||
plugins = {
|
||||
lsp = {
|
||||
enable = true;
|
||||
servers.clangd.enable = true;
|
||||
};
|
||||
nvim-cmp.enable = true;
|
||||
lspkind.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
# All the upstream default options of lspkind
|
||||
defaults = {
|
||||
plugins.lspkind = {
|
29
tests/test-sources/plugins/languages/treesitter.nix
Normal file
29
tests/test-sources/plugins/languages/treesitter.nix
Normal file
|
@ -0,0 +1,29 @@
|
|||
{pkgs}: {
|
||||
empty = {
|
||||
plugins.treesitter.enable = true;
|
||||
};
|
||||
|
||||
nonix = {
|
||||
# TODO: See if we can build parsers (legacy way)
|
||||
tests.dontRun = true;
|
||||
plugins.treesitter = {
|
||||
enable = true;
|
||||
nixGrammars = false;
|
||||
};
|
||||
};
|
||||
|
||||
# This needs a custom input
|
||||
# custom = {
|
||||
# plugins.treesitter = {
|
||||
# enable = true;
|
||||
# nixGrammars = true;
|
||||
# grammarPackages = [
|
||||
# (build-ts.lib.buildGrammar pkgs {
|
||||
# language = "gleam";
|
||||
# version = "0.25.0";
|
||||
# source = gleam;
|
||||
# })
|
||||
# ];
|
||||
# };
|
||||
# };
|
||||
}
|
|
@ -4,6 +4,16 @@
|
|||
plugins.null-ls.enable = true;
|
||||
};
|
||||
|
||||
# Broken:
|
||||
# error: The option `plugins.null-ls.sources.formatting.beautysh' does not exist.
|
||||
#
|
||||
# beautysh = {
|
||||
# plugins.null-ls = {
|
||||
# enable = true;
|
||||
# sources.formatting.beautysh.enable = true;
|
||||
# };
|
||||
# };
|
||||
|
||||
default = {
|
||||
plugins.null-ls = {
|
||||
enable = true;
|
5
tests/test-sources/plugins/nvim-lsp/lsp-lines.nix
Normal file
5
tests/test-sources/plugins/nvim-lsp/lsp-lines.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
empty = {
|
||||
plugins.lsp-lines.enable = true;
|
||||
};
|
||||
}
|
71
tests/test-sources/plugins/nvim-lsp/nvim-lsp.nix
Normal file
71
tests/test-sources/plugins/nvim-lsp/nvim-lsp.nix
Normal file
|
@ -0,0 +1,71 @@
|
|||
{
|
||||
empty = {
|
||||
plugins.lsp.enable = true;
|
||||
};
|
||||
|
||||
example = {
|
||||
plugins.lsp = {
|
||||
enable = true;
|
||||
|
||||
keymaps = {
|
||||
silent = true;
|
||||
diagnostic = {
|
||||
"<leader>k" = "goto_prev";
|
||||
"<leader>j" = "goto_next";
|
||||
};
|
||||
|
||||
lspBuf = {
|
||||
"gd" = "definition";
|
||||
"gD" = "references";
|
||||
"gt" = "type_definition";
|
||||
"gi" = "implementation";
|
||||
"K" = "hover";
|
||||
};
|
||||
};
|
||||
|
||||
servers = {
|
||||
bashls.enable = true;
|
||||
clangd.enable = true;
|
||||
nil_ls.enable = true;
|
||||
rust-analyzer.enable = true;
|
||||
pylsp = {
|
||||
enable = true;
|
||||
filetypes = ["python"];
|
||||
autostart = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
all-servers = {
|
||||
plugins.lsp = {
|
||||
enable = true;
|
||||
|
||||
servers = {
|
||||
astro.enable = true;
|
||||
bashls.enable = true;
|
||||
clangd.enable = true;
|
||||
cssls.enable = true;
|
||||
dartls.enable = true;
|
||||
denols.enable = true;
|
||||
eslint.enable = true;
|
||||
elixirls.enable = true;
|
||||
gopls.enable = true;
|
||||
hls.enable = true;
|
||||
html.enable = true;
|
||||
jsonls.enable = true;
|
||||
lua-ls.enable = true;
|
||||
nil_ls.enable = true;
|
||||
pylsp.enable = true;
|
||||
pyright.enable = true;
|
||||
rnix-lsp.enable = true;
|
||||
rust-analyzer.enable = true;
|
||||
tailwindcss.enable = true;
|
||||
texlab.enable = true;
|
||||
tsserver.enable = true;
|
||||
vuels.enable = true;
|
||||
# zls.enable = true; Broken as of 03/17/2023
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -4,6 +4,15 @@
|
|||
plugins.trouble.enable = true;
|
||||
};
|
||||
|
||||
lsp = {
|
||||
plugins.lsp = {
|
||||
enable = true;
|
||||
servers.clangd.enable = true;
|
||||
};
|
||||
|
||||
plugins.trouble.enable = true;
|
||||
};
|
||||
|
||||
# All the upstream default options of trouble
|
||||
defaults = {
|
||||
plugins.trouble = {
|
46
tests/test-sources/plugins/utils/sniprun.nix
Normal file
46
tests/test-sources/plugins/utils/sniprun.nix
Normal file
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
empty = {
|
||||
plugins.sniprun.enable = true;
|
||||
};
|
||||
|
||||
default = {
|
||||
plugins.sniprun = {
|
||||
enable = true;
|
||||
selectedInterpreters = [];
|
||||
replEnable = [];
|
||||
replDisable = [];
|
||||
interpreterOptions = {};
|
||||
display = ["Classic" "VirtualTextOk"];
|
||||
liveDisplay = ["VirtualTextOk"];
|
||||
displayOptions = {
|
||||
terminalWidth = 45;
|
||||
notificationTimeout = 5;
|
||||
};
|
||||
showNoOutput = ["Classic" "TempFloatingWindow"];
|
||||
snipruncolors = {
|
||||
SniprunVirtualTextOk = {
|
||||
bg = "#66eeff";
|
||||
fg = "#000000";
|
||||
ctermbg = "Cyan";
|
||||
ctermfg = "Black";
|
||||
};
|
||||
SniprunFloatingWinOk = {
|
||||
fg = "#66eeff";
|
||||
ctermfg = "Cyan";
|
||||
};
|
||||
SniprunVirtualTextErr = {
|
||||
bg = "#881515";
|
||||
fg = "#000000";
|
||||
ctermbg = "DarkRed";
|
||||
ctermfg = "Black";
|
||||
};
|
||||
SniprunFloatingWinErr = {
|
||||
fg = "#881515";
|
||||
ctermfg = "DarkRed";
|
||||
};
|
||||
};
|
||||
liveModeToggle = "off";
|
||||
borders = "single";
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue