diff options
Diffstat (limited to 'script/provider')
-rw-r--r-- | script/provider/capability.lua | 19 | ||||
-rw-r--r-- | script/provider/provider.lua | 8 |
2 files changed, 25 insertions, 2 deletions
diff --git a/script/provider/capability.lua b/script/provider/capability.lua index 873fbfd3..4e63f571 100644 --- a/script/provider/capability.lua +++ b/script/provider/capability.lua @@ -11,6 +11,7 @@ require 'provider.inlay-hint' local m = {} m.fillings = {} +m.resolvedMap = {} local function mergeFillings(provider) for _, filling in ipairs(m.fillings) do @@ -29,6 +30,19 @@ local function mergeFillings(provider) end end +local function resolve(t) + for k, v in pairs(t) do + if type(v) == 'table' then + resolve(v) + end + if type(v) == 'string' then + t[k] = v:gsub('%{(.-)%}', function (key) + return m.resolvedMap[key] or '' + end) + end + end +end + function m.getProvider() local provider = { offsetEncoding = client.getOffsetEncoding(), @@ -52,6 +66,7 @@ function m.getProvider() nonil.disable() mergeFillings(provider) + resolve(provider) return provider end @@ -60,4 +75,8 @@ function m.filling(t) m.fillings[#m.fillings+1] = t end +function m.resolve(key, value) + m.resolvedMap[key] = value +end + return m diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 7e06c809..10feb783 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -109,6 +109,7 @@ m.register 'initialize' { if params.rootUri then workspace.initRoot(params.rootUri) + cap.resolve('ROOT_URI', furi.decode(params.rootUri):gsub('\\', '/') .. '/') end if params.workspaceFolders then @@ -188,7 +189,10 @@ m.register 'workspace/didRenameFiles' { filters = { { pattern = { - glob = '**', + glob = '{ROOT_URI}**', + options = { + ignoreCase = true, + } }, }, }, @@ -203,7 +207,7 @@ m.register 'workspace/didRenameFiles' { for _, file in ipairs(params.files) do local oldUri = furi.normalize(file.oldUri) local newUri = furi.normalize(file.newUri) - if files.exists(oldUri) + if workspace.isValidLuaUri(oldUri) and workspace.isValidLuaUri(newUri) then renames[#renames+1] = { oldUri = oldUri, |