summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-07-08 19:51:10 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-07-08 19:51:10 +0800
commitae3a20cfd5ea89919326a6499c5a3c93fdfe2120 (patch)
treeb4b337b82bda3a14f300ab30862efd12b6e10650 /script/core
parent5354d8c339ddb6487f3c0ec1b240eb3e93d19585 (diff)
downloadlua-language-server-ae3a20cfd5ea89919326a6499c5a3c93fdfe2120.zip
fix #187
Diffstat (limited to 'script/core')
-rw-r--r--script/core/completion.lua7
-rw-r--r--script/core/hover/hover.lua22
2 files changed, 17 insertions, 12 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua
index d0301d3a..5af72de0 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -8,6 +8,7 @@ local matchKey = require 'core.matchKey'
local parser = require 'parser'
local lang = require 'language'
local snippet = require 'core.snippet'
+local uric = require 'uri'
local State
local CompletionItemKind = {
@@ -674,11 +675,11 @@ local function searchInRequire(vm, source, callback)
if not vm.lsp then
return
end
- local ws = vm.lsp:findWorkspaceFor(vm.uri)
- if not ws then
+ if source.type ~= 'string' then
return
end
- if source.type ~= 'string' then
+ local ws = vm.lsp:findWorkspaceFor(vm.uri)
+ if not ws then
return
end
local list, map = ws:matchPath(vm.uri, source[1])
diff --git a/script/core/hover/hover.lua b/script/core/hover/hover.lua
index 4270f418..5140edb2 100644
--- a/script/core/hover/hover.lua
+++ b/script/core/hover/hover.lua
@@ -5,6 +5,7 @@ local getFunctionHoverAsEmmy = require 'core.hover.emmy_function'
local buildValueName = require 'core.hover.name'
local lang = require 'language'
local config = require 'config'
+local uric = require 'uri'
local OriginTypes = {
['any'] = true,
@@ -300,16 +301,19 @@ local function hoverAsTargetUri(source, lsp)
return nil
end
local ws = lsp:findWorkspaceFor(uri)
- if not ws then
- return nil
- end
- local path = ws:relativePathByUri(uri)
- if not path then
- return nil
+ if ws then
+ local path = ws:relativePathByUri(uri)
+ if not path then
+ return nil
+ end
+ return {
+ description = ('[%s](%s)'):format(path:string(), uri),
+ }
+ else
+ return {
+ description = ('[%s](%s)'):format(uric.decode(uri):string(), uri),
+ }
end
- return {
- description = ('[%s](%s)'):format(path:string(), uri),
- }
end
local function hoverAsString(source)