diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-06-18 15:18:43 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-06-18 15:18:43 +0800 |
commit | 8cf347df014f16dc88c5c9edec37f2077e335854 (patch) | |
tree | ffe653ea88d199abf9481debb2c1cdb0b8e57880 /script | |
parent | 5d6ec01a3f2b63317f838337751a5b7bbd400b54 (diff) | |
download | lua-language-server-8cf347df014f16dc88c5c9edec37f2077e335854.zip |
improve table view
Diffstat (limited to 'script')
-rw-r--r-- | script/config.lua | 3 | ||||
-rw-r--r-- | script/core/hover/table.lua | 21 |
2 files changed, 14 insertions, 10 deletions
diff --git a/script/config.lua b/script/config.lua index 50aab037..1287681c 100644 --- a/script/config.lua +++ b/script/config.lua @@ -175,8 +175,7 @@ local ConfigTemplate = { viewString = {true, Boolean}, viewStringMax = {1000, Integer}, viewNumber = {true, Boolean}, - fieldInfer = {3000, Integer}, - previewFields = {100, Integer}, + previewFields = {20, Integer}, enumsLimit = {5, Integer}, }, color = { diff --git a/script/core/hover/table.lua b/script/core/hover/table.lua index 159453e6..8bcce0ae 100644 --- a/script/core/hover/table.lua +++ b/script/core/hover/table.lua @@ -1,9 +1,8 @@ local vm = require 'vm' local util = require 'utility' -local searcher = require 'core.searcher' local config = require 'config' -local lang = require 'language' local infer = require 'core.infer' +local await = require 'await' local function formatKey(key) if type(key) == 'string' then @@ -28,8 +27,8 @@ local function buildAsHash(keys, inferMap, literalMap, reachMax) lines[#lines+1] = (' %s: %s,'):format(formatKey(key), inferView) end end - if reachMax then - lines[#lines+1] = ' ...' + if reachMax > 0 then + lines[#lines+1] = (' ...(+%d)'):format(reachMax) end lines[#lines+1] = '}' return table.concat(lines, '\n') @@ -50,8 +49,8 @@ local function buildAsConst(keys, inferMap, literalMap, reachMax) lines[#lines+1] = (' %s: %s,'):format(formatKey(key), inferView) end end - if reachMax then - lines[#lines+1] = ' ...' + if reachMax > 0 then + lines[#lines+1] = (' ...(+%d)'):format(reachMax) end lines[#lines+1] = '}' return table.concat(lines, '\n') @@ -107,10 +106,16 @@ return function (source) local inferMap = {} local literalMap = {} - local reachMax = maxFields < #keys + local reachMax = #keys - maxFields + if #keys > maxFields then + for i = maxFields + 1, #keys do + keys[i] = nil + end + end local isConsts = true - for i = 1, math.min(maxFields, #keys) do + for i = 1, #keys do + await.delay() local key = keys[i] inferMap[key] = infer.searchAndViewInfers(source, key) literalMap[key] = infer.searchAndViewLiterals(source, key) |