aboutsummaryrefslogtreecommitdiffstats
path: root/lua/lspconfig/util.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/lspconfig/util.lua')
-rw-r--r--lua/lspconfig/util.lua18
1 files changed, 15 insertions, 3 deletions
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index 09a22163..956be435 100644
--- a/lua/lspconfig/util.lua
+++ b/lua/lspconfig/util.lua
@@ -21,11 +21,13 @@ M.default_config = {
M.on_setup = nil
function M.bufname_valid(bufname)
- if bufname and bufname ~= '' and (bufname:match '^([a-zA-Z]:).*' or bufname:match '^/') then
- return true
- else
+ if not bufname then
return false
end
+ if bufname:match '^/' or bufname:match '^[a-zA-Z]:' or bufname:match '^zipfile://' or bufname:match '^tarfile:' then
+ return true
+ end
+ return false
end
function M.validate_bufnr(bufnr)
@@ -341,6 +343,7 @@ function M.root_pattern(...)
end
end
return function(startpath)
+ startpath = M.strip_archive_subpath(startpath)
return M.search_ancestors(startpath, matcher)
end
end
@@ -437,4 +440,13 @@ function M.get_managed_clients()
return clients
end
+-- For zipfile: or tarfile: virtual paths, returns the path to the archive.
+-- Other paths are returned unaltered.
+function M.strip_archive_subpath(path)
+ -- Matches regex from zip.vim / tar.vim
+ path = vim.fn.substitute(path, 'zipfile://\\(.\\{-}\\)::[^\\\\].*$', '\\1', '')
+ path = vim.fn.substitute(path, 'tarfile:\\(.\\{-}\\)::.*$', '\\1', '')
+ return path
+end
+
return M