Skip to content

Commit

Permalink
Update lang#coffeescript layer (#4229)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsdjeg committed Apr 24, 2021
1 parent 1512348 commit dbd6442
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
15 changes: 12 additions & 3 deletions autoload/SpaceVim/layers/lang/coffeescript.vim
Expand Up @@ -32,7 +32,13 @@
" SPC l s l send current line
" SPC l s s send selection text
" <
"


if exists('s:coffee_interpreter')
finish
endif

let s:coffee_interpreter = 'coffee' . (s:SYS.isWindows ? '.CMD' : '')

let s:SYS = SpaceVim#api#import('system')

Expand All @@ -45,12 +51,12 @@ endfunction

function! SpaceVim#layers#lang#coffeescript#config() abort
call SpaceVim#plugins#runner#reg_runner('coffee', {
\ 'exe' : 'coffee' . (s:SYS.isWindows ? '.CMD' : ''),
\ 'exe' : s:coffee_interpreter,
\ 'usestdin' : 1,
\ 'opt': ['-s'],
\ })
" call SpaceVim#plugins#runner#reg_runner('coffee', 'coffee %s')
call SpaceVim#plugins#repl#reg('coffee', ['coffee' . (s:SYS.isWindows ? '.CMD' : ''), '-i'])
call SpaceVim#plugins#repl#reg('coffee', [s:coffee_interpreter, '-i'])
call SpaceVim#mapping#space#regesit_lang_mappings('coffee', function('s:language_specified_mappings'))

endfunction
Expand Down Expand Up @@ -99,3 +105,6 @@ endfunction
function! s:filter_coffee_lint(lines, job) abort
let a:lines = []
endfunction
function! SpaceVim#layers#lang#coffeescript#set_variable(var) abort
let s:coffee_interpreter = get(a:var, 'coffee_interpreter', s:coffee_interpreter)
endfunction
1 change: 0 additions & 1 deletion doc/SpaceVim.txt
Expand Up @@ -1752,7 +1752,6 @@ This layer also provides REPL support for coffeescript, the key bindings are:
SPC l s s send selection text
<


==============================================================================
LANG#CRYSTAL *SpaceVim-layer-lang-crystal*

Expand Down
23 changes: 23 additions & 0 deletions docs/layers/lang/coffeescript.md
Expand Up @@ -10,6 +10,9 @@ description: "This layer is for CoffeeScript development, provide autocompletion
- [Description](#description)
- [Features](#features)
- [Install](#install)
- [Key bindings](#key-bindings)
- [Running current script](#running-current-script)
- [Inferior REPL process](#inferior-repl-process)

<!-- vim-markdown-toc -->

Expand All @@ -33,3 +36,23 @@ To use this configuration layer, update custom configuration file with:
[[layers]]
name = "lang#coffeescript"
```

## Key bindings

### Running current script

To running a coffeescript file, you can press `SPC l r` to run current file without loss focus,
and the result will be shown in a runner buffer.

### Inferior REPL process

Start a `coffee -i` inferior REPL process with `SPC l s i`.

Send code to inferior process commands:

| Key Bindings | Descriptions |
| ------------ | ------------------------------------------------ |
| `SPC l s b` | send buffer and keep code buffer focused |
| `SPC l s l` | send line and keep code buffer focused |
| `SPC l s s` | send selection text and keep code buffer focused |

0 comments on commit dbd6442

Please sign in to comment.