Compare commits

..

18 commits

Author SHA1 Message Date
Bruno BELANYI 2326d709fb Release 0.4.0
All checks were successful
ci/woodpecker/push/check Pipeline was successful
ci/woodpecker/tag/check Pipeline was successful
2024-05-13 15:46:07 +00:00
Bruno BELANYI bf783d99bc Handle 'pyproject.toml' in 'bump-version' 2024-05-13 15:45:45 +00:00
Bruno BELANYI c5031e2c16 Add indentation queries for multi-value 'select'
Unfortunately, the indentation feature is still a work in progress, so
we have some expected failures in our tests...
2024-05-13 15:44:18 +00:00
Bruno BELANYI f228904ed0 Fix 'nvim-test-runner' reproducibility
For some reason, it looks like my personal configuration is interfering
with the tests despite `--noplug -u minimal_init.lua`...

Rather than investigate what _exactly_ is going on, let's merge this
work-around for now.
2024-05-13 15:44:18 +00:00
Bruno BELANYI 5cbdf5e3ac Test more 'select' related indentation cases 2024-05-13 15:44:18 +00:00
Bruno BELANYI 533c82cdf3 Add queries to Rust bindings 2024-05-13 15:44:18 +00:00
Bruno BELANYI d25b07cae0 Add queries to 'package.json' 2024-05-13 15:44:18 +00:00
Bruno BELANYI ff40b39dcf Expose 'condition' node 2024-05-13 15:44:18 +00:00
Bruno BELANYI d01bcf0f6d Add multi-valued select expression 2024-05-13 15:44:18 +00:00
Bruno BELANYI 0816633d9a Name 'commaSeparated*' helpers consistently 2024-05-13 15:44:18 +00:00
Bruno BELANYI 6ca4592d84 Remove trailing commas in 'select_value' arguments 2024-05-13 15:44:18 +00:00
Bruno BELANYI afdfbff7bc Add boolean-typed select values 2024-05-13 15:44:18 +00:00
Bruno BELANYI f6bc0f887a Remove 'selection_type' alias 2024-05-13 15:44:18 +00:00
Bruno BELANYI 2649422636 Rename fields in 'select_value'
This aligns with upstream, and makes more sense given their usage.
2024-05-13 15:44:18 +00:00
Bruno BELANYI 1c1387fee0 Simplify 'select_value' rule
Upstream has greatly simplified the parsing of `select` expressions, in
order to add multi-valued `select`.

To this end, we remove the hard-coded list of function names, and accept
an arbitrary number of arguments.
2024-05-13 15:44:17 +00:00
Bruno BELANYI 8137fd3e5b Relax ordering in 'select' cases
We shouldn't really care whether or not `default` *is* the last value...
2024-05-13 15:44:17 +00:00
Bruno BELANYI 9e46303a1d Add more generated files attributes 2024-05-13 15:44:17 +00:00
Bruno BELANYI 1af33aeea1 Bump flake inputs
This means regenerating all the tree-sitter files, and adding newly
generated outputs (mostly new bindings).

The `--apply-all-captures` flag has been removed, it is now the default
(and only) matching behaviour.
2024-05-13 15:44:17 +00:00
7 changed files with 61 additions and 5 deletions

View file

@ -1,7 +1,7 @@
[package] [package]
name = "tree-sitter-bp" name = "tree-sitter-bp"
description = "Blueprint grammar for the tree-sitter parsing library" description = "Blueprint grammar for the tree-sitter parsing library"
version = "0.3.0" version = "0.4.0"
keywords = ["incremental", "parsing", "android", "blueprint"] keywords = ["incremental", "parsing", "android", "blueprint"]
categories = ["parsing", "text-editors"] categories = ["parsing", "text-editors"]
repository = "https://git.belanyi.fr/ambroisie/tree-sitter-bp" repository = "https://git.belanyi.fr/ambroisie/tree-sitter-bp"

View file

@ -61,6 +61,10 @@
export NVIM_TREESITTER_TEXTOBJECTS='${pkgs.vimPlugins.nvim-treesitter-textobjects}' export NVIM_TREESITTER_TEXTOBJECTS='${pkgs.vimPlugins.nvim-treesitter-textobjects}'
export NVIM_TREESITTER_PARSER='${pkgs.vimPlugins.nvim-treesitter.grammarToPlugin self.packages.${system}.tree-sitter-bp}' export NVIM_TREESITTER_PARSER='${pkgs.vimPlugins.nvim-treesitter.grammarToPlugin self.packages.${system}.tree-sitter-bp}'
# FIXME: not sure why, but I get different behaviour when left untouched
XDG_CONFIG_HOME=$(mktemp -d)
export XDG_CONFIG_HOME
nvim --headless --noplugin -u ${scripts/minimal_init.lua} \ nvim --headless --noplugin -u ${scripts/minimal_init.lua} \
-c "PlenaryBustedDirectory test/ { minimal_init = '${./scripts/minimal_init.lua}' }" -c "PlenaryBustedDirectory test/ { minimal_init = '${./scripts/minimal_init.lua}' }"
''; '';
@ -74,8 +78,9 @@
${pkgs.jq}/bin/jq ".version = \"''${NEW_VERSION}\"" package.json > package.json.tmp ${pkgs.jq}/bin/jq ".version = \"''${NEW_VERSION}\"" package.json > package.json.tmp
mv package.json.tmp package.json mv package.json.tmp package.json
${pkgs.gnused}/bin/sed -i -e "s/version = \"[0-9.]\\+\"/version = \"''${NEW_VERSION}\"/" Cargo.toml ${pkgs.gnused}/bin/sed -i -e "s/version = \"[0-9.]\\+\"/version = \"''${NEW_VERSION}\"/" Cargo.toml
${pkgs.gnused}/bin/sed -i -e "s/version = \"[0-9.]\\+\"/version = \"''${NEW_VERSION}\"/" pyproject.toml
git add Cargo.toml package.json git add Cargo.toml package.json pyproject.toml
echo "Release ''${NEW_VERSION}" | git commit -eF - echo "Release ''${NEW_VERSION}" | git commit -eF -
git tag -a "v''${NEW_VERSION}" -m "Release ''${NEW_VERSION}" git tag -a "v''${NEW_VERSION}" -m "Release ''${NEW_VERSION}"
''; '';

