Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore!(queries): adjust queries for tree-sitter-haskell rewrite #162

Merged
merged 1 commit into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,17 @@ jobs:
env:
LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }}
with:
# TODOL Add tree-sitter-haskell when there exists a stable version
dependencies: |
neotest
tree-sitter-haskell
detailed_description: |
* Supports Cabal projects.
* Supports Stack projects.
* Parses Sydtest, Hspec and Tasty filters for the cursor's position using TreeSitter.
* Parses test results and displays error messages as virtual text.
test_interpreters: ""
- name: GitHub Release
if: startsWith(github.ref, 'refs/tags/')
uses: ncipollo/release-action@v1
with:
bodyFile: "CHANGELOG.md"
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.0] - 2024-05-12
### BREAKING CHANGES
- Updated queries to work with tree-sitter-haskell v0.21.0 rewrite.
- If you are using nvim-treesitter to manage parser installations, run `:TSUpdate`
to ensure you have the latest tree-sitter-haskell version.
- If you are using Nix with an older version of the parser,
you can either package tree-sitter-haskell,
or pin an older version of this plugin.

## [1.2.1] - 2024-04-06
### Fixed
- Typo in tasty module.
Expand Down
4 changes: 2 additions & 2 deletions lua/neotest-haskell/runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ local function mk_module_query(modules)
for i, module_name in ipairs(modules) do
local filter = ([[
;;query
(module) @mod%d
(module_id) @mod%d
(#eq? @mod%d "%s")
]]):format(i, i, module_name)
table.insert(filters, filter)
end
return [[
;;query
(qualified_module
(module
]] .. table.concat(filters, '\n') .. [[
;;query
)
Expand Down
57 changes: 56 additions & 1 deletion nix/ci-overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,55 @@
disabled = luaOlder "5.1";
propagatedBuildInputs = [lua nvim-nio plenary-nvim];
}) {};

luarocks-build-treesitter-parser = luaself.callPackage ({
buildLuarocksPackage,
luaOlder,
luafilesystem,
fetchurl,
fetchzip,
lua,
...
}:
buildLuarocksPackage {
pname = "luarocks-build-treesitter-parser";
version = "2.0.0-1";
knownRockspec =
(fetchurl {
url = "mirror://luarocks/luarocks-build-treesitter-parser-2.0.0-1.rockspec";
sha256 = "0ylax1r0yl5k742p8n0fq5irs2r632npigqp1qckfx7kwi89gxhb";
})
.outPath;
src = fetchzip {
url = "https://github.com/nvim-neorocks/luarocks-build-treesitter-parser/archive/v2.0.0.zip";
sha256 = "0gqiwk7dk1xn5n2m0iq5c7xkrgyaxwyd1spb573l289gprvlrbn5";
};

disabled = luaOlder "5.1";
propagatedBuildInputs = [lua luafilesystem];
}) {};

tree-sitter-haskell = luaself.callPackage (
{
buildLuarocksPackage,
fetchurl,
fetchzip,
luarocks-build-treesitter-parser,
...
}:
buildLuarocksPackage {
pname = "tree-sitter-haskell";
version = "scm-1";
knownRockspec = self + "/spec/fixtures/tree-sitter-haskell-scm-1.rockspec";
src = fetchzip {
url = "https://github.com/tree-sitter/tree-sitter-haskell/archive/e29c59236283198d93740a796c50d1394bccbef5.zip";
sha256 = "03mk4jvlg2l33xfd8p2xk1q0xcansij2sfa98bdnhsh8ac1jm30h";
};
propagatedBuildInputs = [
luarocks-build-treesitter-parser
];
}
) {};
};

lua5_1 = prev.lua5_1.override {
Expand All @@ -63,6 +112,12 @@

lua51Packages = prev.lua51Packages // final.lua5_1.pkgs;

tree-sitter-haskell-plugin = final.neovimUtils.buildNeovimPlugin {
pname = "tree-sitter-haskell";
version = "scm";
src = final.lua51Packages.tree-sitter-haskell.src;
};

mkNeorocksTest = {
name,
nvim ? final.neovim-unwrapped,
Expand All @@ -73,7 +128,7 @@
start = with final.vimPlugins; [
final.neotest-haskell-dev # Queries need to be on the rtp
plenary-nvim # XXX: This needs to be on the nvim rtp
(nvim-treesitter.withPlugins (p: [p.haskell])) # TODO: replace with tree-sitter-haskell
tree-sitter-haskell-plugin
];
};
};
Expand Down
94 changes: 41 additions & 53 deletions queries/haskell/hspec-positions.scm
Original file line number Diff line number Diff line change
@@ -1,55 +1,43 @@
;; describe (unqualified)
(_ (_ (exp_apply
(exp_name (variable) @func_name)
(exp_literal) @namespace.name
)
(#any-of? @func_name
"describe"
"xdescribe"
"context"
"xcontext"
)
)) @namespace.definition
;; describe
(_ (_ (expression/apply
function: [
(variable) @_func_name
(qualified id: (variable) @_func_name)
]
argument: (expression/literal) @namespace.name)
(#any-of? @_func_name
"describe"
"xdescribe"
"context"
"xcontext"
))) @namespace.definition

;; describe (qualified)
(_ (_ (exp_apply
(exp_name (qualified_variable (variable) @func_name))
(exp_literal) @namespace.name
)
(#any-of? @func_name
"describe"
"xdescribe"
"context"
"xcontext"
)
)) @namespace.definition
;; test
((expression/apply
function: [
(variable) @_func_name
(qualified id: (variable) @_func_name)
]
argument: (expression/literal) @test.name)
(#any-of? @_func_name
"it"
"xit"
"prop"
"xprop"
"specify"
"xspecify")) @test.definition

;; test (unqualified)
((exp_apply
(exp_name (variable) @func_name)
(exp_literal) @test.name
)
(#any-of? @func_name
"it"
"xit"
"prop"
"xprop"
"specify"
"xspecify"
)
) @test.definition

;; test (qualified)
((exp_apply
(exp_name (qualified_variable (variable) @func_name))
(exp_literal) @test.name
)
(#any-of? @func_name
"it"
"xit"
"prop"
"xprop"
"specify"
"xspecify"
)
) @test.definition
;; test
(_ (expression/apply
function: [
(variable) @_func_name
(qualified id: (variable) @_func_name)
]
argument: (expression/literal) @test.name)
(#any-of? @_func_name
"it"
"xit"
"prop"
"xprop"
"specify"
"xspecify")) @test.definition
61 changes: 20 additions & 41 deletions queries/haskell/sydtest-positions.scm
Original file line number Diff line number Diff line change
@@ -1,43 +1,22 @@
;; NOTE: The sydtest runner inclides all queries for hspec, too.
;; NOTE: The sydtest runner includes all queries for hspec, too.

;; test (unqualified)
((exp_apply
(exp_name (variable) @func_name)
(exp_literal) @test.name
)
(#any-of? @func_name
"itWithOuter"
"xitWithOuter"
"itWithBoth"
"xitWithBoth"
"itWithAll"
"xitWithAll"
"specifyWithOuter"
"xspecifyWithOuter"
"specifyWithBoth"
"xspecifyWithBoth"
"specifyWithAll"
"xspecifyWithAll"
)
) @test.definition

;; test (qualified)
((exp_apply
(exp_name (qualified_variable (variable) @func_name))
(exp_literal) @test.name
)
(#any-of? @func_name
"itWithOuter"
"xitWithOuter"
"itWithBoth"
"xitWithBoth"
"itWithAll"
"xitWithAll"
"specifyWithOuter"
"xspecifyWithOuter"
"specifyWithBoth"
"xspecifyWithBoth"
"specifyWithAll"
"xspecifyWithAll"
)
) @test.definition
((expression/apply
function: [
(variable) @_func_name
(qualified id: (variable) @_func_name)
]
argument: (expression/literal) @test.name)
(#any-of? @_func_name
"itWithOuter"
"xitWithOuter"
"itWithBoth"
"xitWithBoth"
"itWithAll"
"xitWithAll"
"specifyWithOuter"
"xspecifyWithOuter"
"specifyWithBoth"
"xspecifyWithBoth"
"specifyWithAll"
"xspecifyWithAll")) @test.definition
Loading
Loading