summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-08-05 14:42:13 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-08-05 14:42:13 +0800
commit977efc2804c840456edeac2af95ccf68f815d88e (patch)
tree4b743e160a92e7386ad089084e0ff97099a9bb5d /script
parentf3377e1a6bf0cb0d99a44790613ac10c774579b5 (diff)
downloadlua-language-server-977efc2804c840456edeac2af95ccf68f815d88e.zip
#202 增加一个设置可以调整显示建议相关代码片段
Diffstat (limited to 'script')
-rw-r--r--script/config.lua1
-rw-r--r--script/method/completionItem/resolve.lua8
2 files changed, 8 insertions, 1 deletions
diff --git a/script/config.lua b/script/config.lua
index 4c83e511..51f090fe 100644
--- a/script/config.lua
+++ b/script/config.lua
@@ -123,6 +123,7 @@ local ConfigTemplate = {
enable = {true, Boolean},
callSnippet = {'Disable', String},
keywordSnippet = {'Replace', String},
+ displayContext = {6, Integer},
},
signatureHelp = {
enable = {true, Boolean},
diff --git a/script/method/completionItem/resolve.lua b/script/method/completionItem/resolve.lua
index 7d18288e..0e55d311 100644
--- a/script/method/completionItem/resolve.lua
+++ b/script/method/completionItem/resolve.lua
@@ -1,4 +1,10 @@
+local config = require 'config'
+
return function (lsp, item)
+ local context = config.config.completion.displayContext
+ if context <= 0 then
+ return item
+ end
if not item.data then
return item
end
@@ -10,7 +16,7 @@ return function (lsp, item)
end
local row = lines:rowcol(offset)
local firstRow = lines[row]
- local lastRow = lines[math.min(row + 5, #lines)]
+ local lastRow = lines[math.min(row + context - 1, #lines)]
local snip = text:sub(firstRow.start, lastRow.finish)
local document = ([[
%s