summaryrefslogtreecommitdiff
path: root/script-beta
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-09-28 20:48:40 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-09-28 20:48:40 +0800
commit3d9cc0ff63d2023e30b9bdc1b1146d7b5c75970e (patch)
tree57bf5544b0e40c497d009480c9d83e53c3f06130 /script-beta
parent490acd17d163c89d7e6e88a714849731cd9d2e88 (diff)
downloadlua-language-server-3d9cc0ff63d2023e30b9bdc1b1146d7b5c75970e.zip
require 的自动完成处理 library
Diffstat (limited to 'script-beta')
-rw-r--r--script-beta/provider/diagnostic.lua3
-rw-r--r--script-beta/service/service.lua2
-rw-r--r--script-beta/workspace/require-path.lua7
3 files changed, 11 insertions, 1 deletions
diff --git a/script-beta/provider/diagnostic.lua b/script-beta/provider/diagnostic.lua
index 89b70061..64d83c89 100644
--- a/script-beta/provider/diagnostic.lua
+++ b/script-beta/provider/diagnostic.lua
@@ -149,6 +149,9 @@ function m.diagnostics(uri)
end
function m.doDiagnostic(uri)
+ if files.isLibrary(uri) then
+ return
+ end
local ast = files.getAst(uri)
if not ast then
m.clear(uri)
diff --git a/script-beta/service/service.lua b/script-beta/service/service.lua
index 119e70aa..11cc7b19 100644
--- a/script-beta/service/service.lua
+++ b/script-beta/service/service.lua
@@ -110,7 +110,7 @@ function m.reportProto()
end
local lines = {}
- lines[#lines+1] = ' --------------- Cache ---------------'
+ lines[#lines+1] = ' --------------- Proto ---------------'
lines[#lines+1] = (' Holdon: %d'):format(holdon)
lines[#lines+1] = (' Waiting: %d'):format(waiting)
return table.concat(lines, '\n')
diff --git a/script-beta/workspace/require-path.lua b/script-beta/workspace/require-path.lua
index 79642a7f..cfdc0455 100644
--- a/script-beta/workspace/require-path.lua
+++ b/script-beta/workspace/require-path.lua
@@ -1,4 +1,6 @@
local platform = require 'bee.platform'
+local files = require 'files'
+local furi = require 'file-uri'
local m = {}
m.cache = {}
@@ -24,10 +26,15 @@ end
function m.getVisiblePath(path, searchers)
path = path:gsub('^[/\\]+', '')
+ local uri = furi.encode(path)
+ local libraryPath = files.getLibraryPath(uri)
if not m.cache[path] then
local result = {}
m.cache[path] = result
local pos = 1
+ if libraryPath then
+ pos = #libraryPath + 2
+ end
repeat
local cutedPath = path:sub(pos)
local head