Skip to content

Commit f19b077

Browse files
committed
feat(haskell): add treesitter support
1 parent 5c0df16 commit f19b077

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

lua/aerial/backends/treesitter/extensions.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,18 @@ M.rust = {
227227
end,
228228
}
229229

230+
M.haskell = {
231+
postprocess = function(bufnr, item, match)
232+
if item.kind == "Class" then
233+
local class_node = node_from_match(match, "class")
234+
local type = assert(node_from_match(match, "haskell_type"))
235+
local name = get_node_text(type, bufnr) or "<parse error>"
236+
local class = get_node_text(class_node, bufnr) or "<parse error>"
237+
item.name = string.format("%s %s", class, name)
238+
end
239+
end,
240+
}
241+
230242
M.ruby = {
231243
---@note Additionally processes the following captures:
232244
--- `@method`, `@receiver`, `@separator` - extends the name to "@method @reciever[@separator]@name", with @separator defaulting to "."

queries/haskell/aerial.scm

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
(declarations
2+
(function
3+
name: (variable) @name
4+
(#set! "kind" "Function")) @symbol @start)
5+
6+
(data_type
7+
name: (name) @name
8+
(#set! "kind" "Struct")) @symbol @start
9+
10+
(newtype
11+
name: (name) @name
12+
(#set! "kind" "Struct")) @start @symbol
13+
14+
(declarations
15+
(instance
16+
name: (name) @class
17+
patterns: _ @haskell_type
18+
(#set! "kind" "Class")) @start @symbol)
19+
20+
(instance
21+
name: (name) @name
22+
23+
declarations: (instance_declarations
24+
declaration: (function
25+
name: (variable) @name)
26+
(#set! "kind" "Method")) @start @symbol)
27+
28+
(class
29+
name: (name) @name
30+
(#set! "kind" "Interface")) @start @symbol
31+
32+
(class
33+
declarations: (class_declarations
34+
declaration: (signature
35+
name: (variable) @name)
36+
(#set! "kind" "Method")) @start @symbol)

0 commit comments

Comments
 (0)