diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-08-23 11:08:21 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-08-23 11:08:21 +0800 |
commit | 0d902298c0b4b26978e765665431d6d55d4b9b90 (patch) | |
tree | 3d611db4b23ad75fbd98cc99dec30a680ccfa7d6 /script | |
parent | 04b6327f39fc5354caa984b666644333ab52f9cc (diff) | |
download | lua-language-server-0d902298c0b4b26978e765665431d6d55d4b9b90.zip |
resolve #518 `Lua.completion.requireSeparator`
Diffstat (limited to 'script')
-rw-r--r-- | script/config/config.lua | 2 | ||||
-rw-r--r-- | script/provider/completion.lua | 2 | ||||
-rw-r--r-- | script/workspace/require-path.lua | 18 |
3 files changed, 16 insertions, 6 deletions
diff --git a/script/config/config.lua b/script/config/config.lua index 91f0a00b..297d70ef 100644 --- a/script/config/config.lua +++ b/script/config/config.lua @@ -184,6 +184,7 @@ local Template = { ['Lua.completion.showWord'] = Type.String >> 'Enable', ['Lua.completion.autoRequire'] = Type.Boolean >> true, ['Lua.completion.showParams'] = Type.Boolean >> true, + ['Lua.completion.requireSeparator'] = Type.String >> '.', ['Lua.signatureHelp.enable'] = Type.Boolean >> true, ['Lua.hover.enable'] = Type.Boolean >> true, ['Lua.hover.viewString'] = Type.Boolean >> true, @@ -324,6 +325,7 @@ function m.update(new) expand(new) end +---@param callback fun(key: string, value: any, oldValue: any) function m.watch(callback) m.watchList[#m.watchList+1] = callback end diff --git a/script/provider/completion.lua b/script/provider/completion.lua index 92546571..f1698249 100644 --- a/script/provider/completion.lua +++ b/script/provider/completion.lua @@ -6,7 +6,7 @@ local config = require 'config' local isEnable = false local function allWords() - local str = '\t\n.:(\'"[,#*@|=-{ ' + local str = '\t\n.:(\'"[,#*@|=-{/\\ ' local list = {} for c in str:gmatch '.' do list[#list+1] = c diff --git a/script/workspace/require-path.lua b/script/workspace/require-path.lua index 096b7f75..2ec2918c 100644 --- a/script/workspace/require-path.lua +++ b/script/workspace/require-path.lua @@ -1,19 +1,21 @@ -local platform = require 'bee.platform' -local files = require 'files' -local furi = require 'file-uri' +local platform = require 'bee.platform' +local files = require 'files' +local furi = require 'file-uri' local workspace = require "workspace" +local config = require 'config' local m = {} m.cache = {} --- `aaa/bbb/ccc.lua` 与 `?.lua` 将返回 `aaa.bbb.cccc` local function getOnePath(path, searcher) + local separator = config.get 'Lua.completion.requireSeparator' local stemPath = path : gsub('%.[^%.]+$', '') - : gsub('[/\\]+', '.') + : gsub('[/\\%.]+', separator) local stemSearcher = searcher : gsub('%.[^%.]+$', '') - : gsub('[/\\]+', '.') + : gsub('[/\\%.]+', separator) local start = stemSearcher:match '()%?' or 1 for pos = start, #stemPath do local word = stemPath:sub(start, pos) @@ -88,4 +90,10 @@ files.watch(function (ev) end end) +config.watch(function (key, value, oldValue) + if key == 'Lua.completion.requireSeparator' then + m.flush() + end +end) + return m |