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.
This commit is contained in:
Guilherme Soares 2025-01-10 22:46:19 +00:00 committed by GitHub
parent 37c77ab46b
commit aa2b44fbb0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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[]