html.d.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. declare namespace monaco.languages.html {
  6. export interface HTMLFormatConfiguration {
  7. readonly tabSize: number;
  8. readonly insertSpaces: boolean;
  9. readonly wrapLineLength: number;
  10. readonly unformatted: string;
  11. readonly contentUnformatted: string;
  12. readonly indentInnerHtml: boolean;
  13. readonly preserveNewLines: boolean;
  14. readonly maxPreserveNewLines: number | undefined;
  15. readonly indentHandlebars: boolean;
  16. readonly endWithNewline: boolean;
  17. readonly extraLiners: string;
  18. readonly wrapAttributes: 'auto' | 'force' | 'force-aligned' | 'force-expand-multiline';
  19. }
  20. export interface CompletionConfiguration {
  21. readonly [providerId: string]: boolean;
  22. }
  23. export interface Options {
  24. /**
  25. * Settings for the HTML formatter.
  26. */
  27. readonly format?: HTMLFormatConfiguration;
  28. /**
  29. * Code completion settings.
  30. */
  31. readonly suggest?: CompletionConfiguration;
  32. /**
  33. * Configures the HTML data types known by the HTML langauge service.
  34. */
  35. readonly data?: HTMLDataConfiguration;
  36. }
  37. export interface ModeConfiguration {
  38. /**
  39. * Defines whether the built-in completionItemProvider is enabled.
  40. */
  41. readonly completionItems?: boolean;
  42. /**
  43. * Defines whether the built-in hoverProvider is enabled.
  44. */
  45. readonly hovers?: boolean;
  46. /**
  47. * Defines whether the built-in documentSymbolProvider is enabled.
  48. */
  49. readonly documentSymbols?: boolean;
  50. /**
  51. * Defines whether the built-in definitions provider is enabled.
  52. */
  53. readonly links?: boolean;
  54. /**
  55. * Defines whether the built-in references provider is enabled.
  56. */
  57. readonly documentHighlights?: boolean;
  58. /**
  59. * Defines whether the built-in rename provider is enabled.
  60. */
  61. readonly rename?: boolean;
  62. /**
  63. * Defines whether the built-in color provider is enabled.
  64. */
  65. readonly colors?: boolean;
  66. /**
  67. * Defines whether the built-in foldingRange provider is enabled.
  68. */
  69. readonly foldingRanges?: boolean;
  70. /**
  71. * Defines whether the built-in diagnostic provider is enabled.
  72. */
  73. readonly diagnostics?: boolean;
  74. /**
  75. * Defines whether the built-in selection range provider is enabled.
  76. */
  77. readonly selectionRanges?: boolean;
  78. /**
  79. * Defines whether the built-in documentFormattingEdit provider is enabled.
  80. */
  81. readonly documentFormattingEdits?: boolean;
  82. /**
  83. * Defines whether the built-in documentRangeFormattingEdit provider is enabled.
  84. */
  85. readonly documentRangeFormattingEdits?: boolean;
  86. }
  87. export interface LanguageServiceDefaults {
  88. readonly languageId: string;
  89. readonly modeConfiguration: ModeConfiguration;
  90. readonly onDidChange: IEvent<LanguageServiceDefaults>;
  91. readonly options: Options;
  92. setOptions(options: Options): void;
  93. setModeConfiguration(modeConfiguration: ModeConfiguration): void;
  94. }
  95. export const htmlLanguageService: LanguageServiceRegistration;
  96. export const htmlDefaults: LanguageServiceDefaults;
  97. export const handlebarLanguageService: LanguageServiceRegistration;
  98. export const handlebarDefaults: LanguageServiceDefaults;
  99. export const razorLanguageService: LanguageServiceRegistration;
  100. export const razorDefaults: LanguageServiceDefaults;
  101. export interface LanguageServiceRegistration extends IDisposable {
  102. readonly defaults: LanguageServiceDefaults;
  103. }
  104. /**
  105. * Registers a new HTML language service for the languageId.
  106. * Note: 'html', 'handlebar' and 'razor' are registered by default.
  107. *
  108. * Use this method to register additional language ids with a HTML service.
  109. * The language server has to be registered before an editor model is opened.
  110. */
  111. export function registerHTMLLanguageService(languageId: string, options?: Options, modeConfiguration?: ModeConfiguration): LanguageServiceRegistration;
  112. export interface HTMLDataConfiguration {
  113. /**
  114. * Defines whether the standard HTML tags and attributes are shown
  115. */
  116. readonly useDefaultDataProvider?: boolean;
  117. /**
  118. * Provides a set of custom data providers.
  119. */
  120. readonly dataProviders?: {
  121. [providerId: string]: HTMLDataV1;
  122. };
  123. }
  124. /**
  125. * Custom HTML tags attributes and attribute values
  126. * https://github.com/microsoft/vscode-html-languageservice/blob/main/docs/customData.md
  127. */
  128. export interface HTMLDataV1 {
  129. readonly version: 1 | 1.1;
  130. readonly tags?: ITagData[];
  131. readonly globalAttributes?: IAttributeData[];
  132. readonly valueSets?: IValueSet[];
  133. }
  134. export interface IReference {
  135. readonly name: string;
  136. readonly url: string;
  137. }
  138. export interface ITagData {
  139. readonly name: string;
  140. readonly description?: string | MarkupContent;
  141. readonly attributes: IAttributeData[];
  142. readonly references?: IReference[];
  143. }
  144. export interface IAttributeData {
  145. readonly name: string;
  146. readonly description?: string | MarkupContent;
  147. readonly valueSet?: string;
  148. readonly values?: IValueData[];
  149. readonly references?: IReference[];
  150. }
  151. export interface IValueData {
  152. readonly name: string;
  153. readonly description?: string | MarkupContent;
  154. readonly references?: IReference[];
  155. }
  156. export interface IValueSet {
  157. readonly name: string;
  158. readonly values: IValueData[];
  159. }
  160. export interface MarkupContent {
  161. readonly kind: MarkupKind;
  162. readonly value: string;
  163. }
  164. export type MarkupKind = 'plaintext' | 'markdown';
  165. }