summaryrefslogtreecommitdiff
path: root/server-beta/src/proto
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-11-08 14:05:55 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-11-08 14:05:55 +0800
commit0a2df61286035af2bd506605547f6a5d5024c691 (patch)
tree0d77de700d936403aec32c0eea37237448f04b3a /server-beta/src/proto
parentf53b68d739ab7aad9c6aae2b902f34fbb8fc97ea (diff)
downloadlua-language-server-0a2df61286035af2bd506605547f6a5d5024c691.zip
修正诊断策略
Diffstat (limited to 'server-beta/src/proto')
-rw-r--r--server-beta/src/proto/capability.lua40
-rw-r--r--server-beta/src/proto/init.lua1
-rw-r--r--server-beta/src/proto/provider.lua174
3 files changed, 0 insertions, 215 deletions
diff --git a/server-beta/src/proto/capability.lua b/server-beta/src/proto/capability.lua
deleted file mode 100644
index 71d3bca1..00000000
--- a/server-beta/src/proto/capability.lua
+++ /dev/null
@@ -1,40 +0,0 @@
-local m = {}
-
-m.initer = {
- -- 文本同步方式
- textDocumentSync = {
- -- 打开关闭文本时通知
- openClose = true,
- -- 文本改变时完全通知 TODO 支持差量更新(2)
- change = 1,
- },
-
- hoverProvider = true,
- definitionProvider = true,
- --referencesProvider = true,
- --renameProvider = true,
- --documentSymbolProvider = true,
- --documentHighlightProvider = true,
- --codeActionProvider = true,
- --signatureHelpProvider = {
- -- triggerCharacters = { '(', ',' },
- --},
- --workspace = {
- -- workspaceFolders = {
- -- supported = true,
- -- changeNotifications = true,
- -- }
- --},
- --documentOnTypeFormattingProvider = {
- -- firstTriggerCharacter = '}',
- --},
- --executeCommandProvider = {
- -- commands = {
- -- 'config',
- -- 'removeSpace',
- -- 'solve',
- -- },
- --},
-}
-
-return m
diff --git a/server-beta/src/proto/init.lua b/server-beta/src/proto/init.lua
index e2fa1bb5..33e637f6 100644
--- a/server-beta/src/proto/init.lua
+++ b/server-beta/src/proto/init.lua
@@ -1,4 +1,3 @@
local proto = require 'proto.proto'
-require 'proto.provider'
return proto
diff --git a/server-beta/src/proto/provider.lua b/server-beta/src/proto/provider.lua
deleted file mode 100644
index 7527ea16..00000000
--- a/server-beta/src/proto/provider.lua
+++ /dev/null
@@ -1,174 +0,0 @@
-local util = require 'utility'
-local cap = require 'proto.capability'
-local await = require 'await'
-local files = require 'files'
-local proto = require 'proto.proto'
-local define = require 'proto.define'
-local workspace = require 'workspace'
-local config = require 'config'
-
-local function updateConfig()
- local configs = proto.awaitRequest('workspace/configuration', {
- items = {
- {
- scopeUri = workspace.uri,
- section = 'Lua',
- },
- {
- scopeUri = workspace.uri,
- section = 'files.associations',
- },
- {
- scopeUri = workspace.uri,
- section = 'files.exclude',
- }
- },
- })
-
- local updated = configs[1]
- local other = {
- associations = configs[2],
- exclude = configs[3],
- }
-
- local oldConfig = util.deepCopy(config.config)
- local oldOther = util.deepCopy(config.other)
- config.setConfig(updated, other)
- local newConfig = config.config
- local newOther = config.other
- if not util.equal(oldConfig.runtime, newConfig.runtime) then
- end
- if not util.equal(oldConfig.diagnostics, newConfig.diagnostics) then
- end
- if newConfig.completion.enable then
- else
- end
- if not util.equal(oldConfig.plugin, newConfig.plugin) then
- end
- if not util.equal(oldConfig.workspace, newConfig.workspace)
- or not util.equal(oldConfig.plugin, newConfig.plugin)
- or not util.equal(oldOther.associations, newOther.associations)
- or not util.equal(oldOther.exclude, newOther.exclude)
- then
- end
-end
-
-proto.on('initialize', function (params)
- --log.debug(util.dump(params))
- if params.workspaceFolders then
- local name = params.workspaceFolders[1].name
- local uri = params.workspaceFolders[1].uri
- workspace.init(name, uri)
- end
- return {
- capabilities = cap.initer,
- }
-end)
-
-proto.on('initialized', function (params)
- updateConfig()
- proto.awaitRequest('client/registerCapability', {
- registrations = {
- -- 监视文件变化
- {
- id = '0',
- method = 'workspace/didChangeWatchedFiles',
- registerOptions = {
- watchers = {
- {
- globPattern = '**/',
- kind = 1 | 2 | 4,
- }
- },
- },
- },
- -- 配置变化
- {
- id = '1',
- method = 'workspace/didChangeConfiguration',
- }
- }
- })
- await.create(workspace.awaitPreload)
- return true
-end)
-
-proto.on('exit', function ()
- log.info('Server exited.')
- os.exit(true)
-end)
-
-proto.on('shutdown', function ()
- log.info('Server shutdown.')
- return true
-end)
-
-proto.on('workspace/configuration', function ()
- updateConfig()
-end)
-
-proto.on('workspace/didChangeWatchedFiles', function (params)
-end)
-
-proto.on('textDocument/didOpen', function (params)
- local doc = params.textDocument
- local uri = doc.uri
- local text = doc.text
- files.open(uri)
- files.setText(uri, text)
-end)
-
-proto.on('textDocument/didClose', function (params)
- local doc = params.textDocument
- local uri = doc.uri
- files.close(uri)
- if not files.isLua(uri) then
- files.remove(uri)
- end
-end)
-
-proto.on('textDocument/didChange', function (params)
- local doc = params.textDocument
- local change = params.contentChanges
- local uri = doc.uri
- local text = change[1].text
- if files.isLua(uri) or files.isOpen(uri) then
- files.setText(uri, text)
- end
-end)
-
-proto.on('textDocument/hover', function ()
- return {
- contents = {
- value = 'Hello loli!',
- kind = 'markdown',
- }
- }
-end)
-
-proto.on('textDocument/definition', function (params)
- local core = require 'core.definition'
- 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)
- if not result then
- return nil
- end
- local response = {}
- for i, info in ipairs(result) do
- local targetUri = info.uri
- local targetLines = files.getLines(targetUri)
- local targetText = files.getText(targetUri)
- response[i] = define.locationLink(targetUri
- , define.range(targetLines, targetText, info.target.start, info.target.finish)
- , define.range(targetLines, targetText, info.target.start, info.target.finish)
- , define.range(lines, text, info.source.start, info.source.finish)
- )
- end
- return response
-end)