@@ -35,7 +35,7 @@ local function fast_parse(lang_tree)
35
35
return parser :parse (old_trees [1 ], lang_tree ._source )
36
36
end
37
37
38
- --- @param apply fun ( module_name : string ):( string | nil ) Callback to apply the module name to
38
+ --- @param apply fun ( module_name : string ):( string | nil ) Callback to apply the module name to. If the callback returns , this function returns.
39
39
--- @param content string The content to parse from
40
40
--- @param query_string ? string The tree-sitter query string with a ' @mod' capture
41
41
--- @return string | nil
@@ -48,8 +48,11 @@ local function treesitter_module_name(apply, content, query_string)
48
48
--- @diagnostic disable-next-line
49
49
for _ , match in module_query :iter_matches (root , content ) do
50
50
for _ , node in ipairs (match ) do
51
- local txt = vim .treesitter .get_node_text (node , content )
52
- return apply (txt )
51
+ local txt = vim .print (vim .treesitter .get_node_text (node , content ))
52
+ local result = apply (txt )
53
+ if result then
54
+ return result
55
+ end
53
56
end
54
57
end
55
58
end
58
61
local function get_buf_module_name (_ )
59
62
local buf_content = table.concat (vim .api .nvim_buf_get_lines (0 , 0 , - 1 , false ), ' \n ' )
60
63
return treesitter_module_name (function (mod )
61
- return vim . print ( mod )
64
+ return mod
62
65
end , buf_content , ' [(module)(qualified_module)] @mod' )
63
66
end
64
67
@@ -106,7 +109,6 @@ local function get_qualified_name_node(args)
106
109
local choices = { insert (1 ) }
107
110
if has_haskell_parser then
108
111
treesitter_module_name (function (mod )
109
- vim .print (mod )
110
112
table.insert (choices , 1 , text (mod :sub (1 , 1 )))
111
113
table.insert (choices , 1 , text (mod ))
112
114
end , import_stmt )
0 commit comments