diff --git a/.luarc.json b/.luarc.json index 23646d3..676c096 100644 --- a/.luarc.json +++ b/.luarc.json @@ -2,7 +2,8 @@ "runtime.version": "LuaJIT", "runtime.path": ["lua/?.lua", "lua/?/init.lua"], "diagnostics.globals": ["vim", "jit"], - "workspace.library": ["$VIMRUNTIME/lua", "${3rd}/luv/library"], + "workspace.library": ["$VIMRUNTIME/lua", "${3rd}/luv/library", "${3rd}/busted/library"], "workspace.checkThirdParty": false, + "workspace.ignoreDir": [".direnv"], "completion.callSnippet": "Replace" } diff --git a/flake.nix b/flake.nix index 0c5f5d8..38e98cd 100644 --- a/flake.nix +++ b/flake.nix @@ -16,15 +16,26 @@ forEachSystem = f: nixpkgs.lib.genAttrs (import systems) (system: f nixpkgs.legacyPackages.${system}); in { + formatter = forEachSystem (pkgs: pkgs.nixfmt-tree); + devShells = forEachSystem (pkgs: { - default = pkgs.mkShell { + default = + let + ts-plugin = pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [ p.diff ]); + diff-grammar = pkgs.vimPlugins.nvim-treesitter-parsers.diff; + luaEnv = pkgs.luajit.withPackages (ps: with ps; [ busted nlua ]); + busted-with-grammar = pkgs.writeShellScriptBin "busted" '' + nvim_bin=$(which nvim) + tmpdir=$(mktemp -d) + trap 'rm -rf "$tmpdir"' EXIT + printf '#!/bin/sh\nexec "%s" --cmd "set rtp+=${ts-plugin}/runtime" --cmd "set rtp+=${diff-grammar}" "$@"\n' "$nvim_bin" > "$tmpdir/nvim" + chmod +x "$tmpdir/nvim" + PATH="$tmpdir:$PATH" exec ${luaEnv}/bin/busted "$@" + ''; + in + pkgs.mkShell { packages = [ - (pkgs.luajit.withPackages ( - ps: with ps; [ - busted - nlua - ] - )) + busted-with-grammar pkgs.prettier pkgs.stylua pkgs.selene diff --git a/scripts/ci.sh b/scripts/ci.sh new file mode 100755 index 0000000..e06bf09 --- /dev/null +++ b/scripts/ci.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -eu + +nix develop --command stylua --check . +git ls-files '*.lua' | xargs nix develop --command selene --display-style quiet +nix develop --command prettier --check . +nix fmt +git diff --exit-code -- '*.nix' +nix develop --command lua-language-server --check . --checklevel=Warning +nix develop --command busted