aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/lspconfig/util.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua
index b99f8555..d23e47c2 100644
--- a/lua/lspconfig/util.lua
+++ b/lua/lspconfig/util.lua
@@ -93,7 +93,14 @@ function M.search_ancestors(startpath, func)
end
local function escape_wildcards(path)
- return path:gsub('([%[%]%?%*])', '\\%1')
+ -- Escape all potentially problematic special characters
+ -- Covers:
+ -- - Wildcards and pattern matching: [ ] ? * $ ( ) ^ % . + - ~
+ -- - Escape character: \
+ -- - Shell special characters: ` ' " ; | & < >
+ -- - Whitespace: %s (spaces, tabs, etc.)
+ -- The gsub function replaces any matches with the same character preceded by a backslash
+ return path:gsub('([' .. vim.pesc('[]?*$()^%.+-~') .. '\\`\'";|&<>%s])', '\\%1')
end
function M.root_pattern(...)