1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 01:50:05 +08:00

Add lang#nim layer (#2018)

* Add lang#nim layer
This commit is contained in:
Wang Shidong 2018-08-11 18:41:20 +08:00 committed by GitHub
parent db3f0e51bf
commit d89a24aabf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 127 additions and 3 deletions

View File

@ -37,13 +37,13 @@ endfunction
function! s:find_position() abort
let start = search('^<!-- SpaceVim layer list start -->$','bwnc')
let end = search('^<!-- SpaceVim layer list end -->$','bnwc')
return sort([start, end])
return sort([start, end], 'n')
endfunction
function! s:find_position_cn() abort
let start = search('^<!-- SpaceVim layer cn list start -->$','bwnc')
let end = search('^<!-- SpaceVim layer cn list end -->$','bnwc')
return sort([start, end])
return sort([start, end], 'n')
endfunction
function! s:generate_content() abort

View File

@ -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)

View File

@ -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

View File

@ -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. |

69
docs/layers/lang/nim.md Normal file
View File

@ -0,0 +1,69 @@
---
title: "SpaceVim lang#nim layer"
description: "This layer adds nim language support to SpaceVim"
---
# [Available Layers](../../) >> lang#nim
<!-- vim-markdown-toc GFM -->
- [Description](#description)
- [Features](#features)
- [Install](#install)
- [Key bindings](#key-bindings)
- [Inferior REPL process](#inferior-repl-process)
- [Examples](#examples)
<!-- vim-markdown-toc -->
## 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.
<https://github.com/wsdjeg/nim-example>

View File

@ -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