diff options
author | sumneko <sumneko@hotmail.com> | 2019-04-12 16:57:07 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-04-12 16:57:07 +0800 |
commit | 6e955b1f5ba080ae7cd1bc7a664dbc4c5511ad13 (patch) | |
tree | 138cb9deda0f2528746c39b6ddca0547829a7c32 | |
parent | cc998b964d577832bc6ddbd5d17560391497fb76 (diff) | |
download | lua-language-server-6e955b1f5ba080ae7cd1bc7a664dbc4c5511ad13.zip |
预加载跳过大文件的配置
-rw-r--r-- | .vscode/settings.json | 3 | ||||
-rw-r--r-- | package.json | 6 | ||||
-rw-r--r-- | server/src/config.lua | 1 | ||||
-rw-r--r-- | server/src/service.lua | 5 |
4 files changed, 12 insertions, 3 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json index a18e43b3..6941e67b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,5 +12,6 @@ "Lua.diagnostics.disable": [ ], "Lua.runtime.version": "Lua 5.4", - "Lua.workspace.maxPreload": 400 + "Lua.workspace.maxPreload": 400, + "Lua.workspace.preloadFileSize": 1000 } diff --git a/package.json b/package.json index dacc1930..ca3376ae 100644 --- a/package.json +++ b/package.json @@ -88,6 +88,12 @@ "type": "integer", "default": 300, "description": "Max preloaded files.\n最大预加载文件数。" + }, + "Lua.workspace.preloadFileSize": { + "scope": "resource", + "type": "integer", + "default": 100, + "description": "Skip files larger than this value (KB) when preloading.\n预加载时跳过大小大于该值(KB)的文件。" } } } diff --git a/server/src/config.lua b/server/src/config.lua index 79a7d98d..c155eab2 100644 --- a/server/src/config.lua +++ b/server/src/config.lua @@ -52,6 +52,7 @@ local Template = { ignoreSubmodules= {true, Boolean}, useGitIgnore = {true, Boolean}, maxPreload = {300, Integer}, + preloadFileSize = {100, Integer}, } } diff --git a/server/src/service.lua b/server/src/service.lua index f14b0a9b..d35256bf 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -219,8 +219,9 @@ function mt:readText(uri, path, buf, compiled) log.debug('No file: ', path) return end - if #text > 100000 then - log.info(('Skip large file, size: %.3f KB: %s'):format(#text / 1000.0, uri)) + local size = #text / 1000.0 + if size > config.config.workspace.preloadFileSize then + log.info(('Skip large file, size: %.3f KB: %s'):format(size, uri)) return end if self:getCachedFileCount() >= config.config.workspace.maxPreload then |