diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-03-09 17:48:06 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-03-09 17:48:06 +0800 |
commit | 5b144e314fe6644d6f1c46d630820f295dfd866d (patch) | |
tree | bd738c6a12358bce53a98e4c5bcbc09905a1c9a0 /script/provider | |
parent | 13397ffa3c6e5e4b59fb28ebe552cb4ca11efcc7 (diff) | |
download | lua-language-server-5b144e314fe6644d6f1c46d630820f295dfd866d.zip |
type-formating
Diffstat (limited to 'script/provider')
-rw-r--r-- | script/provider/provider.lua | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 0bdfb7fb..c623e31a 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -288,8 +288,8 @@ end) proto.on('textDocument/hover', function (params) await.close 'hover' await.setID 'hover' - workspace.awaitReady() local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_HOVER, 0.5) + workspace.awaitReady() local core = require 'core.hover' local doc = params.textDocument local uri = doc.uri @@ -315,8 +315,8 @@ proto.on('textDocument/hover', function (params) end) proto.on('textDocument/definition', function (params) - workspace.awaitReady() local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_DEFINITION, 0.5) + workspace.awaitReady() local core = require 'core.definition' local uri = params.textDocument.uri if not files.exists(uri) then @@ -344,8 +344,8 @@ proto.on('textDocument/definition', function (params) end) proto.on('textDocument/references', function (params) - workspace.awaitReady() local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_REFERENCE, 0.5) + workspace.awaitReady() local core = require 'core.reference' local uri = params.textDocument.uri if not files.exists(uri) then @@ -388,8 +388,8 @@ proto.on('textDocument/documentHighlight', function (params) end) proto.on('textDocument/rename', function (params) - workspace.awaitReady() local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_RENAME, 0.5) + workspace.awaitReady() local core = require 'core.rename' local uri = params.textDocument.uri if not files.exists(uri) then @@ -432,8 +432,8 @@ proto.on('textDocument/prepareRename', function (params) end) proto.on('textDocument/completion', function (params) - workspace.awaitReady() local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_COMPLETION, 0.5) + workspace.awaitReady() --log.info(util.dump(params)) local core = require 'core.completion' --log.debug('textDocument/completion') @@ -560,8 +560,8 @@ proto.on('textDocument/signatureHelp', function (params) if not config.config.signatureHelp.enable then return nil end - workspace.awaitReady() local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_SIGNATURE, 0.5) + workspace.awaitReady() local uri = params.textDocument.uri if not files.exists(uri) then return nil @@ -601,9 +601,9 @@ proto.on('textDocument/signatureHelp', function (params) end) proto.on('textDocument/documentSymbol', function (params) + local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_SYMBOL, 0.5) workspace.awaitReady() local core = require 'core.document-symbol' - local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_SYMBOL, 0.5) local uri = params.textDocument.uri local symbols = core(uri) @@ -687,8 +687,8 @@ proto.on('workspace/executeCommand', function (params) end) proto.on('workspace/symbol', function (params) - workspace.awaitReady() local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_WS_SYMBOL, 0.5) + workspace.awaitReady() local core = require 'core.workspace-symbol' await.close('workspace/symbol') @@ -720,8 +720,8 @@ end) proto.on('textDocument/semanticTokens/full', function (params) - workspace.awaitReady() local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_SEMANTIC_FULL, 0.5) + workspace.awaitReady() local core = require 'core.semantic-tokens' local uri = params.textDocument.uri local text = files.getText(uri) @@ -735,8 +735,8 @@ proto.on('textDocument/semanticTokens/full', function (params) end) proto.on('textDocument/semanticTokens/range', function (params) - workspace.awaitReady() local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_SEMANTIC_RANGE, 0.5) + workspace.awaitReady() local core = require 'core.semantic-tokens' local uri = params.textDocument.uri local start = files.offsetOfWord(uri, params.range.start) @@ -822,8 +822,8 @@ proto.on('$/status/click', function () end) proto.on('textDocument/onTypeFormatting', function (params) - workspace.awaitReady() local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_TYPE_FORMATTING, 0.5) + workspace.awaitReady() local ch = params.ch local uri = params.textDocument.uri if not files.exists(uri) then @@ -831,33 +831,22 @@ proto.on('textDocument/onTypeFormatting', function (params) end local core = require 'core.type-formatting' local offset = files.offset(uri, params.position) - local edits = core(uri, offset, ch) + local edits = core(uri, offset - 1, ch) if #edits == 0 then return nil end + local tab = '\t' + if params.options.insertSpaces then + tab = (' '):rep(params.options.tabSize) + end local results = {} for i, edit in ipairs(edits) do results[i] = { range = files.range(uri, edit.start, edit.finish), - newText = edit.text, + newText = edit.text:gsub('\t', tab), } end - results = { - { - range = { - ['start'] = { - line = 1, - character = 5, - }, - ['end'] = { - line = 1, - character = 5, - }, - }, - newText = '\nend', - } - } - --return results + return results end) -- Hint |