|
| 1 | +# Svelte for VS Code |
| 2 | + |
| 3 | +Provides syntax highlighting and rich intellisense for Svelte components in VS Code, utilising the [svelte language server](https://github.com/UnwrittenFun/svelte-language-server). |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Svelte |
| 8 | + - Diagnostic messages for warnings and errors |
| 9 | + - Support for svelte preprocessors that provide source maps |
| 10 | + - Svelte specific formatting (via [prettier-plugin-svelte](https://github.com/UnwrittenFun/prettier-plugin-svelte)) |
| 11 | +- HTML |
| 12 | + - Hover info |
| 13 | + - Autocompletions |
| 14 | + - [Emmet](https://emmet.io/) |
| 15 | + - Symbols in Outline panel |
| 16 | +- CSS / SCSS / LESS |
| 17 | + - Diagnostic messages for syntax and lint errors |
| 18 | + - Hover info |
| 19 | + - Autocompletions |
| 20 | + - Formatting (via [prettier](https://github.com/prettier/prettier)) |
| 21 | + - [Emmet](https://emmet.io/) |
| 22 | + - Color highlighting and color picker |
| 23 | + - Symbols in Outline panel |
| 24 | +- TypeScript / JavaScript |
| 25 | + - Diagnostics messages for syntax errors, semantic errors, and suggestions |
| 26 | + - Hover info |
| 27 | + - Formatting (via [prettier](https://github.com/prettier/prettier)) |
| 28 | + - Symbols in Outline panel |
| 29 | + - Autocompletions |
| 30 | + - Go to definition |
| 31 | + - Code Actions |
| 32 | + |
| 33 | +### Using with preprocessors |
| 34 | + |
| 35 | +#### Language specific setup |
| 36 | + |
| 37 | +- [SCSS](docs/preprocessors/scss.md) |
| 38 | +- [TypeScript](docs/preprocessors/typescript.md) |
| 39 | + |
| 40 | +#### Generic setup |
| 41 | + |
| 42 | +If a svelte file contains some language other than `html`, `css` or `javascript`, `svelte-vscode` needs to know how to [preprocess](https://svelte.dev/docs#svelte_preprocess) it. This can be achieved by creating a `svelte.config.js` file at the root of your project which exports a svelte options object (similar to `svelte-loader` and `rollup-plugin-svelte`). |
| 43 | + |
| 44 | +```js |
| 45 | +// svelte.config.js |
| 46 | +const preprocess = require('my-example-svelte-preprocessor'); |
| 47 | + |
| 48 | +module.exports = { |
| 49 | + preprocess: [preprocess()], |
| 50 | + // ...other svelte options |
| 51 | +}; |
| 52 | +``` |
| 53 | + |
| 54 | +It's also necessary to add a `type="text/language-name"` or `lang="language-name"` to your `style` and `script` tags, which defines how that code should be interpreted by the extension. |
| 55 | + |
| 56 | +```html |
| 57 | +<div> |
| 58 | + <h1>Hello, world!</h1> |
| 59 | +</div> |
| 60 | + |
| 61 | +<style type="text/scss"> |
| 62 | + div { |
| 63 | + h1 { |
| 64 | + color: red; |
| 65 | + } |
| 66 | + } |
| 67 | +</style> |
| 68 | +``` |
| 69 | + |
| 70 | +### Settings |
| 71 | + |
| 72 | +##### `svelte.language-server.runtime` |
| 73 | + |
| 74 | +Path to the node executable you would like to use to run the language server. |
| 75 | +This is useful when you depend on native modules such as node-sass as without |
| 76 | +this they will run in the context of vscode, meaning v8 version mismatch is likely. |
| 77 | + |
| 78 | +##### `svelte.plugin.typescript.enable` |
| 79 | + |
| 80 | +Enable the TypeScript plugin. _Default_: `true` |
| 81 | + |
| 82 | +##### `svelte.plugin.typescript.diagnostics` |
| 83 | + |
| 84 | +Enable diagnostic messages for TypeScript. _Default_: `true` |
| 85 | + |
| 86 | +##### `svelte.plugin.typescript.hover` |
| 87 | + |
| 88 | +Enable hover info for TypeScript. _Default_: `true` |
| 89 | + |
| 90 | +##### `svelte.plugin.typescript.documentSymbols` |
| 91 | + |
| 92 | +Enable document symbols for TypeScript. _Default_: `true` |
| 93 | + |
| 94 | +##### `svelte.plugin.typescript.completions` |
| 95 | + |
| 96 | +Enable completions for TypeScript. _Default_: `true` |
| 97 | + |
| 98 | +##### `svelte.plugin.typescript.definitions` |
| 99 | + |
| 100 | +Enable go to definition for TypeScript. _Default_: `true` |
| 101 | + |
| 102 | +##### `svelte.plugin.typescript.codeActions` |
| 103 | + |
| 104 | +Enable code actions for TypeScript. _Default_: `true` |
| 105 | + |
| 106 | +##### `svelte.plugin.css.enable` |
| 107 | + |
| 108 | +Enable the CSS plugin. _Default_: `true` |
| 109 | + |
| 110 | +##### `svelte.plugin.css.diagnostics` |
| 111 | + |
| 112 | +Enable diagnostic messages for CSS. _Default_: `true` |
| 113 | + |
| 114 | +##### `svelte.plugin.css.hover` |
| 115 | + |
| 116 | +Enable hover info for CSS. _Default_: `true` |
| 117 | + |
| 118 | +##### `svelte.plugin.css.completions` |
| 119 | + |
| 120 | +Enable auto completions for CSS. _Default_: `true` |
| 121 | + |
| 122 | +##### `svelte.plugin.css.documentColors` |
| 123 | + |
| 124 | +Enable document colors for CSS. _Default_: `true` |
| 125 | + |
| 126 | +##### `svelte.plugin.css.colorPresentations` |
| 127 | + |
| 128 | +Enable color picker for CSS. _Default_: `true` |
| 129 | + |
| 130 | +##### `svelte.plugin.css.documentSymbols` |
| 131 | + |
| 132 | +Enable document symbols for CSS. _Default_: `true` |
| 133 | + |
| 134 | +##### `svelte.plugin.html.enable` |
| 135 | + |
| 136 | +Enable the HTML plugin. _Default_: `true` |
| 137 | + |
| 138 | +##### `svelte.plugin.html.hover` |
| 139 | + |
| 140 | +Enable hover info for HTML. _Default_: `true` |
| 141 | + |
| 142 | +##### `svelte.plugin.html.completions` |
| 143 | + |
| 144 | +Enable auto completions for HTML. _Default_: `true` |
| 145 | + |
| 146 | +##### `svelte.plugin.html.tagComplete` |
| 147 | + |
| 148 | +Enable HTML tag auto closing. _Default_: `true` |
| 149 | + |
| 150 | +##### `svelte.plugin.html.documentSymbols` |
| 151 | + |
| 152 | +Enable document symbols for HTML. _Default_: `true` |
| 153 | + |
| 154 | +##### `svelte.plugin.svelte.enable` |
| 155 | + |
| 156 | +Enable the Svelte plugin. _Default_: `true` |
| 157 | + |
| 158 | +##### `svelte.plugin.svelte.diagnostics.enable` |
| 159 | + |
| 160 | +Enable diagnostic messages for Svelte. _Default_: `true` |
| 161 | + |
| 162 | +##### `svelte.plugin.svelte.format.enable` |
| 163 | + |
| 164 | +Enable formatting for Svelte (includes css & js). _Default_: `true` |
0 commit comments