Skip to content

Commit

Permalink
fix: add interface type to golang treesitter backend (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Nov 8, 2022
1 parent 3423358 commit 480bf14
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions lua/aerial/backends/treesitter/language_kind_map.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ return {
},
go = {
function_declaration = "Function",
interface_type = "Interface",
method_declaration = "Method",
struct_type = "Struct",
},
Expand Down
2 changes: 1 addition & 1 deletion queries/go/aerial.scm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
(type_declaration
(type_spec
name: (type_identifier) @name
type: (struct_type) @type)) @start
type: [(struct_type) (interface_type)] @type)) @start

(method_declaration
name: (field_identifier) @name
Expand Down
9 changes: 9 additions & 0 deletions tests/treesitter/go_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ describe("treesitter go", function()
end_lnum = 7,
end_col = 23,
},
{
kind = "Interface",
name = "MyInterface",
level = 0,
lnum = 9,
col = 0,
end_lnum = 9,
end_col = 28,
},
})
end)
end)
2 changes: 2 additions & 0 deletions tests/treesitter/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ func fn_1() {}
type st_1 struct{}

func (st_1) Meth_1() {}

type MyInterface interface{}

0 comments on commit 480bf14

Please sign in to comment.