diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-09-16 22:02:33 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-09-16 22:02:33 +0800 |
commit | ac4ff86df32af5b0c0c2c730e5374130326f6129 (patch) | |
tree | 674e1907d70d49b81a1f91ec4f2cd1e742bf4034 /server/src/vm/vm.lua | |
parent | 6285173c57a6a644f598dd91defa4d499176303f (diff) | |
download | lua-language-server-ac4ff86df32af5b0c0c2c730e5374130326f6129.zip |
暂存
Diffstat (limited to 'server/src/vm/vm.lua')
-rw-r--r-- | server/src/vm/vm.lua | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua index 7bae408c..6717a403 100644 --- a/server/src/vm/vm.lua +++ b/server/src/vm/vm.lua @@ -10,6 +10,7 @@ local libraryBuilder = require 'vm.library' local emmyMgr = require 'emmy.manager' local config = require 'config' local mt = require 'vm.manager' +local plugin = require 'plugin' require 'vm.module' require 'vm.raw' @@ -171,12 +172,14 @@ function mt:tryRequireOne(strValue, mode) return nil end local str = strValue:getLiteral() + local strSource = strValue:getSource() + if not strSource then + return nil + end + local raw = self.file:getText():sub(strSource.start, strSource.finish) + str = plugin.call('OnRequirePath', str, raw) or str if type(str) == 'string' then -- 支持 require 'xxx' 的转到定义 - local strSource = strValue:getSource() - if not strSource then - return nil - end self:instantSource(strSource) local uri if mode == 'require' then @@ -1307,7 +1310,7 @@ local function compile(vm, ast, lsp, uri) return vm end -return function (ast, lsp, uri) +return function (ast, lsp, uri, file) if not ast then return nil, 'Ast failed' end @@ -1321,6 +1324,7 @@ return function (ast, lsp, uri) emmyMgr = lsp and lsp.emmy or emmyMgr(), lsp = lsp, uri = uri or '', + file = file, }, mt) local suc, res = xpcall(compile, log.error, vm, ast, lsp, uri) if not suc then |