summaryrefslogtreecommitdiff
path: root/script/provider/formatting.lua
diff options
context:
space:
mode:
Diffstat (limited to 'script/provider/formatting.lua')
-rw-r--r--script/provider/formatting.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/script/provider/formatting.lua b/script/provider/formatting.lua
index 9392259e..f73b0dc0 100644
--- a/script/provider/formatting.lua
+++ b/script/provider/formatting.lua
@@ -5,6 +5,7 @@ local fs = require 'bee.filesystem'
local fw = require 'filewatch'
local util = require 'utility'
local diagnostics = require 'provider.diagnostic'
+local config = require 'config'
local loadedUris = {}
@@ -31,10 +32,23 @@ fw.event(function (ev, path)
end
end)
+config.watch(function (uri, key, value)
+ if key == "Lua.format.defaultConfig" then
+ codeFormat.set_default_config(value)
+ end
+end)
+
local m = {}
+m.loadedDefaultConfig = false
+
---@param uri uri
function m.updateConfig(uri)
+ if not m.loadedDefaultConfig then
+ m.loadedDefaultConfig = true
+ codeFormat.set_default_config(config.get(uri, 'Lua.format.defaultConfig'))
+ end
+
local currentUri = uri
while true do
currentUri = currentUri:match('^(.+)/[^/]*$')