diff options
Diffstat (limited to 'server-beta/src/provider')
-rw-r--r-- | server-beta/src/provider/capability.lua | 2 | ||||
-rw-r--r-- | server-beta/src/provider/init.lua | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/server-beta/src/provider/capability.lua b/server-beta/src/provider/capability.lua index 5cefd0c5..b2b7ee3a 100644 --- a/server-beta/src/provider/capability.lua +++ b/server-beta/src/provider/capability.lua @@ -12,7 +12,7 @@ m.initer = { hoverProvider = true, definitionProvider = true, referencesProvider = true, - --renameProvider = true, + renameProvider = true, --documentSymbolProvider = true, documentHighlightProvider = true, --codeActionProvider = true, diff --git a/server-beta/src/provider/init.lua b/server-beta/src/provider/init.lua index 0a70763e..1dc092c7 100644 --- a/server-beta/src/provider/init.lua +++ b/server-beta/src/provider/init.lua @@ -230,6 +230,35 @@ proto.on('textDocument/documentHighlight', function (params) return response end) +proto.on('textDocument/rename', function (params) + local core = require 'core.rename' + local uri = params.textDocument.uri + if not files.exists(uri) then + return nil + end + local lines = files.getLines(uri) + local text = files.getText(uri) + local offset = define.offset(lines, text, params.position) + local result = core(uri, offset, params.newName) + if not result then + return nil + end + local workspaceEdit = { + changes = {}, + } + for _, info in ipairs(result) do + local ruri = info.uri + local rlines = files.getLines(ruri) + local rtext = files.getText(ruri) + if not workspaceEdit.changes[ruri] then + workspaceEdit.changes[ruri] = {} + end + local textEdit = define.textEdit(define.range(rlines, rtext, info.start, info.finish), info.text) + workspaceEdit.changes[ruri][#workspaceEdit.changes[ruri]+1] = textEdit + end + return workspaceEdit +end) + proto.on('textDocument/completion', function (params) --log.info(util.dump(params)) return nil |