From 07ff07ae4c7d6f09883ff592f11722050dab5885 Mon Sep 17 00:00:00 2001 From: Attila Tajti Date: Wed, 30 Nov 2022 20:07:51 +0100 Subject: install: fix is_installed checks with shellslash Convert paths to use backslashes on Windows. --- lua/nvim-treesitter/install.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'lua') 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 -- cgit v1.2.3-70-g09d2