diff options
Diffstat (limited to 'script/workspace/require-path.lua')
-rw-r--r-- | script/workspace/require-path.lua | 18 |
1 files changed, 13 insertions, 5 deletions
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 |