mirror of
https://github.com/neovim/neovim.git
synced 2025-12-15 19:05:40 +00:00
fix(ts): escape lang when loading parsers (#16668)
When trying to load a language parser, escape the value of
the language.
With language injection, the language might be picked up from the
buffer. If this value is erroneous it can cause `nvim_get_runtime_file`
to hard error.
E.g., the markdown expression `~~~{` will extract '{' as a language and
then try to get the parser using `parser/{*` as the pattern.
This commit is contained in:
@@ -14,7 +14,7 @@ function M.require_language(lang, path, silent)
|
||||
return true
|
||||
end
|
||||
if path == nil then
|
||||
local fname = 'parser/' .. lang .. '.*'
|
||||
local fname = 'parser/' .. vim.fn.fnameescape(lang) .. '.*'
|
||||
local paths = a.nvim_get_runtime_file(fname, false)
|
||||
if #paths == 0 then
|
||||
if silent then
|
||||
|
||||
Reference in New Issue
Block a user