diff options
| author | Stephan Seitz <stephan.seitz@fau.de> | 2020-08-25 20:00:47 +0200 |
|---|---|---|
| committer | Stephan Seitz <stephan.lauf@yahoo.de> | 2020-08-27 22:20:30 +0200 |
| commit | ce7efd34c688ae8d548cf384b215975ef3e6fd98 (patch) | |
| tree | fbd42e849148a7a6a039ce18e9c539a2709f7407 /lua/nvim-treesitter/utils.lua | |
| parent | 34160bb6f215d020a1b741a2fd4e54bbde23fd19 (diff) | |
Add Windows support (mingw)
Diffstat (limited to 'lua/nvim-treesitter/utils.lua')
| -rw-r--r-- | lua/nvim-treesitter/utils.lua | 17 |
1 files changed, 7 insertions, 10 deletions
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 |
