summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-08-19 20:45:51 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-08-19 20:45:51 +0800
commit7829753fb9951f2de05a3ebec0e94b3164eb6b46 (patch)
treed6af300d2453389a28e47acf2ccc7e6d6da84b36 /script
parent0ec4d69bc4e34c3c11c85d17edc0e98e9a719c7e (diff)
downloadlua-language-server-7829753fb9951f2de05a3ebec0e94b3164eb6b46.zip
improve completion
Diffstat (limited to 'script')
-rw-r--r--script/core/completion.lua4
-rw-r--r--script/core/folding.lua3
-rw-r--r--script/core/semantic-tokens.lua6
-rw-r--r--script/files.lua2
-rw-r--r--script/provider/provider.lua8
5 files changed, 16 insertions, 7 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua
index d4f77368..a899ec5c 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -633,6 +633,7 @@ local function checkCommon(myUri, word, text, offset, results)
used[data[1]] = true
end
if config.get 'Lua.completion.workspaceWord' and #word >= 2 then
+ results.complete = true
local myHead = word:sub(1, 2)
for uri in files.eachFile() do
if #results >= 100 then
@@ -697,6 +698,9 @@ local function checkCommon(myUri, word, text, offset, results)
end
end
end
+ if #results >= 100 then
+ results.complete = false
+ end
end
local function isInString(ast, offset)
diff --git a/script/core/folding.lua b/script/core/folding.lua
index dad98422..51d1be6b 100644
--- a/script/core/folding.lua
+++ b/script/core/folding.lua
@@ -1,6 +1,7 @@
local files = require "files"
local guide = require "parser.guide"
local util = require 'utility'
+local await = require 'await'
local Care = {
['function'] = function (source, text, results)
@@ -156,12 +157,14 @@ return function (uri)
guide.eachSource(ast.ast, function (source)
local tp = source.type
if Care[tp] then
+ await.delay()
Care[tp](source, text, regions)
end
end)
for _, source in ipairs(ast.comms) do
local tp = source.type
if Care[tp] then
+ await.delay()
Care[tp](source, text, regions, status)
end
end
diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua
index ce869ed1..96cbc5e1 100644
--- a/script/core/semantic-tokens.lua
+++ b/script/core/semantic-tokens.lua
@@ -221,17 +221,13 @@ return function (uri, start, finish)
end
local results = {}
- local count = 0
guide.eachSourceBetween(ast.ast, start, finish, function (source)
local method = Care[source.type]
if not method then
return
end
method(source, results)
- count = count + 1
- if count % 100 == 0 then
- await.delay()
- end
+ await.delay()
end)
for _, comm in ipairs(ast.comms) do
diff --git a/script/files.lua b/script/files.lua
index 93331bb5..2c8ea829 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -184,7 +184,7 @@ function m.setText(uri, text, isTrust, instance)
await.call(function ()
await.close('update:' .. uri)
await.setID('update:' .. uri)
- await.delay()
+ await.sleep(0.2)
if m.exists(uri) then
m.onWatch('update', uri)
end
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index fe044fc5..09a031cc 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -470,7 +470,7 @@ proto.on('textDocument/completion', function (params)
items[i] = item
end
return {
- isIncomplete = true,
+ isIncomplete = not result.complete,
items = items,
}
end)
@@ -682,6 +682,8 @@ end)
proto.on('textDocument/semanticTokens/full', function (params)
workspace.awaitReady()
+ await.close('textDocument/semanticTokens/full')
+ await.setID('textDocument/semanticTokens/full')
local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_SEMANTIC_FULL, 0.5)
local core = require 'core.semantic-tokens'
local uri = params.textDocument.uri
@@ -697,6 +699,8 @@ end)
proto.on('textDocument/semanticTokens/range', function (params)
workspace.awaitReady()
+ await.close('textDocument/semanticTokens/range')
+ await.setID('textDocument/semanticTokens/range')
local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_SEMANTIC_RANGE, 0.5)
local core = require 'core.semantic-tokens'
local uri = params.textDocument.uri
@@ -722,6 +726,8 @@ proto.on('textDocument/foldingRange', function (params)
if not files.exists(uri) then
return nil
end
+ await.close('textDocument/foldingRange')
+ await.setID('textDocument/foldingRange')
local regions = core(uri)
if not regions then
return nil