Skip to content

Commit 85b0582

Browse files
committed
Support statically registering format support
Some clients, like Neovim, do not support dynamic registration of formatting and range formatting. In this case, to tell the client that formatting is supported, the response to `initialized`, which contains the `ServerCapabilities`, should mark formatting and range formatting as supported. Fixes #1031 Signed-off-by: David Thompson <[email protected]>
1 parent 6c66fdf commit 85b0582

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/yamlServerInit.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ export class YAMLServerInit {
7878
);
7979
this.yamlSettings.clientDynamicRegisterSupport = !!(
8080
this.yamlSettings.capabilities.textDocument &&
81-
this.yamlSettings.capabilities.textDocument.rangeFormatting &&
82-
this.yamlSettings.capabilities.textDocument.rangeFormatting.dynamicRegistration
81+
this.yamlSettings.capabilities.textDocument.formatting &&
82+
this.yamlSettings.capabilities.textDocument.formatting.dynamicRegistration
8383
);
8484
this.yamlSettings.hasWorkspaceFolderCapability =
8585
this.yamlSettings.capabilities.workspace && !!this.yamlSettings.capabilities.workspace.workspaceFolders;
@@ -102,7 +102,7 @@ export class YAMLServerInit {
102102
completionProvider: { resolveProvider: false },
103103
hoverProvider: true,
104104
documentSymbolProvider: true,
105-
documentFormattingProvider: false,
105+
documentFormattingProvider: !this.yamlSettings.clientDynamicRegisterSupport,
106106
documentOnTypeFormattingProvider: {
107107
firstTriggerCharacter: '\n',
108108
},

0 commit comments

Comments
 (0)