aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authoremmanueltouzery <etouzery@gmail.com>2022-09-09 14:06:57 +0200
committerGitHub <noreply@github.com>2022-09-09 20:06:57 +0800
commit8e65dbb6e187604cdaf0e0ef2e90c790760912e7 (patch)
tree2fc78bea7a3c1045034a75f14b5e629ff91553d3 /lua
parentdocs: update server_configurations.md (diff)
downloadnvim-lspconfig-8e65dbb6e187604cdaf0e0ef2e90c790760912e7.tar
nvim-lspconfig-8e65dbb6e187604cdaf0e0ef2e90c790760912e7.tar.gz
nvim-lspconfig-8e65dbb6e187604cdaf0e0ef2e90c790760912e7.tar.bz2
nvim-lspconfig-8e65dbb6e187604cdaf0e0ef2e90c790760912e7.tar.lz
nvim-lspconfig-8e65dbb6e187604cdaf0e0ef2e90c790760912e7.tar.xz
nvim-lspconfig-8e65dbb6e187604cdaf0e0ef2e90c790760912e7.tar.zst
nvim-lspconfig-8e65dbb6e187604cdaf0e0ef2e90c790760912e7.zip
fix: escape wildcards patterns when calling glob (#2111) (#2122)
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/util.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index 0729430f..119c1caf 100644
--- a/lua/lspconfig/util.lua
+++ b/lua/lspconfig/util.lua
@@ -99,6 +99,10 @@ end
M.path = (function()
local is_windows = uv.os_uname().version:match 'Windows'
+ local function escape_wildcards(path)
+ return path:gsub('([%[%]%?%*])', '\\%1')
+ end
+
local function sanitize(path)
if is_windows then
path = path:sub(1, 1):upper() .. path:sub(2)
@@ -211,6 +215,7 @@ M.path = (function()
local path_separator = is_windows and ';' or ':'
return {
+ escape_wildcards = escape_wildcards,
is_dir = is_dir,
is_file = is_file,
is_absolute = is_absolute,
@@ -334,7 +339,7 @@ function M.root_pattern(...)
local patterns = vim.tbl_flatten { ... }
local function matcher(path)
for _, pattern in ipairs(patterns) do
- for _, p in ipairs(vim.fn.glob(M.path.join(path, pattern), true, true)) do
+ for _, p in ipairs(vim.fn.glob(M.path.join(M.path.escape_wildcards(path), pattern), true, true)) do
if M.path.exists(p) then
return path
end