volar-service-css
Advanced tools
Comparing version 0.0.47 to 0.0.48
@@ -1,2 +0,2 @@ | ||
import type { Disposable, DocumentSelector, FormattingOptions, ProviderResult, ServiceContext, LanguageServicePlugin } from '@volar/language-service'; | ||
import type { Disposable, DocumentSelector, FormattingOptions, ProviderResult, LanguageServiceContext, LanguageServicePlugin } from '@volar/language-service'; | ||
import * as css from 'vscode-css-languageservice'; | ||
@@ -13,9 +13,9 @@ import { TextDocument } from 'vscode-languageserver-textdocument'; | ||
useDefaultDataProvider?: boolean; | ||
getDocumentContext?(context: ServiceContext): css.DocumentContext; | ||
isFormattingEnabled?(document: TextDocument, context: ServiceContext): ProviderResult<boolean>; | ||
getFormattingOptions?(document: TextDocument, options: FormattingOptions, context: ServiceContext): ProviderResult<css.CSSFormatConfiguration>; | ||
getLanguageSettings?(document: TextDocument, context: ServiceContext): ProviderResult<css.LanguageSettings | undefined>; | ||
getCustomData?(context: ServiceContext): ProviderResult<css.ICSSDataProvider[]>; | ||
onDidChangeCustomData?(listener: () => void, context: ServiceContext): Disposable; | ||
getDocumentContext?(context: LanguageServiceContext): css.DocumentContext; | ||
isFormattingEnabled?(document: TextDocument, context: LanguageServiceContext): ProviderResult<boolean>; | ||
getFormattingOptions?(document: TextDocument, options: FormattingOptions, context: LanguageServiceContext): ProviderResult<css.CSSFormatConfiguration>; | ||
getLanguageSettings?(document: TextDocument, context: LanguageServiceContext): ProviderResult<css.LanguageSettings | undefined>; | ||
getCustomData?(context: LanguageServiceContext): ProviderResult<css.ICSSDataProvider[]>; | ||
onDidChangeCustomData?(listener: () => void, context: LanguageServiceContext): Disposable; | ||
}): LanguageServicePlugin; | ||
//# sourceMappingURL=index.d.ts.map |
58
index.js
@@ -10,5 +10,6 @@ "use strict"; | ||
resolveReference(ref, base) { | ||
const decoded = context.decodeEmbeddedDocumentUri(base); | ||
let baseUri = vscode_uri_1.URI.parse(base); | ||
const decoded = context.decodeEmbeddedDocumentUri(baseUri); | ||
if (decoded) { | ||
base = decoded[0]; | ||
baseUri = decoded[0]; | ||
} | ||
@@ -19,4 +20,4 @@ if (ref.match(/^\w[\w\d+.-]*:/)) { | ||
} | ||
if (ref[0] === '/') { // resolve absolute path against the current workspace folder | ||
let folderUri = context.env.workspaceFolder; | ||
if (ref[0] === '/' && context.env.workspaceFolders.length) { // resolve absolute path against the current workspace folder | ||
let folderUri = context.env.workspaceFolders[0].toString(); | ||
if (!folderUri.endsWith('/')) { | ||
@@ -27,3 +28,2 @@ folderUri += '/'; | ||
} | ||
const baseUri = vscode_uri_1.URI.parse(base); | ||
const baseUriDir = baseUri.path.endsWith('/') ? baseUri : vscode_uri_1.Utils.dirname(baseUri); | ||
@@ -46,12 +46,15 @@ return vscode_uri_1.Utils.resolvePath(baseUriDir, ref).toString(true); | ||
for (const customDataPath of customData) { | ||
const uri = vscode_uri_1.Utils.resolvePath(vscode_uri_1.URI.parse(context.env.workspaceFolder), customDataPath); | ||
const json = await context.env.fs?.readFile?.(uri.toString()); | ||
if (json) { | ||
try { | ||
const data = JSON.parse(json); | ||
newData.push(css.newCSSDataProvider(data)); | ||
for (const workspaceFolder of context.env.workspaceFolders) { | ||
const uri = vscode_uri_1.Utils.resolvePath(workspaceFolder, customDataPath); | ||
const json = await context.env.fs?.readFile?.(uri); | ||
if (json) { | ||
try { | ||
const data = JSON.parse(json); | ||
newData.push(css.newCSSDataProvider(data)); | ||
} | ||
catch (error) { | ||
console.error(error); | ||
} | ||
break; | ||
} | ||
catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
@@ -70,10 +73,29 @@ } | ||
name: 'css', | ||
// https://github.com/microsoft/vscode/blob/09850876e652688fb142e2e19fd00fd38c0bc4ba/extensions/css-language-features/server/src/cssServer.ts#L97 | ||
triggerCharacters: ['/', '-', ':'], | ||
capabilities: { | ||
completionProvider: { | ||
// https://github.com/microsoft/vscode/blob/09850876e652688fb142e2e19fd00fd38c0bc4ba/extensions/css-language-features/server/src/cssServer.ts#L97 | ||
triggerCharacters: ['/', '-', ':'], | ||
}, | ||
renameProvider: { | ||
prepareProvider: true, | ||
}, | ||
codeActionProvider: {}, | ||
definitionProvider: true, | ||
diagnosticProvider: true, | ||
hoverProvider: true, | ||
referencesProvider: true, | ||
documentHighlightProvider: true, | ||
documentLinkProvider: {}, | ||
documentSymbolProvider: true, | ||
colorProvider: true, | ||
foldingRangeProvider: true, | ||
selectionRangeProvider: true, | ||
documentFormattingProvider: true, | ||
}, | ||
create(context) { | ||
const stylesheets = new WeakMap(); | ||
const fileSystemProvider = { | ||
stat: async (uri) => await context.env.fs?.stat(uri) | ||
stat: async (uri) => await context.env.fs?.stat(vscode_uri_1.URI.parse(uri)) | ||
?? { type: css.FileType.Unknown, ctime: 0, mtime: 0, size: 0 }, | ||
readDirectory: async (uri) => await context.env.fs?.readDirectory(uri) ?? [], | ||
readDirectory: async (uri) => await context.env.fs?.readDirectory(vscode_uri_1.URI.parse(uri)) ?? [], | ||
}; | ||
@@ -80,0 +102,0 @@ const documentContext = getDocumentContext(context); |
{ | ||
"name": "volar-service-css", | ||
"version": "0.0.47", | ||
"version": "0.0.48", | ||
"description": "Integrate vscode-css-languageservice into Volar", | ||
@@ -35,3 +35,3 @@ "homepage": "https://github.com/volarjs/services/tree/master/packages/css", | ||
"peerDependencies": { | ||
"@volar/language-service": "~2.2.3" | ||
"@volar/language-service": "~2.3.0-alpha.0" | ||
}, | ||
@@ -43,3 +43,3 @@ "peerDependenciesMeta": { | ||
}, | ||
"gitHead": "d53f4dfa7007e77409af3ef28cc165e9940e7313" | ||
"gitHead": "6a80c92133e154907a79eefa05603f63994214c3" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22140
377