Skip to content

Commit

Permalink
Merge pull request #41 from desdic/20240227fixlua
Browse files Browse the repository at this point in the history
Add missing lua function type
  • Loading branch information
desdic committed Feb 27, 2024
2 parents 337f680 + 4ca8a46 commit 772737d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions queries/lua/agrolens.callings.scm
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
(function_call name:(identifier) @agrolens.name) @agrolens.scope

(function_call name:(dot_index_expression table:(identifier) @agrolens.object field:(identifier) @agrolens.name)) @agrolens.scope

(function_call
name:(method_index_expression
table:(identifier)
method:(identifier) @agrolens.name)) @agrolens.scope
6 changes: 6 additions & 0 deletions queries/lua/agrolens.functions.scm
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@
(variable_list name:(dot_index_expression field:(identifier) @agrolens.name))
(expression_list value:(function_definition))
) @agrolens.scope

(function_declaration
name:(method_index_expression
table:(identifier)
method:(identifier) @agrolens.name)) @agrolens.scope

5 changes: 5 additions & 0 deletions tests/lua/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ function M.hello5()
print("hello5")
end

function M:hello6()
print("hello6")
end

hello1()
hello2()
hello3()
M.hello4()
M.hello5()
M:hello6()
6 changes: 4 additions & 2 deletions tests/lua_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,27 @@ describe("lua", function()
local entries =
core.get_captures({ queries = { "functions" }, bufids = buffers })

eq(#entries, 5)
eq(#entries, 6)
eq(entries[1].lnum, 1)
eq(entries[1].col, 0)
eq(entries[1].line, "local hello1 = function()")
eq(entries[2].line, "hello2 = function()")
eq(entries[3].line, "function hello3()")
eq(entries[4].line, "M.hello4 = function()")
eq(entries[5].line, "function M.hello5()")
eq(entries[6].line, "function M:hello6()")
end)

it("callings", function()
local entries =
core.get_captures({ queries = { "callings" }, bufids = buffers })

eq(#entries, 10)
eq(#entries, 12)
eq(entries[1].lnum, 2)
eq(entries[1].col, 4)
eq(entries[1].line, ' print("hello1")')
eq(entries[2].line, ' print("hello2")')
eq(entries[12].line, 'M:hello6()')
end)

it("comments", function()
Expand Down

0 comments on commit 772737d

Please sign in to comment.