diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-01-27 20:09:57 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-01-27 20:09:57 +0800 |
commit | 9da178541151a664dd131164bb1c7c2393da3172 (patch) | |
tree | 4abbf35f9c0afdd278c8e2f14a822ec8721dc57a /script | |
parent | 2d63a946faebbda3fc7f4a1e87d8e8453fc727eb (diff) | |
download | lua-language-server-9da178541151a664dd131164bb1c7c2393da3172.zip |
Organize the startup process
Diffstat (limited to 'script')
-rw-r--r-- | script/files.lua | 8 | ||||
-rw-r--r-- | script/provider/diagnostic.lua | 3 | ||||
-rw-r--r-- | script/provider/provider.lua | 22 |
3 files changed, 19 insertions, 14 deletions
diff --git a/script/files.lua b/script/files.lua index 52f2b18a..88ee466c 100644 --- a/script/files.lua +++ b/script/files.lua @@ -11,7 +11,7 @@ local plugin = require 'plugin' local util = require 'utility' local guide = require 'parser.guide' local smerger = require 'string-merger' -local plugin = require 'plugin' +local progress = require "progress" local m = {} @@ -289,6 +289,7 @@ function m.eachDll() end function m.compileAst(uri, text) + local ws = require 'workspace' if not m.isOpen(uri) and #text >= config.config.workspace.preloadFileSize * 1000 then if not m.notifyCache['preloadFileSize'] then m.notifyCache['preloadFileSize'] = {} @@ -298,11 +299,10 @@ function m.compileAst(uri, text) m.notifyCache['preloadFileSize'][uri] = true m.notifyCache['skipLargeFileCount'] = m.notifyCache['skipLargeFileCount'] + 1 if m.notifyCache['skipLargeFileCount'] <= 3 then - local ws = require 'workspace' proto.notify('window/showMessage', { type = 3, message = lang.script('WORKSPACE_SKIP_LARGE_FILE' - , ws.getRelativePath(uri) + , ws.getRelativePath(m.getOriginUri(uri)) , config.config.workspace.preloadFileSize , #text / 1000 ), @@ -311,6 +311,8 @@ function m.compileAst(uri, text) end return nil end + local prog <close> = progress.create('正在编译', 0.5) + prog:setMessage(ws.getRelativePath(m.getOriginUri(uri))) local clock = os.clock() local state, err = parser:compile(text , 'lua' diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua index 9ab57d9d..b561c7e4 100644 --- a/script/provider/diagnostic.lua +++ b/script/provider/diagnostic.lua @@ -176,6 +176,9 @@ function m.doDiagnostic(uri) await.delay() + local prog <close> = progress.create('正在诊断', 0.5) + prog:setMessage(ws.getRelativePath(files.getOriginUri(uri))) + local ast = files.getAst(uri) if not ast then m.clear(uri) diff --git a/script/provider/provider.lua b/script/provider/provider.lua index e65fb440..3447c9cd 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -98,7 +98,7 @@ proto.on('initialize', function (params) end) proto.on('initialized', function (params) - local _ <close> = progress.create('正在初始化...', 1) + local _ <close> = progress.create('正在初始化...', 0.5) updateConfig() proto.awaitRequest('client/registerCapability', { registrations = { @@ -218,8 +218,8 @@ end) proto.on('textDocument/hover', function (params) await.close 'hover' await.setID 'hover' - local _ <close> = progress.create('正在处理悬浮提示...', 1) workspace.awaitReady() + local _ <close> = progress.create('正在处理悬浮提示...', 0.5) local core = require 'core.hover' local doc = params.textDocument local uri = doc.uri @@ -248,8 +248,8 @@ proto.on('textDocument/hover', function (params) end) proto.on('textDocument/definition', function (params) - local _ <close> = progress.create('正在处理转到定义...', 1) workspace.awaitReady() + local _ <close> = progress.create('正在处理转到定义...', 0.5) local core = require 'core.definition' local uri = params.textDocument.uri if not files.exists(uri) then @@ -277,8 +277,8 @@ proto.on('textDocument/definition', function (params) end) proto.on('textDocument/references', function (params) - local _ <close> = progress.create('正在处理转到引用...', 1) workspace.awaitReady() + local _ <close> = progress.create('正在处理转到引用...', 0.5) local core = require 'core.reference' local uri = params.textDocument.uri if not files.exists(uri) then @@ -321,8 +321,8 @@ proto.on('textDocument/documentHighlight', function (params) end) proto.on('textDocument/rename', function (params) - local _ <close> = progress.create('正在处理重命名...', 1) workspace.awaitReady() + local _ <close> = progress.create('正在处理重命名...', 0.5) local core = require 'core.rename' local uri = params.textDocument.uri if not files.exists(uri) then @@ -365,8 +365,8 @@ proto.on('textDocument/prepareRename', function (params) end) proto.on('textDocument/completion', function (params) - local _ <close> = progress.create('正在处理自动完成...', 1) workspace.awaitReady() + local _ <close> = progress.create('正在处理自动完成...', 0.5) --log.info(util.dump(params)) local core = require 'core.completion' --log.debug('textDocument/completion') @@ -490,8 +490,8 @@ proto.on('textDocument/signatureHelp', function (params) if not config.config.signatureHelp.enable then return nil end - local _ <close> = progress.create('正在处理参数提示...', 1) workspace.awaitReady() + local _ <close> = progress.create('正在处理参数提示...', 0.5) local uri = params.textDocument.uri if not files.exists(uri) then return nil @@ -531,8 +531,8 @@ proto.on('textDocument/signatureHelp', function (params) end) proto.on('textDocument/documentSymbol', function (params) - local _ <close> = progress.create('正在处理文件符号...', 1) local core = require 'core.document-symbol' + local _ <close> = progress.create('正在处理文件符号...', 0.5) local uri = params.textDocument.uri while not files.exists(uri) do await.sleep(0.1) @@ -616,8 +616,8 @@ proto.on('workspace/executeCommand', function (params) end) proto.on('workspace/symbol', function (params) - local _ <close> = progress.create('正在处理工作区符号...', 1) workspace.awaitReady() + local _ <close> = progress.create('正在处理工作区符号...', 0.5) local core = require 'core.workspace-symbol' await.close('workspace/symbol') @@ -649,8 +649,8 @@ end) proto.on('textDocument/semanticTokens/full', function (params) - local _ <close> = progress.create('正在处理全量语义着色...', 1) workspace.awaitReady() + local _ <close> = progress.create('正在处理全量语义着色...', 0.5) local core = require 'core.semantic-tokens' local uri = params.textDocument.uri log.debug('semanticTokens/full', uri) @@ -666,8 +666,8 @@ proto.on('textDocument/semanticTokens/full', function (params) end) proto.on('textDocument/semanticTokens/range', function (params) - local _ <close> = progress.create('正在处理差量语义着色...', 1) workspace.awaitReady() + local _ <close> = progress.create('正在处理差量语义着色...', 0.5) local core = require 'core.semantic-tokens' local uri = params.textDocument.uri log.debug('semanticTokens/range', uri) |