Skip to content
Draft
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
6 changes: 6 additions & 0 deletions lua/aerial/backends/treesitter/extensions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,12 @@ M.zig = {
end,
}

M.org = {
postprocess = function(bufnr, item, match)
item.name = item.name:gsub("%[%[.-]%[(.-)%]%]", "%1")
end,
}

for _, lang in pairs(M) do
setmetatable(lang, { __index = default_methods })
end
Expand Down
4 changes: 4 additions & 0 deletions queries/org/aerial.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(section
(headline
item: (item) @name)
(#set! "kind" "Interface")) @symbol
5 changes: 5 additions & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ fi
if [ ! -e "$PLUGINS/nvim-treesitter" ]; then
git clone --depth=1 --no-single-branch https://github.com/nvim-treesitter/nvim-treesitter.git "$PLUGINS/nvim-treesitter"
fi
if [ ! -e "$PLUGINS/orgmode" ]; then
# Provides the `org` treesitter grammar
git clone --depth=1 --no-single-branch https://github.com/nvim-orgmode/orgmode "$PLUGINS/orgmode"
fi

(cd "$PLUGINS/plenary.nvim" && git pull)
(cd "$PLUGINS/nvim-treesitter" && git checkout ${NVIM_TREESITTER_BRANCH} && git pull)
(cd "$PLUGINS/orgmode" && git pull)

export XDG_CONFIG_HOME=".testenv/config"
export XDG_DATA_HOME=".testenv/data"
Expand Down
13 changes: 11 additions & 2 deletions tests/minimal_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@ vim.filetype.add({
},
})

local orgmode_ok, orgmode = pcall(require, "orgmode")
if orgmode_ok then
pcall(orgmode.setup)
end

local skip_lang_install = {
help = true, -- "help" has been renamed to "vimdoc"
org = true, -- "org" is provided by a dedicated plugin.
}

local langs = {}
for lang, _ in vim.fs.dir("queries") do
-- "help" has been renamed to "vimdoc"
if lang ~= "help" then
if not skip_lang_install[lang] then
table.insert(langs, lang)
end
end
Expand Down
99 changes: 99 additions & 0 deletions tests/symbols/org_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
[
{
"children": [
{
"children": [
{
"col": 0,
"end_col": 0,
"end_lnum": 7,
"kind": "Interface",
"level": 2,
"lnum": 5,
"name": "Level3",
"selection_range": {
"col": 4,
"end_col": 10,
"end_lnum": 5,
"lnum": 5
}
}
],
"col": 0,
"end_col": 0,
"end_lnum": 7,
"kind": "Interface",
"level": 1,
"lnum": 3,
"name": "Level2 link",
"selection_range": {
"col": 3,
"end_col": 59,
"end_lnum": 3,
"lnum": 3
}
}
],
"col": 0,
"end_col": 0,
"end_lnum": 7,
"kind": "Interface",
"level": 0,
"lnum": 1,
"name": "Level1",
"selection_range": {
"col": 2,
"end_col": 8,
"end_lnum": 1,
"lnum": 1
}
},
{
"children": [
{
"col": 0,
"end_col": 0,
"end_lnum": 15,
"kind": "Interface",
"level": 1,
"lnum": 11,
"name": "Level2_2",
"selection_range": {
"col": 3,
"end_col": 11,
"end_lnum": 11,
"lnum": 11
}
}
],
"col": 0,
"end_col": 0,
"end_lnum": 15,
"kind": "Interface",
"level": 0,
"lnum": 7,
"name": "Level1_2",
"selection_range": {
"col": 2,
"end_col": 10,
"end_lnum": 7,
"lnum": 7
}
},
{
"col": 0,
"end_col": 0,
"end_lnum": 16,
"kind": "Interface",
"level": 0,
"lnum": 15,
"name": "Level1_3 link1 link2",
"selection_range": {
"col": 2,
"end_col": 112,
"end_lnum": 15,
"lnum": 15
}
}

]
15 changes: 15 additions & 0 deletions tests/treesitter/org_test.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
* Level1

** Level2 [[id:b2c99868-6014-4e81-a484-a4a7f7e62128][link]]

*** Level3

* Level1_2

paragraph

** Level2_2

paragraph2

* Level1_3 [[id:b2c99868-6014-4e81-a484-a4a7f7e62128][link1]] [[id:b2c99868-6014-4e81-a484-a4a7f7e62128][link2]]
Loading