From bfcbdd35745ff1fc821781ec2153edfe87c63767 Mon Sep 17 00:00:00 2001 From: CppCXY <812125110@qq.com> Date: Mon, 21 Feb 2022 11:56:42 +0800 Subject: =?UTF-8?q?=E6=8F=90=E4=BE=9B=E9=BB=98=E8=AE=A4=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rd/EmmyLuaCodeStyle | 2 +- script/config/config.lua | 2 ++ script/provider/formatting.lua | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/3rd/EmmyLuaCodeStyle b/3rd/EmmyLuaCodeStyle index 6606b51c..af4cbbdf 160000 --- a/3rd/EmmyLuaCodeStyle +++ b/3rd/EmmyLuaCodeStyle @@ -1 +1 @@ -Subproject commit 6606b51cd417b8b9c9b07711416dbab8b12cded6 +Subproject commit af4cbbdf1da3c5227525288cb88a04f661298297 diff --git a/script/config/config.lua b/script/config/config.lua index e44b9372..a430d623 100644 --- a/script/config/config.lua +++ b/script/config/config.lua @@ -209,6 +209,8 @@ local Template = { ['Lua.window.statusBar'] = Type.Boolean >> true, ['Lua.window.progressBar'] = Type.Boolean >> true, ['Lua.format.enable'] = Type.Boolean >> false, + ['Lua.format.defaultConfig'] = Type.Hash(Type.String, Type.String) + >> {}, ['Lua.IntelliSense.traceLocalSet'] = Type.Boolean >> false, ['Lua.IntelliSense.traceReturn'] = Type.Boolean >> false, ['Lua.IntelliSense.traceBeSetted'] = Type.Boolean >> false, 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('^(.+)/[^/]*$') -- cgit v1.2.3