summaryrefslogtreecommitdiff
path: root/script/workspace/workspace.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-07-19 20:21:27 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-07-19 20:21:27 +0800
commit39af624faa6909ea16f1815e819915c6b95d3bd5 (patch)
tree83a2bda8cc48d88d49896fb2ea96593bf0c156f1 /script/workspace/workspace.lua
parent5750d4484d4f98c8e4e535277066f10452cb0e72 (diff)
downloadlua-language-server-39af624faa6909ea16f1815e819915c6b95d3bd5.zip
path in config supports `~/xxxx`
Diffstat (limited to 'script/workspace/workspace.lua')
-rw-r--r--script/workspace/workspace.lua13
1 files changed, 10 insertions, 3 deletions
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index b98face5..73b6138d 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -13,6 +13,7 @@ local progress = require 'progress'
local define = require "proto.define"
local client = require 'client'
local plugin = require 'plugin'
+local util = require 'utility'
local m = {}
m.type = 'workspace'
@@ -460,6 +461,7 @@ function m.normalize(path)
return (ROOT / 'meta' / '3rd'):string()
end
end)
+ path = util.expandPath(path)
if platform.OS == 'Windows' then
path = path:gsub('[/\\]+', '\\')
:gsub('[/\\]+$', '')
@@ -485,10 +487,15 @@ function m.getAbsolutePath(path)
return path
end
----@param uri uri
+---@param uriOrPath uri|string
---@return string
-function m.getRelativePath(uri)
- local path = furi.decode(uri)
+function m.getRelativePath(uriOrPath)
+ local path
+ if uriOrPath:sub(1, 5) == 'file:' then
+ path = furi.decode(uriOrPath)
+ else
+ path = uriOrPath
+ end
if not m.path then
local relative = m.normalize(path)
return relative:gsub('^[/\\]+', '')