feat: add support for org files

This commit is contained in:
TerseTears 2022-04-17 12:26:25 +04:30
parent 27071368e7
commit 1e698f36fa
6 changed files with 82 additions and 0 deletions

View file

@ -130,6 +130,7 @@ automatically fetch symbols from treesitter.
- julia
- lua
- markdown
- org
- php
- python
- rst

View file

@ -64,6 +64,9 @@ return {
markdown = {
atx_heading = "Interface",
},
org = {
section = "Interface",
},
php = {
anonymous_function_creation_expression = "Function",
class_declaration = "Class",

3
queries/org/aerial.scm Normal file
View file

@ -0,0 +1,3 @@
(section
(headline
item: (item) @name)) @type

View file

@ -6,6 +6,8 @@ vim.o.swapfile = false
vim.bo.swapfile = false
-- Neovim 0.5 doesn't have julia filetype detection
vim.cmd([[autocmd BufRead,BufNewFile *.jl setfiletype julia]])
-- Neovim below 0.7 doesn't have org filetype detection
vim.cmd([[autocmd BufRead,BufNewFile *.org setfiletype org]])
require("nvim-treesitter.configs").setup({
ensure_installed = "all",

View file

@ -0,0 +1,60 @@
local util = require("tests.test_util")
describe("org", function()
local symbols = {
{
kind = "Interface",
name = "Level1",
level = 0,
lnum = 1,
col = 0,
end_lnum = 7,
end_col = 0,
children = {
{
kind = "Interface",
name = "Level2",
level = 1,
lnum = 3,
col = 0,
end_lnum = 7,
end_col = 0,
children = {
{
kind = "Interface",
name = "Level3",
level = 2,
lnum = 5,
col = 0,
end_lnum = 7,
end_col = 0,
},
},
},
},
},
{
kind = "Interface",
name = "Level1_2",
level = 0,
lnum = 7,
col = 0,
end_lnum = 14,
end_col = 0,
children = {
{
kind = "Interface",
name = "Level2_2",
level = 1,
lnum = 11,
col = 0,
end_lnum = 14,
end_col = 0,
},
},
},
}
it("treesitter parses all symbols correctly", function()
util.test_file_symbols("treesitter", "./tests/treesitter/org_test.org", symbols)
end)
end)

View file

@ -0,0 +1,13 @@
* Level1
** Level2
*** Level3
* Level1_2
paragraph
** Level2_2
paragraph2