Open madskjeldgaard opened 3 years ago
It seems that when using this, the local_def here is passed the value "local"
as a string: https://github.com/nvim-treesitter/nvim-treesitter/blob/506e998da2739024b52f1ca947ae76d3423763e6/lua/nvim-treesitter/locals.lua#L133
Okay, changing that function in nvim-treesitter to the following (which now includes a type check for whether or not it is a table) works:
-- Recurse locals results until a node is found.
-- The accumulator function is given
-- * The table of the node
-- * The node
-- * The full definition match `@definition.var.something` -> 'var.something'
-- * The last definition match `@definition.var.something` -> 'something'
-- @param The locals result
-- @param The accumulator function
-- @param The full match path to append to
-- @param The last match
function M.recurse_local_nodes(local_def, accumulator, full_match, last_match)
if local_def.node then
accumulator(local_def, local_def.node, full_match, last_match)
else
if(type(local_def) == "table") then
for match_key, def in pairs(local_def) do
M.recurse_local_nodes(
def,
accumulator,
full_match and (full_match..'.'..match_key) or match_key,
match_key)
end
end
end
end
@theHamsta should this function perhaps generally type check to make sure it is a table?
should this function perhaps generally type check to make sure it is a table?
That makes sense, feel free to open a PR with that change!
should this function perhaps generally type check to make sure it is a table?
That makes sense, feel free to open a PR with that change!
Yes I'll do a PR :)
Describe the bug Hello Highlight definitions for me freaks out Nvim when it encounters and error in the parser tree it seems:
NVIM v0.5.0-dev+1318-g61aefaf29 Build type: RelWithDebInfo LuaJIT 2.0.5 Compilation: /usr/bin/cc -D_FORTIFY _SOURCE=2 -march=x86-64 -mtune=gene ric -O2 -pipe -fno-plt -U_FORTIFY_S OURCE -D_FORTIFY_SOURCE=1 -O2 -g -O g -g -Wall -Wextra -pedantic -Wno-u nused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion - Wmissing-prototypes -Wimplicit-fall through -Wvla -fstack-protector-str ong -fno-common -fdiagnostics-color =auto -DINCLUDE_GENERATED_DECLARATI ONS -D_GNU_SOURCE -DNVIM_MSGPACK_HA S_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/mads/.ca che/yay/neovim-git/src/build/config -I/home/mads/.cache/yay/neovim-git /src/neovim-git/src -I/usr/include -I/home/mads/.cache/yay/neovim-git/ src/build/src/nvim/auto -I/home/mad s/.cache/yay/neovim-git/src/build/i nclude Compiled by mads
Features: +acl +iconv +tui See ":help feature-compile"
system vimrc file: "$VIM/sysinit .vim" fall-back for $VIM: "/usr/share/n vim"