This project extends JavaScript and TypeScript support of Kakoune.
It provides additional commands for linting and formatting of your files.
All formatting and linting will be done according to your local project preferences, e.g. in .eslintrc.js
.
It does not provide additional language features. For that, check the Kakoune Language Server Protocol Client instead.
kak-jsts has two dependencies that must be available on your machine:
- eslint-formatter-kakoune:
npm i -g eslint-formatter-kakoune
- jq
- Check installation instructions for your system (e.g.
brew install jq
).
- Check installation instructions for your system (e.g.
eslint-formatter-kakoune is required to enable Kakoune to interpret eslint's output.
jq is required to parse eslint's output of the JSON formatter.
With plug.kak
Add this to your kakrc
:
plug "schemar/kak-jsts"
Restart Kakoune or re-source your kakrc
and call the plug-install
command.
Clone this repository to your autoload
directory, or source the rc/jsts.kak
file
from your kakrc
.
kak-jsts provides three new commands:
format-eslint
format-prettier
format-tslint
format-eslint
and format-pretter
will format your buffer without touching the disk.
Due to a limitation in tslint
, your buffer will be written, formatted on disk, and then reloaded.
All formatting will be done according to your local project preferences, e.g. in .eslintrc.js
.
Kakoune must run in the root of the project for that to work.
kak-jsts provides implementations for common kakoune commands:
alt
lint
alt
jumps to the alternate file (implementation ↔ test).
Jumps between implementation und .test.(js|ts) or .spec.(js|ts) in the same directory.
alt
is an alias to jsts-alternative-file
.
Kak-jsts sets Kakoune's lint command to use eslint for JavaScript and TypeScript files.
Linting will be done according to your local project preferences, e.g. in .eslintrc.js
.
Kakoune must run in the root of the project for that to work.
plug "schemar/kak-jsts" config %{
hook global WinSetOption filetype=(javascript|typescript) %{
map window user l -docstring 'lint' ': lint<ret>'
map window user f -docstring 'format' ': format-eslint<ret>'
# If you want to format before every write, you could do s.th. like this:
hook window BufWritePre .* %{
evaluate-commands -no-hooks %{
format-eslint
}
}
}
}
If you use different formatters in different projects, you can source a local kakrc
where you overwrite the formatting command, for example to be format-prettier
.
See IDE on the Kakoune Wiki for more info about that.