Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

vscode-css-languageservice

Microsoft3.5mMIT6.3.2TypeScript support: included

Language service for CSS, LESS and SCSS

readme

vscode-css-languageservice

Language services for CSS, LESS and SCSS

npm Package NPM Downloads Build Status License: MIT

Why?

The vscode-css-languageservice contains the language smarts behind the CSS, LESS and SCSS editing experience of Visual Studio Code and the Monaco editor.

  • doValidation analyses an input string and returns syntax and lint errors.
  • doComplete provides completion proposals for a given location.
  • doHover provides a hover text for a given location.
  • findDefinition finds the definition of the symbol at the given location.
  • findReferences finds all references to the symbol at the given location.
  • findDocumentHighlights finds all symbols connected to the given location.
  • findDocumentSymbols provides all symbols in the given document
  • doCodeActions evaluates code actions for the given location, typically to fix a problem.
  • findDocumentColors evaluates all color symbols in the given document
  • doRename renames all symbols connected to the given location.
  • prepareRename the range of the node that can be renamed
  • getFoldingRanges returns folding ranges in the given document.

Installation

npm install --save vscode-css-languageservice

API

For the complete API see cssLanguageService.ts and cssLanguageTypes.ts

Development

  • clone this repo, run npm install`
  • npm test to compile and run tests

How can I run and debug the service?

  • open the folder in VSCode.
  • set breakpoints, e.g. in cssCompletion.ts
  • run the Unit tests from the run viewlet and wait until a breakpoint is hit: image

How can I run and debug the service inside an instance of VSCode?

  • run VSCode out of sources setup as described here: https://github.com/Microsoft/vscode/wiki/How-to-Contribute
  • run npm link in the folder of vscode-css-languageservice
  • use npm link vscode-css-languageservice in vscode/extensions/css-language-features/server to run VSCode with the latest changes from vscode-css-languageservice
  • run VSCode out of source (vscode/scripts/code.sh|bat) and open a .css file
  • in VSCode window that is open on the vscode-css-languageservice sources, run command Debug: Attach to Node process and pick the code-oss process with the css-language-features path image
  • set breakpoints, e.g. in cssCompletion.ts
  • in the instance run from sources, invoke code completion in the .css file

Note: All CSS entities (properties, at-rules, etc) are sourced from https://github.com/microsoft/vscode-custom-data/tree/master/web-data and transpiled here. For adding new property or fixing existing properties' completion/hover description, please open PR there).

License

(MIT License)

Copyright 2016, 20 Microsoft

With the exceptions of build/mdn-documentation.js, which is built upon content from Mozilla Developer Network and distributed under CC BY-SA 2.5.

changelog

6.3.0 / 2022-06-24

  • new optional API fileSystemProvider.getContent

6.2.0 / 2022-11-09

  • new API LanguageService.prepareRename, returning Range

6.1.0 / 2022-09-02

  • new API LanguageService.findDocumentSymbols2, returning DocumentSymbol[]

6.0.0 / 2022-05-18

5.4.0 / 2022-04-01

  • new formatter settings: braceStyle, preserveNewLines, maxPreserveNewLines, wrapLineLength, indentEmptyLines

5.3.0 / 2022-03-23

  • renamed CSSFormatConfiguration.selectorSeparatorNewline to CSSFormatConfiguration.newlineBetweenSelectors

5.2.0 / 2022-03-17

5.1.0 / 2021-02-05

  • new API LanguageSettings.hover
  • New parameter CompletionSettings for LanguageService.doComplete and LanguageService.doComplete2

5.0.0 / 2020-12-14

4.4.0 - 2020-11-30

  • New parameter HoverSettings for LanguageService.doHover: Defines whether the hover contains element documentation and/or a reference to MDN.

4.3.0 - 2020-06-26

  • module resolving in urls (~foo/hello.html) when using LanguageService.findDocumentLinks2 and if fileSystemProvider is provided.
  • new API LanguageService.doComplete2. Support path completion if fileSystemProvider.readDirectory is provided.
  • DocumentContext.resolveReference can also return undefined (if the ref is invalid)

4.2.0 - 2020-05-14

  • new API LanguageServiceOptions.useDefaultDataProvider to control whether the default data provider is used. Defaults to true
  • new API LanguageService.setDataProviders to update the data providers.

4.1.0 - 2020-02-23

  • markdown descriptions in completions and hover
    • new API LanguageServiceOptions.clientCapabilities with ClientCapabilities for completion documentationFormat and hover content
    • extended format of CustomData (version 1.1) with MarkupContent contents and reference links
  • dynamically resolved links for scss include statements
    • new API LanguageService.findDocumentLinks2: Also returns dynamically resolved links if fileSystemProvider is provided
    • new API LanguageServiceOptions.fileSystemProvider with FileSystemProvider to query the file system (currently used to resolve the location of included files)
  • new API CompletionSettings.completePropertyWithSemicolon
  • new API ICompletionParticipant.onCssMixinReference
  • Switch to TextDocument from vscode-languageserver-textdocument (reexported from the main module)

4.0.0 / 2019-06-12

  • LanguageServiceOptions.customDataProviders allows you to use custom datasets for properties, at-properties, pseudo-classes and pseudo-elements.
  • New API LanguageService.getSelectionRanges

3.0.12 / 2018-10-29

  • Selector hover shows specificity
  • New linter setting validProperties: a comma separated list of all properties not to be included in validation checking.

3.0.10 / 2018-08-27

  • New API ICompletionParticipant.onCssImportPath to participate on @import statement.
  • New API LanguageService.doCodeActions2 returning code actions as CodeAction[].

3.0.9 / 2018-07-25

  • Use MDN data for to enhance CSS properties definition. See #91.
  • New API LanguageService.getFoldingRanges returning folding ranges in the given document.

3.0.8 / 2018-03-08

  • Provide ems modules in lib/esm

3.0.0 / 2017-01-11

  • Changed API LanguageService.getColorPresentations: separate parameters range and color (to match LS API)

2.1.7 / 2017-09-21

  • New API LanguageService.getColorPresentations returning presentations for a given color.
  • New API type ColorPresentation added.

2.1.4 / 2017-08-28

  • New API LanguageService.findDocumentColors returning the location and value of all colors in a document.
  • New API types ColorInformation and Color added.
  • Deprecated LanguageService.findColorSymbols. Use LanguageService.findDocumentColors instead.

2.1.3 / 2017-08-15

  • New argument documentSettings to LanguageService.doValidation to support resource specific settings. If present, document settings are used instead of the options passed in configure.

2.0.0 / 2017-02-17