diff options
author | sumneko <sumneko@hotmail.com> | 2019-04-15 12:35:01 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-04-15 12:35:01 +0800 |
commit | a7f2d6fcc71a33db60cf759ffc79fdc711aaee30 (patch) | |
tree | 17c61f04db05351af2117df84e171d985afc4961 /server/src | |
parent | d3b7320f385b9f31b29978258657293e314babd5 (diff) | |
download | lua-language-server-a7f2d6fcc71a33db60cf759ffc79fdc711aaee30.zip |
VSCode默认关闭输入时格式化功能,所以这个功能先搁置。以后考虑帮用户修改工作区设置?
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/method/init.lua | 1 | ||||
-rw-r--r-- | server/src/method/initialize.lua | 3 | ||||
-rw-r--r-- | server/src/method/textDocument/onTypeFormatting.lua | 14 |
3 files changed, 18 insertions, 0 deletions
diff --git a/server/src/method/init.lua b/server/src/method/init.lua index 565fdb64..7e81eb00 100644 --- a/server/src/method/init.lua +++ b/server/src/method/init.lua @@ -18,6 +18,7 @@ init 'textDocument/documentHighlight' init 'textDocument/documentSymbol' init 'textDocument/hover' init 'textDocument/implementation' +init 'textDocument/onTypeFormatting' init 'textDocument/publishDiagnostics' init 'textDocument/rename' init 'textDocument/references' diff --git a/server/src/method/initialize.lua b/server/src/method/initialize.lua index e7c48545..930ff75e 100644 --- a/server/src/method/initialize.lua +++ b/server/src/method/initialize.lua @@ -39,6 +39,9 @@ return function (lsp) changeNotifications = true, } }, + documentOnTypeFormattingProvider = { + firstTriggerCharacter = '}', + }, executeCommandProvider = { commands = { 'config', diff --git a/server/src/method/textDocument/onTypeFormatting.lua b/server/src/method/textDocument/onTypeFormatting.lua new file mode 100644 index 00000000..4943c609 --- /dev/null +++ b/server/src/method/textDocument/onTypeFormatting.lua @@ -0,0 +1,14 @@ +return function (lsp, params) + local uri = params.textDocument.uri + local vm, lines = lsp:loadVM(uri) + log.debug(table.dump(params)) + if not vm then + return nil + end + local position = lines:position(params.position.line + 1, params.position.character) + local ch = params.ch + local options = params.options + local tabSize = options.tabSize + local insertSpaces = options.insertSpaces + return nil +end |