diff options
Diffstat (limited to 'script')
-rw-r--r-- | script/provider/provider.lua | 25 | ||||
-rw-r--r-- | script/workspace/workspace.lua | 12 |
2 files changed, 33 insertions, 4 deletions
diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 5b1200cc..0249ffca 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -293,7 +293,15 @@ end) proto.on('textDocument/hover', function (params) await.close 'hover' await.setID 'hover' - workspace.awaitReady() + if not workspace.isReady() then + local count, max = workspace.getLoadProcess() + return { + contents = { + value = lang.script('HOVER_WS_LOADING', count, max), + kind = 'markdown', + } + } + end local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_HOVER, 0.5) local core = require 'core.hover' local doc = params.textDocument @@ -439,7 +447,20 @@ end) proto.on('textDocument/completion', function (params) await.close 'completion' await.setID 'completion' - workspace.awaitReady() + if not workspace.isReady() then + local count, max = workspace.getLoadProcess() + return { + { + label = lang.script('HOVER_WS_LOADING', count, max),textEdit = { + range = { + start = params.position, + ['end'] = params.position, + }, + newText = '', + }, + } + } + end local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_COMPLETION, 0.5) --log.info(util.dump(params)) local core = require 'core.completion' diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua index 5350369e..5ffcac5c 100644 --- a/script/workspace/workspace.lua +++ b/script/workspace/workspace.lua @@ -9,8 +9,6 @@ local await = require 'await' local proto = require 'proto.proto' local lang = require 'language' local library = require 'library' -local sp = require 'bee.subprocess' -local timer = require 'timer' local progress = require 'progress' local define = require "proto.define" @@ -19,6 +17,8 @@ m.type = 'workspace' m.nativeVersion = -1 m.libraryVersion = -1 m.nativeMatcher = nil +m.fileLoaded = 0 +m.fileFound = 0 m.waitingReady = {} m.requireCache = {} m.cache = {} @@ -282,6 +282,8 @@ function m.awaitPreload() diagnostic.pause() m.libraryMatchers = nil m.nativeMatcher = nil + m.fileLoaded = 0 + m.fileFound = 0 m.cache = {} local progressBar <close> = progress.create(lang.script.WORKSPACE_LOADING) local progressData = { @@ -291,6 +293,8 @@ function m.awaitPreload() update = function (self) progressBar:setMessage(('%d/%d'):format(self.read, self.max)) progressBar:setPercentage(self.read / self.max * 100) + m.fileLoaded = self.read + m.fileFound = self.max end } log.info('Preload start.') @@ -501,6 +505,10 @@ function m.isReady() return m.ready == true end +function m.getLoadProcess() + return m.fileLoaded, m.fileFound +end + files.watch(function (ev, uri) if ev == 'close' and m.isIgnored(uri) |