zk-org / zk-nvim

Neovim extension for zk
https://github.com/zk-org/zk
GNU General Public License v3.0
530 stars 42 forks source link

Escape lua `special characters` in path name #117

Closed dstanberry closed 1 year ago

dstanberry commented 1 year ago

Please include the following in lua/zk/root_pattern.lua (copied from nvim-lspconfig):

-- M.path = (function()
--   local is_windows = uv.os_uname().version:match("Windows")
--
  local function escape_wildcards(path)
    return path:gsub('([%[%]%?%*])', '\\%1')
  end
--
--   local function exists(filename)
--     local stat = uv.fs_stat(filename)
--     return stat and stat.type or false
--   end

...

-- 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(M.path.escape_wildcards(path), pattern), true, true)) do
--         if M.path.exists(p) then
--           return path
--         end
--       end
mickael-menu commented 1 year ago

Would you mind opening a PR for this with a short description on why this is needed? Thanks

dstanberry commented 1 year ago

Opened #118