volar-service-pug-beautify
Advanced tools
Comparing version 0.0.31 to 0.0.32
@@ -1,6 +0,7 @@ | ||
import type { DocumentSelector, Result, ServiceContext, ServicePlugin, TextDocument } from '@volar/language-service'; | ||
export declare function create({ documentSelector, isFormattingEnabled, }?: { | ||
import type { DocumentSelector, FormattingOptions, Result, ServiceContext, ServicePlugin, TextDocument } from '@volar/language-service'; | ||
export declare function create({ documentSelector, isFormattingEnabled, getFormattingOptions, }?: { | ||
documentSelector?: DocumentSelector; | ||
isFormattingEnabled?(document: TextDocument, context: ServiceContext): Result<boolean>; | ||
getFormattingOptions?(document: TextDocument, options: FormattingOptions, context: ServiceContext): Result<{}>; | ||
}): ServicePlugin; | ||
//# sourceMappingURL=index.d.ts.map |
13
index.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.create = void 0; | ||
function create({ documentSelector = ['jade'], isFormattingEnabled = () => true, } = {}) { | ||
function create({ documentSelector = ['jade'], isFormattingEnabled = () => true, getFormattingOptions = (_document, options) => { | ||
return { | ||
tab_size: options.tabSize, | ||
fill_tab: !options.insertSpaces, | ||
}; | ||
}, } = {}) { | ||
return { | ||
name: 'pug-beautify', | ||
@@ -23,6 +28,4 @@ create(context) { | ||
const suffixes = pugCode.slice(pugCode.length - suffixesLength); | ||
let newText = pugBeautify(pugCode, { | ||
tab_size: options.tabSize, | ||
fill_tab: !options.insertSpaces, | ||
}); | ||
const formatOptions = await getFormattingOptions(document, options, context); | ||
const newText = pugBeautify(pugCode, formatOptions); | ||
return [{ | ||
@@ -29,0 +32,0 @@ range, |
{ | ||
"name": "volar-service-pug-beautify", | ||
"version": "0.0.31", | ||
"version": "0.0.32", | ||
"description": "Integrate pug-beautify into Volar", | ||
@@ -40,3 +40,3 @@ "homepage": "https://github.com/volarjs/services/tree/master/packages/pug-beautify", | ||
}, | ||
"gitHead": "f7005aef724767786ee9fe943fa976231cc79bf1" | ||
"gitHead": "717049e7dcd5c30f451f6db8eb71eaba43f74c83" | ||
} |
5005
53