View file

@ -1,6 +1,6 @@
{ {
"name": "tree-sitter-bp", "name": "tree-sitter-bp",
"version": "0.3.0", "version": "0.4.0",
"description": "Blueprint grammar for tree-sitter", "description": "Blueprint grammar for tree-sitter",
"main": "bindings/node", "main": "bindings/node",
"types": "bindings/node", "types": "bindings/node",

View file

@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "tree-sitter-bp" name = "tree-sitter-bp"
description = "Bp grammar for tree-sitter" description = "Bp grammar for tree-sitter"
version = "0.0.1" version = "0.4.0"
keywords = ["incremental", "parsing", "tree-sitter", "bp"] keywords = ["incremental", "parsing", "tree-sitter", "bp"]
classifiers = [ classifiers = [
"Intended Audience :: Developers", "Intended Audience :: Developers",

View file

@ -11,6 +11,15 @@
(select_expression (select_expression
")" @indent.branch) ")" @indent.branch)
(select_value) @indent.begin
(select_value
")" @indent.branch)
(select_pattern
"(" @indent.begin)
(select_pattern
")" @indent.branch)
(select_cases) @indent.begin (select_cases) @indent.begin
(select_cases (select_cases
"}" @indent.branch) "}" @indent.branch)

View file

@ -26,3 +26,35 @@ foo = select(
default: 0, default: 0,
} }
) )
foo = select((
arch(),
os(),
), {
(default, default): [],
})
foo = select(
(arch(), os()),
{
(default, default): [],
}
)
// We're really getting into more and more unlikely choices here...
foo = select(
(
arch(),
os(),
),
{
(default, default): [],
}
)
foo = select((arch(), os()), {
(
default,
default,
): [],
})

View file

@ -1,6 +1,7 @@
package.path = package.path .. ";" .. vim.env.NVIM_TREESITTER .. "/?.lua" package.path = package.path .. ";" .. vim.env.NVIM_TREESITTER .. "/?.lua"
local Runner = require("tests.indent.common").Runner local Runner = require("tests.indent.common").Runner
local XFAIL = require("tests.indent.common").XFAIL
-- FIXME: path to root -- FIXME: path to root
local runner = Runner:new(it, ".", { local runner = Runner:new(it, ".", {
@ -19,7 +20,7 @@ describe("indent Blueprint:", function()
}) })
runner:whole_file("test/indent/", { runner:whole_file("test/indent/", {
expected_failures = { expected_failures = {
-- NOTE: none for now "test/indent/select.bp",
}, },
}) })
end) end)
@ -47,5 +48,14 @@ describe("indent Blueprint:", function()
runner:new_line("test/indent/select.bp", { on_line = 26, text = 'default: "value"', indent = 8 }, "default case, trailing, alternate formatting") runner:new_line("test/indent/select.bp", { on_line = 26, text = 'default: "value"', indent = 8 }, "default case, trailing, alternate formatting")
runner:new_line("test/indent/select.bp", { on_line = 26, text = '}', indent = 4 }, "select cases closing delimiter, alternate formatting") runner:new_line("test/indent/select.bp", { on_line = 26, text = '}', indent = 4 }, "select cases closing delimiter, alternate formatting")
runner:new_line("test/indent/select.bp", { on_line = 27, text = ')', indent = 0 }, "select expression closing delimiter, alternate formatting") runner:new_line("test/indent/select.bp", { on_line = 27, text = ')', indent = 0 }, "select expression closing delimiter, alternate formatting")
runner:new_line("test/indent/select.bp", { on_line = 30, text = 'device()', indent = 4 }, "multi-valued select condition, begin")
runner:new_line("test/indent/select.bp", { on_line = 31, text = 'device()', indent = 4 }, "multi-valued select condition, middle")
runner:new_line("test/indent/select.bp", { on_line = 32, text = 'device()', indent = 4 }, "multi-valued select condition, end")
runner:new_line("test/indent/select.bp", { on_line = 46, text = 'device()', indent = 8 }, "multi-valued select condition, begin, alternate formatting")
runner:new_line("test/indent/select.bp", { on_line = 47, text = 'device()', indent = 8 }, "multi-valued select condition, middle, alternate formatting")
runner:new_line("test/indent/select.bp", { on_line = 48, text = 'device()', indent = 8 }, "multi-valued select condition, end, alternate formatting")
runner:new_line("test/indent/select.bp", { on_line = 56, text = 'default,', indent = 8 }, "multi-valued select case, begin", XFAIL)
runner:new_line("test/indent/select.bp", { on_line = 57, text = 'default,', indent = 8 }, "multi-valued select case, middle", XFAIL)
runner:new_line("test/indent/select.bp", { on_line = 58, text = 'default,', indent = 8 }, "multi-valued select case, end", XFAIL)
end) end)
end) end)