mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-17 02:40:09 -04:00
install: fix is_installed checks with shellslash
Convert paths to use backslashes on Windows.
This commit is contained in:
parent
8b5080b1bf
commit
07ff07ae4c
1 changed files with 13 additions and 2 deletions
|
|
@ -95,6 +95,17 @@ local function get_installed_revision(lang)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Clean path for use in a prefix comparison
|
||||||
|
-- @param input string
|
||||||
|
-- @return string
|
||||||
|
local function clean_path(input)
|
||||||
|
local pth = vim.fn.fnamemodify(input, ":p")
|
||||||
|
if fn.has "win32" == 1 then
|
||||||
|
pth = pth:gsub("/", "\\")
|
||||||
|
end
|
||||||
|
return pth
|
||||||
|
end
|
||||||
|
|
||||||
---Checks if parser is installed with nvim-treesitter
|
---Checks if parser is installed with nvim-treesitter
|
||||||
---@param lang string
|
---@param lang string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
|
|
@ -104,9 +115,9 @@ local function is_installed(lang)
|
||||||
if not install_dir then
|
if not install_dir then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
install_dir = vim.fn.fnamemodify(install_dir, ":p")
|
install_dir = clean_path(install_dir)
|
||||||
for _, path in ipairs(matched_parsers) do
|
for _, path in ipairs(matched_parsers) do
|
||||||
local abspath = vim.fn.fnamemodify(path, ":p")
|
local abspath = clean_path(path)
|
||||||
if vim.startswith(abspath, install_dir) then
|
if vim.startswith(abspath, install_dir) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue