1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 22:30:04 +08:00

Add Fennel language support (#4260)

This commit is contained in:
Wang Shidong 2021-05-07 22:22:59 +08:00 committed by GitHub
parent c20177c401
commit 7ae88264ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 116 additions and 0 deletions

View File

@ -0,0 +1,52 @@
"=============================================================================
" fennel.vim --- fennel language support
" Copyright (c) 2016-2019 Wang Shidong & Contributors
" Author: Wang Shidong < wsdjeg@outlook.com >
" URL: https://spacevim.org
" License: GPLv3
"=============================================================================
if exists('s:fennel_interpreter')
finish
endif
let s:fennel_interpreter = 'fennel'
function! SpaceVim#layers#lang#fennel#plugins() abort
let plugins = []
call add(plugins, ['bakpakin/fennel.vim', {'merged' : 0}])
return plugins
endfunction
function! SpaceVim#layers#lang#fennel#config() abort
call SpaceVim#plugins#repl#reg('fennel', s:fennel_interpreter)
call SpaceVim#plugins#runner#reg_runner('fennel', s:fennel_interpreter . ' %s')
call SpaceVim#mapping#space#regesit_lang_mappings('fennel', function('s:language_specified_mappings'))
endfunction
function! SpaceVim#layers#lang#fennel#set_variable(var) abort
let s:fennel_interpreter = get(a:var, 'fennel_interpreter', s:fennel_interpreter)
endfunction
function! s:language_specified_mappings() abort
call SpaceVim#mapping#space#langSPC('nmap', ['l','r'], 'call SpaceVim#plugins#runner#open()', 'execute current file', 1)
let g:_spacevim_mappings_space.l.s = {'name' : '+Send'}
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'],
\ 'call SpaceVim#plugins#repl#start("fennel")',
\ 'start REPL process', 1)
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'l'],
\ 'call SpaceVim#plugins#repl#send("line")',
\ 'send line and keep code buffer focused', 1)
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'b'],
\ 'call SpaceVim#plugins#repl#send("buffer")',
\ 'send buffer and keep code buffer focused', 1)
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 's'],
\ 'call SpaceVim#plugins#repl#send("selection")',
\ 'send selection and keep code buffer focused', 1)
endfunction

View File

@ -0,0 +1,64 @@
---
title: "SpaceVim lang#fennel layer"
description: "This layer is for fennel development, provide syntax checking, code runner and repl support for fennel file."
---
# [Available Layers](../../) >> lang#fennel
<!-- vim-markdown-toc GFM -->
- [Description](#description)
- [Install](#install)
- [Features](#features)
- [Layer options](#layer-options)
- [Key bindings](#key-bindings)
- [Running current script](#running-current-script)
- [Inferior REPL process](#inferior-repl-process)
<!-- vim-markdown-toc -->
## Description
`lang#fennel` layer provides syntax highlighting, code runner and repl support for [fennel language](https://fennel-lang.org/).
## Install
This layer is not enabled by default.
To use this configuration layer, update custom configuration file with:
```toml
[[layers]]
name = "lang#fennel"
```
## Features
- syntax highlighting for `.fnl` files
- repl support
- code runner
## Layer options
- `fennel_interpreter`: Set the path of `fennel` command, by default it is `fennel`.
## Key bindings
### Running current script
To running a fennel 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 `fennel` 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 |