Skip to content

Latest commit

 

History

History
67 lines (45 loc) · 1.96 KB

README.md

File metadata and controls

67 lines (45 loc) · 1.96 KB

Docs for coc-svelte

Setup

Do you want to use TypeScript/SCSS/Less/..? See Using with preprocessors.

Using with preprocessors

Generic setup

Language specific setup

Documenting components

To add documentation on a Svelte component that will show up as a docstring in LSP-compatible editors, you can use an HTML comment with the @component tag:

<!--
 @component
 Here's some documentation for this component. It will show up on hover for
 JavaScript/TypeScript projects using a LSP-compatible editor such as VSCode or
 Vim/Neovim with coc.nvim.

 - You can use markdown here.
 - You can use code blocks here.
 - JSDoc/TSDoc will be respected by LSP-compatible editors.
 - Indentation will be respected as much as possible.
-->

<!-- @component You can use a single line, too -->

<!-- @component But only the last documentation comment will be used -->

<main>
    <h1>
        Hello world
    </h1>
</main>

Troubleshooting / FAQ

Using TypeScript? See this section

Using SCSS or Less? See this section

If I update a TS/JS file, Svelte does not seem to recognize it

You need to save the file to see the changes. If the problem persists after saving, check if you have something like this set in your settings:

"files.watcherExclude": {
  "**/*": true,
}

If so, this will prevent the language server from getting noticed about updates, because it uses a file watcher for js/ts files.

My Code does not get formatted

Your default formatter for Svelte files may be wrong.

  • Maybe you set all files to be formatted by the prettier extension. Install prettier-plugin-svelte from npm.