Yesterday I explained how you can add linting and formatting support for Svelte.js with ESLint and Prettier.
But how can you integrate it into (Neo)Vim and ALE?
1. Installation 🔗︎
- Follow the steps here to get up and running with ESLint and Prettier.
- Install ALE with your favorite Vim plugin manager (I use minpac).
- optional: Install burner/vim-svelte for syntax highlighting.
2. Configuration 🔗︎
There is no native support for
.svelte files but you can define an alias.
Now, files with a
ale linters object.
You can also set up fixers (see above). I like to use
prettier amongst others.
You have to install these tools globally (via npm) or locally in your project, if you want to use them. ALE won't install them for you. The configuration file above tells ALE what linters to run, but if they're not available on your system, they won't work.
3. How to Use 🔗︎
If you run
:ALELint in (Neo)Vim, ALE should work.
I suggest customizing ALE to run when you save a file:
let g:ale_lint_on_save = 1 let g:ale_fix_on_save = 1 let g:ale_lint_on_enter = 0 let g:ale_lint_on_text_changed = 'never'