summaryrefslogtreecommitdiff
path: root/script/workspace
diff options
context:
space:
mode:
Diffstat (limited to 'script/workspace')
-rw-r--r--script/workspace/scope.lua21
-rw-r--r--script/workspace/workspace.lua8
2 files changed, 11 insertions, 18 deletions
diff --git a/script/workspace/scope.lua b/script/workspace/scope.lua
index 16c9500d..8bf91c71 100644
--- a/script/workspace/scope.lua
+++ b/script/workspace/scope.lua
@@ -37,6 +37,7 @@ end
---@param v any
function mt:set(k, v)
self._data[k] = v
+ return v
end
---@param k string
@@ -45,16 +46,6 @@ function mt:get(k)
return self._data[k]
end
----@class scope.manager
-local m = {}
-
----@type scope[]
-m.folders = {}
----@type scope
-m.override = nil
----@type scope
-m.fallback = nil
-
---@param scopeType scope.type
---@return scope
local function createScope(scopeType)
@@ -67,6 +58,14 @@ local function createScope(scopeType)
return scope
end
+---@class scope.manager
+local m = {}
+
+---@type scope[]
+m.folders = {}
+m.override = createScope 'override'
+m.fallback = createScope 'fallback'
+
---@param uri uri
---@return scope
function m.createFolder(uri)
@@ -115,6 +114,4 @@ function m.getLinkedScope(uri)
end
end
-m.fallback = createScope 'fallback'
-
return m
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index dbe2f346..a1f57a7d 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -15,6 +15,7 @@ local client = require 'client'
local plugin = require 'plugin'
local util = require 'utility'
local fw = require 'filewatch'
+local scope = require 'workspace.scope'
---@class workspace
local m = {}
@@ -29,8 +30,6 @@ m.requireCache = {}
m.cache = {}
m.watchers = {}
m.matchOption = {}
----@type {uri: uri, path: string}[]
-m.folders = {}
function m.initRoot(uri)
m.rootUri = uri
@@ -47,11 +46,8 @@ end
function m.create(uri)
log.info('Workspace create: ', uri)
local path = m.normalize(furi.decode(uri))
- m.folders[#m.folders+1] = {
- uri = uri,
- path = path,
- }
fw.watch(path)
+ scope.createFolder(uri)
end
local globInteferFace = {