From 7ae88264ee62780ea2164a06a213f04eb3159176 Mon Sep 17 00:00:00 2001 From: Wang Shidong Date: Fri, 7 May 2021 22:22:59 +0800 Subject: [PATCH] Add Fennel language support (#4260) --- autoload/SpaceVim/layers/lang/fennel.vim | 52 +++++++++++++++++++ docs/layers/lang/fennel.md | 64 ++++++++++++++++++++++++ 2 files changed, 116 insertions(+) create mode 100644 autoload/SpaceVim/layers/lang/fennel.vim create mode 100644 docs/layers/lang/fennel.md diff --git a/autoload/SpaceVim/layers/lang/fennel.vim b/autoload/SpaceVim/layers/lang/fennel.vim new file mode 100644 index 000000000..1cf9eb0ed --- /dev/null +++ b/autoload/SpaceVim/layers/lang/fennel.vim @@ -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 diff --git a/docs/layers/lang/fennel.md b/docs/layers/lang/fennel.md new file mode 100644 index 000000000..d8c597444 --- /dev/null +++ b/docs/layers/lang/fennel.md @@ -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 + + + +- [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) + + + +## 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 | + +