string \z escape causing ERROR
Closed this issue · 3 comments
will commented
If I have this code formatted like this (which runs fine)
local fd = vim.loop.fs_scandir(vim.fn.stdpath('config') .. '/lua/user/')
for name in
function() return vim.loop.fs_scandir_next(fd) end
do require('user.' .. name:gsub('.lua\z', '')) end
I get the parse tree
local_declaration: variable_declaration [0, 0] - [3, 52]
assignment_statement [0, 6] - [3, 52]
variable_list [0, 6] - [0, 8]
name: identifier [0, 6] - [0, 8]
expression_list [0, 11] - [3, 52]
value: function_call [0, 11] - [3, 52]
name: dot_index_expression [0, 11] - [0, 30]
table: dot_index_expression [0, 11] - [0, 19]
table: identifier [0, 11] - [0, 14]
field: identifier [0, 15] - [0, 19]
field: identifier [0, 20] - [0, 30]
arguments: arguments [0, 30] - [3, 52]
function_call [0, 31] - [3, 52]
name: function_call [0, 31] - [3, 45]
name: dot_index_expression [0, 31] - [3, 39]
table: function_call [0, 31] - [3, 35]
name: dot_index_expression [0, 31] - [0, 45]
table: dot_index_expression [0, 31] - [0, 37]
table: identifier [0, 31] - [0, 34]
field: identifier [0, 35] - [0, 37]
field: identifier [0, 38] - [0, 45]
arguments: arguments [0, 45] - [3, 35]
ERROR [0, 46] - [3, 19]
binary_expression [0, 47] - [2, 52]
left: binary_expression [0, 47] - [0, 69]
left: binary_expression [0, 47] - [0, 64]
left: function_call [0, 47] - [0, 60]
name: identifier [0, 47] - [0, 53]
arguments: arguments [0, 53] - [0, 60]
string [0, 53] - [0, 60]
right: identifier [0, 61] - [0, 64]
right: identifier [0, 65] - [0, 69]
ERROR [0, 70] - [1, 11]
identifier [1, 0] - [1, 3]
right: function_definition [2, 2] - [2, 52]
parameters: parameters [2, 10] - [2, 12]
body: block [2, 13] - [2, 48]
return_statement [2, 13] - [2, 48]
expression_list [2, 20] - [2, 48]
function_call [2, 20] - [2, 48]
name: dot_index_expression [2, 20] - [2, 44]
table: dot_index_expression [2, 20] - [2, 28]
table: identifier [2, 20] - [2, 23]
field: identifier [2, 24] - [2, 28]
field: identifier [2, 29] - [2, 44]
arguments: arguments [2, 44] - [2, 48]
identifier [2, 45] - [2, 47]
identifier [3, 14] - [3, 18]
string [3, 19] - [3, 35]
field: identifier [3, 36] - [3, 39]
ERROR [3, 39] - [3, 41]
ERROR [3, 39] - [3, 40]
identifier [3, 40] - [3, 41]
arguments: arguments [3, 41] - [3, 45]
string [3, 41] - [3, 45]
arguments: arguments [3, 45] - [3, 52]
string [3, 45] - [3, 52]
which has several errors
but formatted more normally like
local fd = vim.loop.fs_scandir(vim.fn.stdpath "config" .. "/lua/user/")
for name in function() return vim.loop.fs_scandir_next(fd) end do
require("user." .. name:gsub(".lua\z", ""))
end
I get less errors, but still one
local_declaration: variable_declaration [0, 0] - [0, 71]
assignment_statement [0, 6] - [0, 71]
variable_list [0, 6] - [0, 8]
name: identifier [0, 6] - [0, 8]
expression_list [0, 11] - [0, 71]
value: function_call [0, 11] - [0, 71]
name: dot_index_expression [0, 11] - [0, 30]
table: dot_index_expression [0, 11] - [0, 19]
table: identifier [0, 11] - [0, 14]
field: identifier [0, 15] - [0, 19]
field: identifier [0, 20] - [0, 30]
arguments: arguments [0, 30] - [0, 71]
binary_expression [0, 31] - [0, 70]
left: function_call [0, 31] - [0, 54]
name: dot_index_expression [0, 31] - [0, 45]
table: dot_index_expression [0, 31] - [0, 37]
table: identifier [0, 31] - [0, 34]
field: identifier [0, 35] - [0, 37]
field: identifier [0, 38] - [0, 45]
arguments: arguments [0, 46] - [0, 54]
string [0, 46] - [0, 54]
right: string [0, 58] - [0, 70]
ERROR [1, 0] - [3, 3]
for_generic_clause [1, 4] - [1, 62]
variable_list [1, 4] - [1, 8]
name: identifier [1, 4] - [1, 8]
expression_list [1, 12] - [1, 62]
function_definition [1, 12] - [1, 62]
parameters: parameters [1, 20] - [1, 22]
body: block [1, 23] - [1, 58]
return_statement [1, 23] - [1, 58]
expression_list [1, 30] - [1, 58]
function_call [1, 30] - [1, 58]
name: dot_index_expression [1, 30] - [1, 54]
table: dot_index_expression [1, 30] - [1, 38]
table: identifier [1, 30] - [1, 33]
field: identifier [1, 34] - [1, 38]
field: identifier [1, 39] - [1, 54]
arguments: arguments [1, 54] - [1, 58]
identifier [1, 55] - [1, 57]
identifier [2, 2] - [2, 9]
string [2, 10] - [2, 17]
function_call [2, 21] - [2, 42]
name: method_index_expression [2, 21] - [2, 30]
table: identifier [2, 21] - [2, 25]
method: identifier [2, 26] - [2, 30]
arguments: arguments [2, 30] - [2, 42]
string [2, 31] - [2, 42]
identifier [3, 0] - [3, 3]
when I don’t think there should be any?
MunifTanjim commented
Released v0.0.11
: https://github.com/MunifTanjim/tree-sitter-lua/tree/v0.0.11
It should be fixed.
MunifTanjim commented
Should be available in nvim-treesitter
after this is merged: nvim-treesitter/nvim-treesitter#3129
will commented
Works great, thanks!