Ⅰ. 插件描述
svelte support for (Neo)VimⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'coc-extensions/coc-svelte'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'coc-extensions/coc-svelte'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'coc-extensions/coc-svelte'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/coc-extensions/coc-svelte
Ⅳ. 文档说明
# Svelte for (Neo)Vim
fork from svelte-vscode
Provides rich intellisense for Svelte components in (neo)vim,
utilising the svelte language server.
Install
:CocInstall coc-svelte
Features
Svelte
- Diagnostic messages for warnings and errors
- Support for svelte preprocessors that provide source maps
- Svelte specific formatting (via prettier-plugin-svelte)
HTML
- Hover info
- Autocompletions
- Emmet
- Symbols in Outline panel
CSS / SCSS / LESS
TypeScript / JavaScript
- Diagnostics messages for syntax errors, semantic errors, and suggestions
- Hover info
- Formatting (via prettier)
- Symbols in Outline panel
- Autocompletions
- Go to definition
- Code Actions
Using with preprocessors
Language specific setup
Generic setup
If a svelte file contains some language other than html
, css
or javascript
,svelte-vscode
needs to know how to 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
).
// svelte.config.js
const preprocess = require('my-example-svelte-preprocessor');
module.exports = {
preprocess: [preprocess()],
// ...other svelte options
};
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.
<div>
<h1>Hello, world!</h1>
</div>
<style type="text/scss">
div {
h1 {
color: red;
}
}
</style>
Settings
svelte.language-server.runtime
Path to the node executable you would like to use to run the language server.
This is useful when you depend on native modules such as node-sass as without
this they will run in the context of coc.nvim, meaning v8 version mismatch is likely.
svelte.plugin.typescript.enable
Enable the TypeScript plugin. _Default_: true
svelte.plugin.typescript.diagnostics
Enable diagnostic messages for TypeScript. _Default_: true
svelte.plugin.typescript.hover
Enable hover info for TypeScript. _Default_: true
svelte.plugin.typescript.documentSymbols
Enable document symbols for TypeScript. _Default_: true
svelte.plugin.typescript.completions
Enable completions for TypeScript. _Default_: true
svelte.plugin.typescript.definitions
Enable go to definition for TypeScript. _Default_: true
svelte.plugin.typescript.codeActions
Enable code actions for TypeScript. _Default_: true
svelte.plugin.css.enable
Enable the CSS plugin. _Default_: true
svelte.plugin.css.diagnostics
Enable diagnostic messages for CSS. _Default_: true
svelte.plugin.css.hover
Enable hover info for CSS. _Default_: true
svelte.plugin.css.completions
Enable auto completions for CSS. _Default_: true
svelte.plugin.css.documentColors
Enable document colors for CSS. _Default_: true
svelte.plugin.css.colorPresentations
Enable color picker for CSS. _Default_: true
svelte.plugin.css.documentSymbols
Enable document symbols for CSS. _Default_: true
svelte.plugin.html.enable
Enable the HTML plugin. _Default_: true
svelte.plugin.html.autoClosingTags
Auto close tag for html template. _Default_: true
svelte.plugin.html.hover
Enable hover info for HTML. _Default_: true
svelte.plugin.html.completions
Enable auto completions for HTML. _Default_: true
svelte.plugin.html.tagComplete
Enable HTML tag auto closing. _Default_: true
svelte.plugin.html.documentSymbols
Enable document symbols for HTML. _Default_: true
svelte.plugin.svelte.enable
Enable the Svelte plugin. _Default_: true
svelte.plugin.svelte.diagnostics.enable
Enable diagnostic messages for Svelte. _Default_: true
svelte.plugin.svelte.format.enable
Enable formatting for Svelte (includes css & js). _Default_: true