mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-02 03:26:52 -04:00
Add Windows support (mingw)
This commit is contained in:
parent
34160bb6f2
commit
ce7efd34c6
2 changed files with 20 additions and 15 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue