Closed luckasRanarison closed 9 months ago
Any pattern that doesn't start with
**
will fail to match because we're passing in the absolute path to the file.
This is actually not true, try the following:
local pat = vim.fn.glob2regpat("*.js")
local match = vim.fn.match("/dir/file.js", pat)
print(match) -- 9
Ah, I was overly broad. Yes it's true that a pattern of *.js
also works, but if the pattern doesn't start with a *
or **
, then it will fail. Example:
local pat = vim.fn.glob2regpat("src/*.js")
local match = vim.fn.match("/home/user/project/src/file.js", pat)
print(match) -- -1
Oh, I see. But I think it's unlikely going to happen, I think FileOperartionPattern
is meant to be matched against the absolute path. tsserver, rust_analyzer and php actor which support willRenameFiles
all use **/*.filetype
.
I'll update this later and use vim.lsp._watchfiles
and fallback to both absolute path and relative path as a workaround if you're concerned about it.
Thanks for the PR!
Closes #247. I think getting the relative path is unnecessary because the glob pattern will always match the full path, and it can mess up with some server filters, for example: tsserver uses
**/*.js
but the relative path omit the parent dir.