Skip to content

Commit

Permalink
ci: add type checking for neovim stable
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb committed Oct 29, 2023
1 parent 386883f commit 8b76417
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 40 deletions.
17 changes: 17 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

125 changes: 85 additions & 40 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
flake = false;
};

# inputs for tests and lints
neodev-nvim = {
url = "github:folke/neodev.nvim";
flake = false;
};

neotest = {
url = "github:nvim-neotest/neotest";
flake = false;
Expand All @@ -37,6 +43,7 @@
flake-utils,
neovim-nightly-overlay,
pre-commit-hooks,
neodev-nvim,
plenary-nvim,
neotest,
...
Expand All @@ -50,7 +57,7 @@
"x86_64-linux"
];

ci-overlay = import ./nix/ci-overlay.nix {inherit (inputs) self plenary-nvim neotest;};
ci-overlay = import ./nix/ci-overlay.nix {inherit (inputs) self neodev-nvim plenary-nvim neotest;};

nvim-plugin-overlay = import ./nix/nvim-plugin-overlay.nix {
inherit name;
Expand All @@ -67,52 +74,86 @@
];
};

mkTypeCheck = {
nvim-api ? [],
disabled-diagnostics ? [],
}:
pre-commit-hooks.lib.${system}.run {
src = self;
hooks = {
lua-ls.enable = true;
};
settings = {
lua-ls = {
config = {
runtime.version = "LuaJIT";
Lua = {
workspace = {
library =
nvim-api
++ (with pkgs; [
"${neotest-plugin}/lua"
# FIXME:
# "${pkgs.luajitPackages.busted}"
]);
checkThirdParty = false;
ignoreDir = [
".git"
".github"
".direnv"
"result"
"nix"
"doc"
"tests" # neotest's types are not well-defined
];
};
diagnostics = {
globals = [
"vim"
"describe"
"it"
"assert"
];
libraryFiles = "Disable";
disable = disabled-diagnostics;
};
};
};
};
};
};

type-check-stable = mkTypeCheck {
nvim-api = [
"${pkgs.neovim}/share/nvim/runtime/lua"
"${pkgs.neodev-plugin}/types/stable"
];
disabled-diagnostics = [
"duplicate-set-field" # neotest
"undefined-doc-name"
"redundant-parameter"
"invisible"
];
};

type-check-nightly = mkTypeCheck {
nvim-api = [
"${pkgs.neovim-nightly}/share/nvim/runtime/lua"
"${pkgs.neodev-plugin}/types/nightly"
];
disabled-diagnostics = [
"duplicate-set-field" # neotest
];
};

pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = self;
hooks = {
alejandra.enable = true;
stylua.enable = true;
lua-ls.enable = true;
editorconfig-checker.enable = true;
markdownlint.enable = true;
};
settings = {
lua-ls.config = {
Lua = {
diagnostics = {
globals = [
"vim"
"describe"
"it"
"assert"
];
libraryFiles = "Disable";
disable = [
"duplicate-set-field"
];
};
workspace = {
library = with pkgs; [
"${neovim-nightly}/share/nvim/runtime/lua"
"${plenary-plugin}/lua"
"${nvim-treesitter-plugin}/lua"
"${neotest-plugin}/lua"
];
checkThirdParty = false;
ignoreDir = [
".git"
".github"
".direnv"
"result"
"nix"
"doc"
"tests" # neotest's types are not well-defined
];
};
runtime.version = "LuaJIT";
};
};
};
};

devShell = pkgs.mkShell {
Expand Down Expand Up @@ -145,7 +186,11 @@
};

checks = {
inherit pre-commit-check;
inherit
pre-commit-check
type-check-stable
type-check-nightly
;
inherit
(pkgs)
nvim-stable-test
Expand Down
7 changes: 7 additions & 0 deletions nix/ci-overlay.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
# Add flake.nix test inputs as arguments here
{
self,
neodev-nvim,
plenary-nvim,
neotest,
}: final: prev:
with final.lib;
with final.stdenv; let
nvim-nightly = final.neovim-nightly;

neodev-plugin = final.pkgs.vimUtils.buildVimPlugin {
name = "neodev.nvim";
src = neodev-nvim;
};

plenary-plugin = final.pkgs.vimUtils.buildVimPlugin {
name = "plenary.nvim";
src = plenary-nvim;
Expand Down Expand Up @@ -79,6 +85,7 @@ in {
nvim = nvim-nightly;
};
inherit
neodev-plugin
plenary-plugin
neotest-plugin
nvim-treesitter-plugin
Expand Down

0 comments on commit 8b76417

Please sign in to comment.