summaryrefslogtreecommitdiff
path: root/script/provider
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-07-07 14:25:23 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-07-07 14:25:23 +0800
commit3b8a99d32810d83c56fd06ef1375eccc5f220345 (patch)
tree6e479a48d127021c2e02482cf0267774e6231a2d /script/provider
parentc902388de8d140a1dbb979118ca705b47c52b51f (diff)
downloadlua-language-server-3b8a99d32810d83c56fd06ef1375eccc5f220345.zip
cleanup
Diffstat (limited to 'script/provider')
-rw-r--r--script/provider/capability.lua2
-rw-r--r--script/provider/client.lua124
-rw-r--r--script/provider/completion.lua2
-rw-r--r--script/provider/diagnostic.lua2
-rw-r--r--script/provider/provider.lua2
-rw-r--r--script/provider/semantic-tokens.lua2
6 files changed, 5 insertions, 129 deletions
diff --git a/script/provider/capability.lua b/script/provider/capability.lua
index 3cc98744..b8a56b7b 100644
--- a/script/provider/capability.lua
+++ b/script/provider/capability.lua
@@ -1,6 +1,6 @@
local sp = require 'bee.subprocess'
local nonil = require 'without-check-nil'
-local client = require 'provider.client'
+local client = require 'client'
local platform = require 'bee.platform'
local completion = require 'provider.completion'
diff --git a/script/provider/client.lua b/script/provider/client.lua
deleted file mode 100644
index a3d837bb..00000000
--- a/script/provider/client.lua
+++ /dev/null
@@ -1,124 +0,0 @@
-local nonil = require 'without-check-nil'
-local util = require 'utility'
-local lang = require 'language'
-local proto = require 'proto'
-local define = require 'proto.define'
-local config = require 'config'
-
-local m = {}
-m.watchList = {}
-
-function m.client(newClient)
- if newClient then
- m._client = newClient
- else
- return m._client
- end
-end
-
-function m.isVSCode()
- if not m._client then
- return false
- end
- if m._isvscode == nil then
- local lname = m._client:lower()
- if lname:find 'vscode'
- or lname:find 'visual studio code' then
- m._isvscode = true
- else
- m._isvscode = false
- end
- end
- return m._isvscode
-end
-
-function m.getOption(name)
- nonil.enable()
- local option = m.info.initializationOptions[name]
- nonil.disable()
- return option
-end
-
----show message to client
----@param type '"Error"'|'"Warning"'|'"Info"'|'"Log"'
----@param message any
-function m.showMessage(type, message)
- proto.notify('window/showMessage', {
- type = define.MessageType[type] or 3,
- message = message,
- })
- proto.notify('window/logMessage', {
- type = define.MessageType[type] or 3,
- message = message,
- })
-end
-
----@param type '"Error"'|'"Warning"'|'"Info"'|'"Log"'
----@param message any
-function m.logMessage(type, message)
- proto.notify('window/logMessage', {
- type = define.MessageType[type] or 4,
- message = message,
- })
-end
-
----@class config.change
----@field key string
----@field value any
----@field action '"add"'|'"set"'
----@field isGlobal? boolean
----@field uri? uri
-
----@param changes config.change[]
-function m.setConfig(changes)
- for _, change in ipairs(changes) do
- if change.action == 'add' then
- config.add(change.key, change.value)
- elseif change.action == 'set' then
- config.set(change.key, change.value)
- end
- end
- m.event('updateConfig')
- if m.getOption 'changeConfiguration' then
- for _, change in ipairs(changes) do
- proto.notify('$/command', {
- command = 'lua.config',
- data = change,
- })
- end
- else
- -- TODO translate
- local messages = {}
- messages[1] = lang.script('你的客户端不支持从服务侧修改设置,请手动修改如下设置:')
- for _, change in ipairs(changes) do
- if change.action == 'add' then
- messages[#messages+1] = lang.script('为 `{key}` 添加值 `{value:q}`;', change)
- else
- messages[#messages+1] = lang.script('将 `{key}` 的值设置为 `{value:q}`;', change)
- end
- end
- local message = table.concat(messages, '\n')
- m.showMessage('Info', message)
- end
-end
-
-function m.event(ev, ...)
- for _, callback in ipairs(m.watchList) do
- callback(ev, ...)
- end
-end
-
-function m.watch(callback)
- m.watchList[#m.watchList+1] = callback
-end
-
-function m.init(t)
- log.debug('Client init', util.dump(t))
- m.info = t
- nonil.enable()
- m.client(t.clientInfo.name)
- nonil.disable()
- lang(LOCALE or t.locale)
-end
-
-return m
diff --git a/script/provider/completion.lua b/script/provider/completion.lua
index bca5b7af..108ea023 100644
--- a/script/provider/completion.lua
+++ b/script/provider/completion.lua
@@ -1,6 +1,6 @@
local proto = require 'proto'
local nonil = require 'without-check-nil'
-local client = require 'provider.client'
+local client = require 'client'
local isEnable = false
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index fa31805c..0a857be7 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -8,7 +8,7 @@ local core = require 'core.diagnostics'
local util = require 'utility'
local ws = require 'workspace'
local progress = require "progress"
-local client = require 'provider.client'
+local client = require 'client'
local m = {}
m._start = false
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index 1dfe2719..5ad5bc0b 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -10,7 +10,7 @@ local workspace = require 'workspace'
local config = require 'config'
local library = require 'library'
local markdown = require 'provider.markdown'
-local client = require 'provider.client'
+local client = require 'client'
local furi = require 'file-uri'
local pub = require 'pub'
local fs = require 'bee.filesystem'
diff --git a/script/provider/semantic-tokens.lua b/script/provider/semantic-tokens.lua
index 942bd046..5e331ebd 100644
--- a/script/provider/semantic-tokens.lua
+++ b/script/provider/semantic-tokens.lua
@@ -1,6 +1,6 @@
local proto = require 'proto'
local define = require 'proto.define'
-local client = require 'provider.client'
+local client = require 'client'
local json = require "json"
local config = require 'config'
local lang = require 'language'