summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/plugin.lua2
-rw-r--r--script/workspace/require-path.lua6
2 files changed, 7 insertions, 1 deletions
diff --git a/script/plugin.lua b/script/plugin.lua
index 26211a42..80179633 100644
--- a/script/plugin.lua
+++ b/script/plugin.lua
@@ -27,7 +27,7 @@ function m.showError(scp, err)
client.showMessage('Error', lang.script('PLUGIN_RUNTIME_ERROR', scp:get('pluginPath'), err))
end
----@alias plugin.event 'OnSetText' | 'OnTransformAst'
+---@alias plugin.event 'OnSetText' | 'OnTransformAst' | 'ResolveRequire'
---@param event plugin.event
function m.dispatch(event, uri, ...)
diff --git a/script/workspace/require-path.lua b/script/workspace/require-path.lua
index 1507183c..6553212d 100644
--- a/script/workspace/require-path.lua
+++ b/script/workspace/require-path.lua
@@ -5,6 +5,7 @@ local workspace = require "workspace"
local config = require 'config'
local scope = require 'workspace.scope'
local util = require 'utility'
+local plugin = require 'plugin'
---@class require-path
local m = {}
@@ -181,6 +182,11 @@ function mt:searchUrisByRequireName(name)
local searcherMap = {}
local excludes = {}
+ local pluginSuccess, pluginResults = plugin.dispatch('ResolveRequire', self.scp.uri, name)
+ if pluginSuccess and pluginResults ~= nil then
+ return pluginResults
+ end
+
for uri in files.eachFile(self.scp.uri) do
if vm.isMetaFileRequireable(uri) then
local metaName = vm.getMetaName(uri)