commit aa2b44fbb07f3ab4dd00ea4a3ae7c5d31bc20a9d
parent 37c77ab46baaeadb7c3cc5f3b77bd8ca1d7cd0da
Author: Guilherme Soares <48023091+guilhas07@users.noreply.github.com>
Date: Fri, 10 Jan 2025 22:46:19 +0000
fix(treesitter): don't return error message on success #31955
Problem:
The `vim.treesitter.language.add` function returns
a error message even when it succeeds.
Solution:
Don't return error message on success.
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/runtime/lua/vim/treesitter/language.lua b/runtime/lua/vim/treesitter/language.lua
@@ -133,8 +133,9 @@ function M.add(lang, opts)
path = paths[1]
end
- return loadparser(path, lang, symbol_name) or nil,
- string.format('Cannot load parser %s for language "%s"', path, lang)
+ local res = loadparser(path, lang, symbol_name)
+ return res,
+ res == nil and string.format('Cannot load parser %s for language "%s"', path, lang) or nil
end
--- @param x string|string[]