volar-service-html 0.0.31 → 0.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +2 -3
  2. package/index.js +15 -14
  3. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Disposable, DocumentSelector, Result, ServiceContext, ServicePlugin } from '@volar/language-service';
1
+ import type { Disposable, DocumentSelector, FormattingOptions, Result, ServiceContext, ServicePlugin } from '@volar/language-service';
2
2
  import * as html from 'vscode-html-languageservice';
3
3
  import { TextDocument } from 'vscode-languageserver-textdocument';
4
4
  export interface Provide {
@@ -9,12 +9,11 @@ export interface Provide {
9
9
  export declare function create({ documentSelector, useDefaultDataProvider, getDocumentContext, isFormattingEnabled, isAutoCreateQuotesEnabled, isAutoClosingTagsEnabled, getFormattingOptions, getCompletionConfiguration, getHoverSettings, getCustomData, onDidChangeCustomData, }?: {
10
10
  documentSelector?: DocumentSelector;
11
11
  useDefaultDataProvider?: boolean;
12
- useCustomDataProviders?: boolean;
13
12
  isFormattingEnabled?(document: TextDocument, context: ServiceContext): Result<boolean>;
14
13
  isAutoCreateQuotesEnabled?(document: TextDocument, context: ServiceContext): Result<boolean>;
15
14
  isAutoClosingTagsEnabled?(document: TextDocument, context: ServiceContext): Result<boolean>;
16
15
  getDocumentContext?(context: ServiceContext): html.DocumentContext;
17
- getFormattingOptions?(document: TextDocument, context: ServiceContext): Result<html.HTMLFormatConfiguration | undefined>;
16
+ getFormattingOptions?(document: TextDocument, options: FormattingOptions, context: ServiceContext): Result<html.HTMLFormatConfiguration>;
18
17
  getCompletionConfiguration?(document: TextDocument, context: ServiceContext): Result<html.CompletionConfiguration | undefined>;
19
18
  getHoverSettings?(document: TextDocument, context: ServiceContext): Result<html.HoverSettings | undefined>;
20
19
  getCustomData?(context: ServiceContext): Result<html.IHTMLDataProvider[]>;
package/index.js CHANGED
@@ -29,8 +29,20 @@ function create({ documentSelector = ['html'], useDefaultDataProvider = true, ge
29
29
  return await context.env.getConfiguration?.('html.autoCreateQuotes') ?? true;
30
30
  }, isAutoClosingTagsEnabled = async (_document, context) => {
31
31
  return await context.env.getConfiguration?.('html.autoClosingTags') ?? true;
32
- }, getFormattingOptions = async (_document, context) => {
33
- return await context.env.getConfiguration?.('html.format');
32
+ }, getFormattingOptions = async (_document, options, context) => {
33
+ const formatSettings = {
34
+ ...options,
35
+ endWithNewline: options.insertFinalNewline ? true : options.trimFinalNewlines ? false : undefined,
36
+ ...await context.env.getConfiguration?.('html.format'),
37
+ };
38
+ // https://github.com/microsoft/vscode/blob/a8f73340be02966c3816a2f23cb7e446a3a7cb9b/extensions/html-language-features/server/src/modes/htmlMode.ts#L47-L51
39
+ if (formatSettings.contentUnformatted) {
40
+ formatSettings.contentUnformatted = formatSettings.contentUnformatted + ',script';
41
+ }
42
+ else {
43
+ formatSettings.contentUnformatted = 'script';
44
+ }
45
+ return formatSettings;
34
46
  }, getCompletionConfiguration = async (_document, context) => {
35
47
  return await context.env.getConfiguration?.('html.completion');
36
48
  }, getHoverSettings = async (_document, context) => {
@@ -163,18 +175,7 @@ function create({ documentSelector = ['html'], useDefaultDataProvider = true, ge
163
175
  end: document.positionAt(endOffset),
164
176
  };
165
177
  }
166
- const formatSettings = {
167
- ...options,
168
- endWithNewline: options.insertFinalNewline ? true : options.trimFinalNewlines ? false : undefined,
169
- ...await getFormattingOptions(document, context),
170
- };
171
- // https://github.com/microsoft/vscode/blob/a8f73340be02966c3816a2f23cb7e446a3a7cb9b/extensions/html-language-features/server/src/modes/htmlMode.ts#L47-L51
172
- if (formatSettings.contentUnformatted) {
173
- formatSettings.contentUnformatted = formatSettings.contentUnformatted + ',script';
174
- }
175
- else {
176
- formatSettings.contentUnformatted = 'script';
177
- }
178
+ const formatSettings = await getFormattingOptions(document, options, context);
178
179
  let formatDocument = document;
179
180
  let prefixes = [];
180
181
  let suffixes = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volar-service-html",
3
- "version": "0.0.31",
3
+ "version": "0.0.32",
4
4
  "description": "Integrate vscode-languageservice-html into Volar",
5
5
  "homepage": "https://github.com/volarjs/services/tree/master/packages/html",
6
6
  "bugs": "https://github.com/volarjs/services/issues",
@@ -39,5 +39,5 @@
39
39
  "optional": true
40
40
  }
41
41
  },
42
- "gitHead": "f7005aef724767786ee9fe943fa976231cc79bf1"
42
+ "gitHead": "717049e7dcd5c30f451f6db8eb71eaba43f74c83"
43
43
  }