From d89a24aabfd2cb52625020a225b898e895afc7b4 Mon Sep 17 00:00:00 2001 From: Wang Shidong Date: Sat, 11 Aug 2018 18:41:20 +0800 Subject: [PATCH] Add lang#nim layer (#2018) * Add lang#nim layer --- .SpaceVim.d/autoload/SpaceVim/dev/layers.vim | 4 +- README.md | 2 +- autoload/SpaceVim/layers/lang/nim.vim | 53 +++++++++++++++ docs/layers/index.md | 1 + docs/layers/lang/nim.md | 69 ++++++++++++++++++++ wiki/en/Following-HEAD.md | 1 + 6 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 autoload/SpaceVim/layers/lang/nim.vim create mode 100644 docs/layers/lang/nim.md diff --git a/.SpaceVim.d/autoload/SpaceVim/dev/layers.vim b/.SpaceVim.d/autoload/SpaceVim/dev/layers.vim index 6e674959a..aed28fc34 100644 --- a/.SpaceVim.d/autoload/SpaceVim/dev/layers.vim +++ b/.SpaceVim.d/autoload/SpaceVim/dev/layers.vim @@ -37,13 +37,13 @@ endfunction function! s:find_position() abort let start = search('^$','bwnc') let end = search('^$','bnwc') - return sort([start, end]) + return sort([start, end], 'n') endfunction function! s:find_position_cn() abort let start = search('^$','bwnc') let end = search('^$','bnwc') - return sort([start, end]) + return sort([start, end], 'n') endfunction function! s:generate_content() abort diff --git a/README.md b/README.md index 5af166f81..008bcc125 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [Community](https://spacevim.org/community/) \| [Sponsors](http://spacevim.org/sponsors/) \| [Gitter **Chat**](https://gitter.im/SpaceVim/SpaceVim) \| -[中文官网](http://spacevim.org/cn/) +[中文官网](https://spacevim.org/cn/) [![Build Status](https://travis-ci.org/SpaceVim/SpaceVim.svg?branch=master)](https://travis-ci.org/SpaceVim/SpaceVim) [![Build status](https://ci.appveyor.com/api/projects/status/eh3t5oph70abp665/branch/master?svg=true)](https://ci.appveyor.com/project/wsdjeg/spacevim/branch/master) diff --git a/autoload/SpaceVim/layers/lang/nim.vim b/autoload/SpaceVim/layers/lang/nim.vim new file mode 100644 index 000000000..9c5e57f44 --- /dev/null +++ b/autoload/SpaceVim/layers/lang/nim.vim @@ -0,0 +1,53 @@ +"============================================================================= +" nim.vim --- nim language support for SpaceVim +" Copyright (c) 2016-2017 Wang Shidong & Contributors +" Author: Wang Shidong < wsdjeg at 163.com > +" URL: https://spacevim.org +" License: GPLv3 +"============================================================================= + + +function! SpaceVim#layers#lang#nim#plugins() abort + let plugins = [] + call add(plugins, ['wsdjeg/vim-nim', {'merged' : 0}]) + return plugins +endfunction + +function! SpaceVim#layers#lang#nim#config() abort + call SpaceVim#mapping#space#regesit_lang_mappings('nim', function('s:language_specified_mappings')) + call SpaceVim#mapping#gd#add('nim', function('s:go_to_def')) + call SpaceVim#plugins#runner#reg_runner('nim', 'nim c -r --hints:off --verbosity:0 %s') + call SpaceVim#plugins#repl#reg('nim', 'nim secret') +endfunction + +function! s:language_specified_mappings() abort + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'], + \ 'NimInfo', 'show symbol info', 1) + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'], + \ 'call nim#features#usages#run()', 'rename symbol in file', 1) + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'E'], + \ 'call nim#features#usages#run(1)', 'rename symbol in project', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','r'], + \ 'call SpaceVim#plugins#runner#open()', + \ 'compible and run current file', 1) + + " REPL key bindings {{{ + let g:_spacevim_mappings_space.l.s = {'name' : '+Send'} + call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'], + \ 'call SpaceVim#plugins#repl#start("nim")', + \ '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 + +function! s:go_to_def() abort + NimDefinition +endfunction diff --git a/docs/layers/index.md b/docs/layers/index.md index ce7244888..8206a89ab 100644 --- a/docs/layers/index.md +++ b/docs/layers/index.md @@ -83,6 +83,7 @@ enable = false | [lang#lisp](lang/lisp/) | This layer is for lisp development, provide autocompletion, syntax checking, code format for lisp file. | | [lang#lua](lang/lua/) | This layer is for lua development, provide autocompletion, syntax checking, code format for lua file. | | [lang#markdown](lang/markdown/) | Edit markdown within vim, autopreview markdown in the default browser, with this layer you can also format markdown file. | +| [lang#nim](lang/nim/) | This layer adds nim language support to SpaceVim | | [lang#ocaml](lang/ocaml/) | This layer is for Python development, provide autocompletion, syntax checking, code format for ocaml file. | | [lang#php](lang/php/) | This layer adds PHP language support to SpaceVim | | [lang#python](lang/python/) | This layer is for Python development, provide autocompletion, syntax checking, code format for python file. | diff --git a/docs/layers/lang/nim.md b/docs/layers/lang/nim.md new file mode 100644 index 000000000..7398cb666 --- /dev/null +++ b/docs/layers/lang/nim.md @@ -0,0 +1,69 @@ +--- +title: "SpaceVim lang#nim layer" +description: "This layer adds nim language support to SpaceVim" +--- + +# [Available Layers](../../) >> lang#nim + + + +- [Description](#description) +- [Features](#features) +- [Install](#install) +- [Key bindings](#key-bindings) + - [Inferior REPL process](#inferior-repl-process) +- [Examples](#examples) + + + +## Description + +This layer adds [nim](https://github.com/nim-lang/Nim) language support to SpaceVim. +Nim is a compiled, garbage-collected systems programming language. + +## Features + +- syntax highlighting +- code completion +- code compiler and runner + +## Install + +To use this configuration layer, update custom configuration file with: + +```toml +[[layers]] + name = "lang#nim" +``` + +before using this layer, you need to install nim via package manager. for example in archlinux: + +```sh +sudo pacman -S nim nimble +``` + +## Key bindings + +| Key binding | Description | +| ----------- | ---------------------------- | +| `SPC l r` | compile and run current file | +| `SPC l e` | rename symbol in file | +| `SPC l E` | rename symbol in project | + +### Inferior REPL process + +Start a `nim secret` inferior REPL process with `SPC l s i`. + +Send code to inferior process commands: + +| Key Binding | Description | +| ----------- | ------------------------------------------------ | +| `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 | + +## Examples + +This is an nim example project which is developed in SpaceVim. + + diff --git a/wiki/en/Following-HEAD.md b/wiki/en/Following-HEAD.md index 3eeb13892..b08bec182 100644 --- a/wiki/en/Following-HEAD.md +++ b/wiki/en/Following-HEAD.md @@ -20,6 +20,7 @@ The next release is v0.9.0. - Add lang#agda layer ([#1941](https://github.com/SpaceVim/SpaceVim/pull/1941)) - Add lang#autohotkey layer ([#2021](https://github.com/SpaceVim/SpaceVim/pull/2021)) - Add lang#swift layer ([#2027](https://github.com/SpaceVim/SpaceVim/pull/2027)) +- Add lang#nim layer ([#2018](https://github.com/SpaceVim/SpaceVim/pull/2018)) ### Improvement