summaryrefslogtreecommitdiff
path: root/script-beta
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-08-15 18:57:58 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-08-15 18:57:58 +0800
commit674892abc53ad6752326135c8aaf60073f80b632 (patch)
treec9376e1f76975834ad49f785f7f31b33e7661059 /script-beta
parent67eae45b182fc8a7302970d71af4e76eafab0a2e (diff)
downloadlua-language-server-674892abc53ad6752326135c8aaf60073f80b632.zip
先保证自动完成的速度
Diffstat (limited to 'script-beta')
-rw-r--r--script-beta/core/completion.lua5
-rw-r--r--script-beta/provider/diagnostic.lua5
-rw-r--r--script-beta/provider/provider.lua17
-rw-r--r--script-beta/vm/eachRef.lua6
4 files changed, 20 insertions, 13 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua
index ba4119fb..5f7e153e 100644
--- a/script-beta/core/completion.lua
+++ b/script-beta/core/completion.lua
@@ -13,6 +13,7 @@ local config = require 'config'
local util = require 'utility'
local markdown = require 'provider.markdown'
local findSource = require 'core.find-source'
+local await = require 'await'
local stackID = 0
local stacks = {}
@@ -234,8 +235,8 @@ local function checkFieldThen(src, used, word, start, parent, oop, results)
if used[name] then
return
end
+ used[name] = true
if not matchKey(word, name) then
- used[name] = true
return
end
local kind = ckind.Field
@@ -245,7 +246,6 @@ local function checkFieldThen(src, used, word, start, parent, oop, results)
else
kind = ckind.Function
end
- used[name] = true
buildFunction(results, src, oop, {
label = name,
kind = kind,
@@ -260,7 +260,6 @@ local function checkFieldThen(src, used, word, start, parent, oop, results)
if oop then
return
end
- used[name] = true
local literal = vm.getLiteral(src)
if literal ~= nil then
kind = ckind.Enum
diff --git a/script-beta/provider/diagnostic.lua b/script-beta/provider/diagnostic.lua
index 92aa01c2..28f0cf8e 100644
--- a/script-beta/provider/diagnostic.lua
+++ b/script-beta/provider/diagnostic.lua
@@ -212,13 +212,16 @@ end
function m.start()
m._start = true
- m.diagnosticsAll()
+ --m.diagnosticsAll()
end
files.watch(function (env, uri)
if env == 'remove' then
m.clear(uri)
elseif env == 'update' then
+ if not m._start then
+ return
+ end
await.create(function ()
await.delay(function ()
return files.globalVersion
diff --git a/script-beta/provider/provider.lua b/script-beta/provider/provider.lua
index aa649370..ba635255 100644
--- a/script-beta/provider/provider.lua
+++ b/script-beta/provider/provider.lua
@@ -319,7 +319,7 @@ proto.on('textDocument/completion', function (params)
if not result then
return nil
end
- local easy = true
+ local easy = false
local items = {}
for i, res in ipairs(result) do
local item = {
@@ -332,11 +332,13 @@ proto.on('textDocument/completion', function (params)
if res.id then
if easy and os.clock() - clock < 0.05 then
local resolved = core.resolve(res.id)
- item.detail = resolved.detail
- item.documentation = resolved.description and {
- value = resolved.description,
- kind = 'markdown',
- }
+ if resolved then
+ item.detail = resolved.detail
+ item.documentation = resolved.description and {
+ value = resolved.description,
+ kind = 'markdown',
+ }
+ end
else
easy = false
item.data = {
@@ -362,6 +364,9 @@ proto.on('completionItem/resolve', function (item)
end
await.setPriority(1000)
local resolved = core.resolve(id)
+ if not resolved then
+ return nil
+ end
item.detail = resolved.detail
item.documentation = resolved.description and {
value = resolved.description,
diff --git a/script-beta/vm/eachRef.lua b/script-beta/vm/eachRef.lua
index 65ce4d05..d372b03b 100644
--- a/script-beta/vm/eachRef.lua
+++ b/script-beta/vm/eachRef.lua
@@ -2,7 +2,7 @@ local vm = require 'vm.vm'
local guide = require 'parser.guide'
local util = require 'utility'
-local function eachRef(source, results)
+local function getRefs(source, results)
results = results or {}
local lock = vm.lock('eachDef', source)
if not lock then
@@ -22,8 +22,8 @@ local function eachRef(source, results)
end
function vm.getRefs(source)
- local cache = vm.getCache('eachRef')[source] or eachRef(source)
- vm.getCache('eachDef')[source] = cache
+ local cache = vm.getCache('eachRef')[source] or getRefs(source)
+ vm.getCache('eachRef')[source] = cache
return cache
end