diff options
author | Artem Dzhemesiuk <programming@zziger.me> | 2024-03-30 02:40:48 +0100 |
---|---|---|
committer | Artem Dzhemesiuk <programming@zziger.me> | 2024-03-30 02:40:48 +0100 |
commit | cf9e38657db9878a23a911bf811536b73b164715 (patch) | |
tree | def13fa68f5647727a5a4cfe1b1a9cb97b242c95 | |
parent | e930179bbd6b3eb26721a676303e0e27cdb29290 (diff) | |
download | lua-language-server-cf9e38657db9878a23a911bf811536b73b164715.zip |
Allow plugins to resolve require paths
-rw-r--r-- | script/plugin.lua | 2 | ||||
-rw-r--r-- | script/workspace/require-path.lua | 6 |
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) |