DEV Community

SpaceVim
SpaceVim

Posted on • Originally published at spacevim.org on

Use Vim as a CoffeeScript IDE

Blogs » Use Vim as a CoffeeScript IDE

This is a general guide for using SpaceVim as a CoffeeScript IDE, including layer configuration and usage. Each of the following sections will be covered:

  • Enable language layer
  • Code completion
  • Syntax linting
  • Jump to test file
  • running code
  • Code formatting <!-- vim-markdown-toc --> ### Enable language layer

By default lang#coffeescript layer is not loaded. To add CoffeeScript language support in SpaceVim,you need to enable the lang#coffeescript layer. Press SPC f v d to openSpaceVim configuration file, and add following configuration:

[[layers]]
  name = "lang#coffeescript"

for more info, you can read the lang#coffeescript layer documentation.

Code completion

lang#coffeescript layer will load the vim-coffeescript plugin automatically, unless overriden in your init.toml.The completion menu will be opened as you type.

coffeeide

Syntax linting

The checkers layer is enabled by default. This layer provides asynchronous syntax linting via neomake.It will run coffeelint asynchronously.

The coffeelint is command line lint for coffeescript, currently is maintained by Shuan Wang.To install coffeelint, just run following command in terminal.

npm install -g coffeelint

Note: if no coffeelint is installed, neomake will ues default command coffee.

coffeecheckers

Jump to test file

SpaceVim use built-in plugin to manager the files in a project,you can add a .project_alt.json to the root of your project with following content:

{
  "src/*.coffee": {"alternate": "test/{}.coffee"},
  "test/*.coffee": {"alternate": "src/{}.coffee"}
}

with this configuration, you can jump between the source code and test file via command :A.

running code

To run current script, you can press SPC l r, and a split windowswill be openen, the output of the script will be shown in this windows.It is running asynchronously, and will not block your vim.

coffeerunner

Code formatting

The format layer is also enabled by default, with this layer you can use key binding SPC b f to format current buffer.Before using this feature, please install coffee-fmt.

npm install -g coffee-fmt

Top comments (0)