@@ -65,22 +65,20 @@ function m.register(method)
6565 end
6666end
6767
68- filewatch .event (function (changes ) --- @async
69- for _ , change in ipairs (changes ) do
70- if (CONFIGPATH and util .stringEndWith (change .path , CONFIGPATH )) then
71- for _ , scp in ipairs (workspace .folders ) do
72- local configPath = workspace .getAbsolutePath (scp .uri , CONFIGPATH )
73- if change .path == configPath then
74- updateConfig (scp .uri )
75- end
68+ filewatch .event (function (ev , path ) --- @async
69+ if (CONFIGPATH and util .stringEndWith (path , CONFIGPATH )) then
70+ for _ , scp in ipairs (workspace .folders ) do
71+ local configPath = workspace .getAbsolutePath (scp .uri , CONFIGPATH )
72+ if path == configPath then
73+ updateConfig (scp .uri )
7674 end
7775 end
78- if util . stringEndWith ( change . path , ' .luarc.json ' ) then
79- for _ , scp in ipairs ( workspace . folders ) do
80- local rcPath = workspace .getAbsolutePath ( scp . uri , ' .luarc.json ' )
81- if change . path == rcPath then
82- updateConfig ( scp . uri )
83- end
76+ end
77+ if util . stringEndWith ( path , ' .luarc.json ' ) then
78+ for _ , scp in ipairs ( workspace .folders ) do
79+ local rcPath = workspace . getAbsolutePath ( scp . uri , ' .luarc.json ' )
80+ if path == rcPath then
81+ updateConfig ( scp . uri )
8482 end
8583 end
8684 end
@@ -102,19 +100,6 @@ m.register 'initialize' {
102100 workspace .create (params .rootUri )
103101 end
104102
105- if params .initializationOptions then
106- if params .initializationOptions .editorConfigFiles then
107- local codeFormat = require " code_format"
108- for _ , config in pairs (params .initializationOptions .editorConfigFiles ) do
109- local status , err = codeFormat .update_config (1 , config .workspace , config .path )
110-
111- if not status and err ~= nil then
112- log .error (err )
113- end
114- end
115- end
116- end
117-
118103 return {
119104 capabilities = cap .getIniter (),
120105 serverInfo = {
@@ -938,6 +923,9 @@ m.register 'textDocument/formatting' {
938923 return nil
939924 end
940925
926+ local pformatting = require ' provider.formatting'
927+ pformatting .updateConfig (uri )
928+
941929 local core = require ' core.formatting'
942930 local edits = core (uri )
943931 if not edits or # edits == 0 then
@@ -965,6 +953,9 @@ m.register 'textDocument/rangeFormatting' {
965953 return nil
966954 end
967955
956+ local pformatting = require ' provider.formatting'
957+ pformatting .updateConfig (uri )
958+
968959 local core = require ' core.rangeformatting'
969960 local edits = core (uri , params .range )
970961 if not edits or # edits == 0 then
@@ -983,24 +974,6 @@ m.register 'textDocument/rangeFormatting' {
983974 end
984975}
985976
986- m .register ' config/editorconfig/update' {
987- --- @async
988- function (params )
989- local codeFormat = require " code_format"
990- local status , err = codeFormat .update_config (params .type , params .source .workspace , params .source .path )
991-
992- if not status and err ~= nil then
993- log .error (err )
994- return
995- end
996-
997- local diagnostic = require ' provider.diagnostic'
998- for _ , scp in ipairs (workspace .folders ) do
999- diagnostic .diagnosticsScope (scp .uri )
1000- end
1001- end
1002- }
1003-
1004977m .register ' textDocument/onTypeFormatting' {
1005978 abortByFileUpdate = true ,
1006979 --- @async
0 commit comments