From ce7efd34c688ae8d548cf384b215975ef3e6fd98 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Tue, 25 Aug 2020 20:00:47 +0200 Subject: Add Windows support (mingw) --- lua/nvim-treesitter/utils.lua | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'lua/nvim-treesitter/utils.lua') diff --git a/lua/nvim-treesitter/utils.lua b/lua/nvim-treesitter/utils.lua index d3d18339..a39dd054 100644 --- a/lua/nvim-treesitter/utils.lua +++ b/lua/nvim-treesitter/utils.lua @@ -19,7 +19,9 @@ end function M.get_package_path() for _, path in pairs(api.nvim_list_runtime_paths()) do - if string.match(path, '.*/nvim%-treesitter') then + local last_segment = vim.fn.fnamemodify(path, ":t") + local penultimate_segment = vim.fn.fnamemodify(path, ":t:t") + if last_segment == "nvim-treesitter" or (last_segment == "" and penultimate_segment == "nvim-treesitter") then return path end end @@ -28,20 +30,15 @@ function M.get_package_path() end function M.get_cache_dir() - local home = fn.get(fn.environ(), 'HOME') - local xdg_cache = fn.get(fn.environ(), 'XDG_CACHE_HOME') + local cache_dir = fn.stdpath('data') - if xdg_cache == 0 then - xdg_cache = home .. '/.cache' - end - - if luv.fs_access(xdg_cache, 'RW') then - return xdg_cache + if luv.fs_access(cache_dir, 'RW') then + return cache_dir elseif luv.fs_access('/tmp', 'RW') then return '/tmp' end - return nil, 'Invalid cache rights, $XDG_CACHE_HOME or /tmp should be read/write' + return nil, 'Invalid cache rights, '..fn.stdpath('data')..' or /tmp should be read/write' end -- Gets a property at path -- cgit v1.2.3