@@ -61,6 +61,12 @@ m.attributes = {}
6161function m .register (method )
6262 return function (attrs )
6363 m .attributes [method ] = attrs
64+ if attrs .preview and not PREVIEW then
65+ return
66+ end
67+ if attrs .capability then
68+ cap .filling (attrs .capability )
69+ end
6470 proto .on (method , attrs [1 ])
6571 end
6672end
@@ -101,7 +107,7 @@ m.register 'initialize' {
101107 end
102108
103109 return {
104- capabilities = cap .getIniter (),
110+ capabilities = cap .getProvider (),
105111 serverInfo = {
106112 name = ' sumneko.lua' ,
107113 },
@@ -261,6 +267,9 @@ m.register 'textDocument/didChange' {
261267}
262268
263269m .register ' textDocument/hover' {
270+ capability = {
271+ hoverProvider = true ,
272+ },
264273 abortByFileUpdate = true ,
265274 --- @async
266275 function (params )
@@ -299,6 +308,9 @@ m.register 'textDocument/hover' {
299308}
300309
301310m .register ' textDocument/definition' {
311+ capability = {
312+ definitionProvider = true ,
313+ },
302314 abortByFileUpdate = true ,
303315 --- @async
304316 function (params )
@@ -338,6 +350,9 @@ m.register 'textDocument/definition' {
338350}
339351
340352m .register ' textDocument/typeDefinition' {
353+ capability = {
354+ typeDefinitionProvider = true ,
355+ },
341356 abortByFileUpdate = true ,
342357 --- @async
343358 function (params )
@@ -377,6 +392,9 @@ m.register 'textDocument/typeDefinition' {
377392}
378393
379394m .register ' textDocument/references' {
395+ capability = {
396+ referencesProvider = true ,
397+ },
380398 abortByFileUpdate = true ,
381399 --- @async
382400 function (params )
@@ -404,6 +422,9 @@ m.register 'textDocument/references' {
404422}
405423
406424m .register ' textDocument/documentHighlight' {
425+ capability = {
426+ documentHighlightProvider = true ,
427+ },
407428 abortByFileUpdate = true ,
408429 function (params )
409430 local core = require ' core.highlight'
@@ -428,6 +449,11 @@ m.register 'textDocument/documentHighlight' {
428449}
429450
430451m .register ' textDocument/rename' {
452+ capability = {
453+ renameProvider = {
454+ prepareProvider = true ,
455+ },
456+ },
431457 abortByFileUpdate = true ,
432458 --- @async
433459 function (params )
@@ -631,6 +657,11 @@ m.register 'completionItem/resolve' {
631657}
632658
633659m .register ' textDocument/signatureHelp' {
660+ capability = {
661+ signatureHelpProvider = {
662+ triggerCharacters = { ' (' , ' ,' },
663+ },
664+ },
634665 abortByFileUpdate = true ,
635666 --- @async
636667 function (params )
@@ -677,6 +708,9 @@ m.register 'textDocument/signatureHelp' {
677708}
678709
679710m .register ' textDocument/documentSymbol' {
711+ capability = {
712+ documentSymbolProvider = true ,
713+ },
680714 abortByFileUpdate = true ,
681715 --- @async
682716 function (params )
@@ -723,6 +757,17 @@ m.register 'textDocument/documentSymbol' {
723757}
724758
725759m .register ' textDocument/codeAction' {
760+ capability = {
761+ codeActionProvider = {
762+ codeActionKinds = {
763+ ' ' ,
764+ ' quickfix' ,
765+ ' refactor.rewrite' ,
766+ ' refactor.extract' ,
767+ },
768+ resolveProvider = false ,
769+ },
770+ },
726771 abortByFileUpdate = true ,
727772 function (params )
728773 local core = require ' core.code-action'
@@ -757,6 +802,17 @@ m.register 'textDocument/codeAction' {
757802}
758803
759804m .register ' workspace/executeCommand' {
805+ capability = {
806+ executeCommandProvider = {
807+ commands = {
808+ ' lua.removeSpace' ,
809+ ' lua.solve' ,
810+ ' lua.jsonToLua' ,
811+ ' lua.setConfig' ,
812+ ' lua.autoRequire' ,
813+ },
814+ },
815+ },
760816 --- @async
761817 function (params )
762818 local command = params .command :gsub (' :.+' , ' ' )
@@ -780,6 +836,9 @@ m.register 'workspace/executeCommand' {
780836}
781837
782838m .register ' workspace/symbol' {
839+ capability = {
840+ workspaceSymbolProvider = true ,
841+ },
783842 abortByFileUpdate = true ,
784843 --- @async
785844 function (params )
@@ -826,7 +885,29 @@ m.register 'textDocument/semanticTokens/full' {
826885 end
827886}
828887
888+ local function toArray (map )
889+ local array = {}
890+ for k in pairs (map ) do
891+ array [# array + 1 ] = k
892+ end
893+ table.sort (array , function (a , b )
894+ return map [a ] < map [b ]
895+ end )
896+ return array
897+ end
898+
899+
829900m .register ' textDocument/semanticTokens/range' {
901+ capability = {
902+ semanticTokensProvider = {
903+ legend = {
904+ tokenTypes = toArray (define .TokenTypes ),
905+ tokenModifiers = toArray (define .TokenModifiers ),
906+ },
907+ range = true ,
908+ full = false ,
909+ },
910+ },
830911 --- @async
831912 function (params )
832913 log .debug (' textDocument/semanticTokens/range' )
@@ -843,6 +924,9 @@ m.register 'textDocument/semanticTokens/range' {
843924}
844925
845926m .register ' textDocument/foldingRange' {
927+ capability = {
928+ foldingRangeProvider = true ,
929+ },
846930 abortByFileUpdate = true ,
847931 --- @async
848932 function (params )
@@ -915,6 +999,10 @@ m.register '$/status/click' {
915999}
9161000
9171001m .register ' textDocument/formatting' {
1002+ capability = {
1003+ documentFormattingProvider = true ,
1004+ },
1005+ preview = true ,
9181006 --- @async
9191007 function (params )
9201008 local uri = files .getRealUri (params .textDocument .uri )
@@ -949,6 +1037,10 @@ m.register 'textDocument/formatting' {
9491037}
9501038
9511039m .register ' textDocument/rangeFormatting' {
1040+ capability = {
1041+ documentRangeFormattingProvider = true ,
1042+ },
1043+ preview = true ,
9521044 --- @async
9531045 function (params )
9541046 local uri = files .getRealUri (params .textDocument .uri )
@@ -983,6 +1075,12 @@ m.register 'textDocument/rangeFormatting' {
9831075}
9841076
9851077m .register ' textDocument/onTypeFormatting' {
1078+ capability = {
1079+ documentOnTypeFormattingProvider = {
1080+ firstTriggerCharacter = ' \n ' ,
1081+ moreTriggerCharacter = nil , -- string[]
1082+ },
1083+ },
9861084 abortByFileUpdate = true ,
9871085 --- @async
9881086 function (params )
0 commit comments