Skip to content

Commit

Permalink
feat(queries): add basic yaml support
Browse files Browse the repository at this point in the history
  • Loading branch information
barklan committed Jun 4, 2022
1 parent ece90c4 commit c29e53a
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lua/aerial/backends/treesitter/language_kind_map.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,8 @@ return {
vim = {
function_definition = "Function",
},
yaml = {
block_mapping = "Class",
block_sequence = "Enum",
},
}
7 changes: 7 additions & 0 deletions queries/yaml/aerial.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(block_mapping_pair
key: (flow_node) @name
value: (block_node (block_mapping) @type)) @start

(block_mapping_pair
key: (flow_node) @name
value: (block_node (block_sequence) @type)) @start
77 changes: 77 additions & 0 deletions tests/treesitter/yaml_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
local util = require("tests.test_util")

describe("treesitter yaml", function()
it("parses all symbols correctly", function()
util.test_file_symbols("treesitter", "./tests/treesitter/yaml_test.yml", {
{
kind = "Class",
name = "services",
level = 0,
lnum = 3,
col = 0,
end_lnum = 10,
end_col = 24,
children = {
{
kind = "Class",
name = "proxy",
level = 1,
lnum = 4,
col = 2,
end_lnum = 7,
end_col = 15,
children = {
{
kind = "Enum",
name = "ports",
level = 2,
lnum = 6,
col = 4,
end_lnum = 7,
end_col = 15,
},
},
},
{
kind = "Class",
name = "db",
level = 1,
lnum = 9,
col = 2,
end_lnum = 10,
end_col = 24,
},
},
},
{
kind = "Class",
name = "volumes",
level = 0,
lnum = 12,
col = 0,
end_lnum = 14,
end_col = 18,
children = {
{
kind = "Class",
name = "media-volume",
level = 1,
lnum = 13,
col = 2,
end_lnum = 14,
end_col = 18,
},
},
},
{
kind = "Class",
name = "networks",
level = 0,
lnum = 16,
col = 0,
end_lnum = 18,
end_col = 0,
},
})
end)
end)
17 changes: 17 additions & 0 deletions tests/treesitter/yaml_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: "4.7"

services:
proxy:
image: "traefik:v2.5.3"
ports:
- "80:80"

db:
image: "postgres:14"

volumes:
media-volume:
external: true

networks:
traefik-public: null

0 comments on commit c29e53a

Please sign in to comment.