aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorAttila Tajti <attila.tajti@gmail.com>2022-11-30 20:07:51 +0100
committerStephan Seitz <stephan.seitz@fau.de>2022-12-14 17:27:16 +0100
commit07ff07ae4c7d6f09883ff592f11722050dab5885 (patch)
treefab1eb1039aac71b75cace3fc578edaf8764c043 /lua
parentshell: respect shellslash option on Windows (diff)
downloadnvim-treesitter-07ff07ae4c7d6f09883ff592f11722050dab5885.tar
nvim-treesitter-07ff07ae4c7d6f09883ff592f11722050dab5885.tar.gz
nvim-treesitter-07ff07ae4c7d6f09883ff592f11722050dab5885.tar.bz2
nvim-treesitter-07ff07ae4c7d6f09883ff592f11722050dab5885.tar.lz
nvim-treesitter-07ff07ae4c7d6f09883ff592f11722050dab5885.tar.xz
nvim-treesitter-07ff07ae4c7d6f09883ff592f11722050dab5885.tar.zst
nvim-treesitter-07ff07ae4c7d6f09883ff592f11722050dab5885.zip
install: fix is_installed checks with shellslash
Convert paths to use backslashes on Windows.
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-treesitter/install.lua15
1 files changed, 13 insertions, 2 deletions
diff --git a/lua/nvim-treesitter/install.lua b/lua/nvim-treesitter/install.lua
index b0428bd8f..54a813cd4 100644
--- a/lua/nvim-treesitter/install.lua
+++ b/lua/nvim-treesitter/install.lua
@@ -95,6 +95,17 @@ local function get_installed_revision(lang)
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
---@param lang string
---@return boolean
@@ -104,9 +115,9 @@ local function is_installed(lang)
if not install_dir then
return false
end
- install_dir = vim.fn.fnamemodify(install_dir, ":p")
+ install_dir = clean_path(install_dir)
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
return true
end