diff --git a/.ci/script.sh b/.ci/script.sh index 7e89021b6..1cca74acd 100755 --- a/.ci/script.sh +++ b/.ci/script.sh @@ -2,33 +2,39 @@ set -ex if [ "$LINT" = "vimlint" ]; then - for file in $(git diff --name-only HEAD dev | grep .vim$); - do - sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser $file; - done + for file in $(git diff --name-only HEAD dev | grep .vim$); + do + sh /tmp/vimlint/bin/vimlint.sh -l /tmp/vimlint -p /tmp/vimlparser $file; + done elif [ "$LINT" = "vimlint-errors" ]; then - if [[ -f build_log ]]; then - rm build_log - fi - for file in $(git diff --name-only HEAD master | grep .vim$); - do - /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser $file >> build_log 2>&1; - done - if [[ -s build_log ]]; then - cat build_log - exit 2 - fi + if [[ -f build_log ]]; then + rm build_log + fi + for file in $(git diff --name-only HEAD master | grep .vim$); + do + /tmp/vimlint/bin/vimlint.sh -E -l /tmp/vimlint -p /tmp/vimlparser $file >> build_log 2>&1; + done + if [[ -s build_log ]]; then + cat build_log + exit 2 + fi elif [ "$LINT" = "vint" ]; then - vint . + vint . elif [ "$LINT" = "vint-errors" ]; then - vint --error . + vint --error . elif [ "$LINT" = "vader" ]; then - pip install covimerage - make test_coverage - covimerage -vv xml --omit 'build/*' - pip install codecov - codecov -X search gcov pycov -f coverage.xml + export PATH="${DEPS}/_neovim/bin:${PATH}" + echo "\$PATH: \"${PATH}\"" + + export VIM="${DEPS}/_neovim/share/nvim/runtime" + echo "\$VIM: \"${VIM}\"" + nvim --version + pip install covimerage + make test_coverage + covimerage -vv xml --omit 'build/*' + pip install codecov + codecov -X search gcov pycov -f coverage.xml elif [ "$LINT" = "jekyll" ]; then - .ci/build-production + .ci/build-production fi set +x diff --git a/autoload/SpaceVim/layers/core/statusline.vim b/autoload/SpaceVim/layers/core/statusline.vim index b448b58dd..d1dc5529e 100644 --- a/autoload/SpaceVim/layers/core/statusline.vim +++ b/autoload/SpaceVim/layers/core/statusline.vim @@ -603,21 +603,21 @@ function! SpaceVim#layers#core#statusline#mode(mode) if a:mode == 'n' if !empty(iedit_mode) if iedit_mode ==# 'n' - exe 'hi! SpaceVim_statusline_a gui=bold ctermbg=' . t[8][3] . ' ctermfg=' . t[8][2] . ' guibg=' . t[8][1] . ' guifg=' . t[8][0] + exe 'hi! SpaceVim_statusline_a gui=bold cterm=bold ctermbg=' . t[8][3] . ' ctermfg=' . t[8][2] . ' guibg=' . t[8][1] . ' guifg=' . t[8][0] elseif iedit_mode ==# 'i' - exe 'hi! SpaceVim_statusline_a gui=bold ctermbg=' . t[7][3] . ' ctermfg=' . t[7][2] . ' guibg=' . t[7][1] . ' guifg=' . t[7][0] + exe 'hi! SpaceVim_statusline_a gui=bold cterm=bold ctermbg=' . t[7][3] . ' ctermfg=' . t[7][2] . ' guibg=' . t[7][1] . ' guifg=' . t[7][0] else - exe 'hi! SpaceVim_statusline_a gui=bold ctermbg=' . t[0][2] . ' ctermfg=' . t[0][3] . ' guibg=' . t[0][1] . ' guifg=' . t[0][0] + exe 'hi! SpaceVim_statusline_a gui=bold cterm=bold ctermbg=' . t[0][2] . ' ctermfg=' . t[0][3] . ' guibg=' . t[0][1] . ' guifg=' . t[0][0] endif else - exe 'hi! SpaceVim_statusline_a gui=bold ctermbg=' . t[0][2] . ' ctermfg=' . t[0][3] . ' guibg=' . t[0][1] . ' guifg=' . t[0][0] + exe 'hi! SpaceVim_statusline_a gui=bold cterm=bold ctermbg=' . t[0][2] . ' ctermfg=' . t[0][3] . ' guibg=' . t[0][1] . ' guifg=' . t[0][0] endif elseif a:mode == 'i' - exe 'hi! SpaceVim_statusline_a gui=bold ctermbg=' . t[4][3] . ' ctermfg=' . t[4][2] . ' guibg=' . t[4][1] . ' guifg=' . t[4][0] + exe 'hi! SpaceVim_statusline_a gui=bold cterm=bold ctermbg=' . t[4][3] . ' ctermfg=' . t[4][2] . ' guibg=' . t[4][1] . ' guifg=' . t[4][0] elseif a:mode == 'R' - exe 'hi! SpaceVim_statusline_a gui=bold ctermbg=' . t[6][3] . ' ctermfg=' . t[6][2] . ' guibg=' . t[6][1] . ' guifg=' . t[6][0] + exe 'hi! SpaceVim_statusline_a gui=bold cterm=bold ctermbg=' . t[6][3] . ' ctermfg=' . t[6][2] . ' guibg=' . t[6][1] . ' guifg=' . t[6][0] elseif a:mode == 'v' || a:mode == 'V' || a:mode == '' || a:mode == 's' || a:mode == 'S' || a:mode == '' - exe 'hi! SpaceVim_statusline_a gui=bold ctermbg=' . t[5][3] . ' ctermfg=' . t[5][2] . ' guibg=' . t[5][1] . ' guifg=' . t[5][0] + exe 'hi! SpaceVim_statusline_a gui=bold cterm=bold ctermbg=' . t[5][3] . ' ctermfg=' . t[5][2] . ' guibg=' . t[5][1] . ' guifg=' . t[5][0] endif call s:HI.hi_separator('SpaceVim_statusline_a', 'SpaceVim_statusline_b') let w:spacevim_statusline_mode = a:mode diff --git a/autoload/SpaceVim/layers/lang/purescript.vim b/autoload/SpaceVim/layers/lang/purescript.vim new file mode 100644 index 000000000..e13bed969 --- /dev/null +++ b/autoload/SpaceVim/layers/lang/purescript.vim @@ -0,0 +1,81 @@ +"============================================================================= +" purescript.vim --- lang#purescript layer 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#purescript#plugins() abort + let plugins = [] + call add(plugins, ['wsdjeg/purescript-vim', {'on_ft' : 'purescript'}]) + call add(plugins, ['frigoeu/psc-ide-vim', {'on_ft' : 'purescript'}]) + return plugins +endfunction + +function! SpaceVim#layers#lang#purescript#config() abort + call SpaceVim#mapping#space#regesit_lang_mappings('purescript', function('s:language_specified_mappings')) + call SpaceVim#mapping#gd#add('purescript', function('s:go_to_def')) + call SpaceVim#plugins#repl#reg('purescript', ['pulp', 'repl']) + call SpaceVim#plugins#runner#reg_runner('purescript', 'pulp run') +endfunction +function! s:language_specified_mappings() abort + call SpaceVim#mapping#space#langSPC('nmap', ['l','L'], + \ 'Plist', + \ 'list loaded modules', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','l'], + \ 'Pload!', + \ 'reset loaded modules and load externs', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','r'], + \ 'call SpaceVim#plugins#runner#open()', + \ 'run current project', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','R'], + \ 'Prebuild!', + \ 'rubuild current buffer', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','f'], + \ 'PaddClause', + \ 'generate function template', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','t'], + \ 'PaddType', + \ 'add type annotation', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','a'], + \ 'Papply', + \ 'apply current line suggestion', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','A'], + \ 'Papply!', + \ 'apply all suggestions', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','C'], + \ 'Pcase!', + \ 'add case expression', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','i'], + \ 'Pimport', + \ 'import module', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','p'], + \ 'Pursuit', + \ 'search pursuit for cursor ident', 1) + call SpaceVim#mapping#space#langSPC('nmap', ['l','T'], + \ 'Ptype', + \ 'find type of cursor ident', 1) + let g:_spacevim_mappings_space.l.s = {'name' : '+Send'} + call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 'i'], + \ 'call SpaceVim#plugins#repl#start("purescript")', + \ '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 + if !SpaceVim#layers#lsp#check_filetype('purescript') + Pgoto + else + call SpaceVim#lsp#go_to_def() + endif +endfunction diff --git a/autoload/SpaceVim/layers/lsp.vim b/autoload/SpaceVim/layers/lsp.vim index 2b742666a..aefe7c2e4 100644 --- a/autoload/SpaceVim/layers/lsp.vim +++ b/autoload/SpaceVim/layers/lsp.vim @@ -95,7 +95,8 @@ let s:lsp_servers = { \ 'html' : ['html-languageserver', '--stdio'], \ 'php' : ['php', g:spacevim_plugin_bundle_dir . 'repos/github.com/felixfbecker/php-language-server/bin/php-language-server.php'], \ 'julia' : ['julia', '--startup-file=no', '--history-file=no', '-e', 'using LanguageServer; server = LanguageServer.LanguageServerInstance(STDIN, STDOUT, false); server.runlinter = true; run(server);'], - \ 'javascript' : ['javascript-typescript-stdio'] + \ 'javascript' : ['javascript-typescript-stdio'], + \ 'purescript' : ['purescript-language-server', '--stdio'] \ } function! SpaceVim#layers#lsp#set_variable(var) abort diff --git a/autoload/SpaceVim/mapping/leader.vim b/autoload/SpaceVim/mapping/leader.vim index eae456d0f..2c5f41a00 100644 --- a/autoload/SpaceVim/mapping/leader.vim +++ b/autoload/SpaceVim/mapping/leader.vim @@ -59,9 +59,9 @@ function! SpaceVim#mapping#leader#defindWindowsLeader(key) abort \ ] \ ] nnoremap [Window]o - \ :only + \ :onlydoautocmd WinEnter let lnum = expand('') + s:lnum - 4 - let g:_spacevim_mappings_windows.o = ['only', + let g:_spacevim_mappings_windows.o = ['only | doautocmd WinEnter', \ 'Close other windows', \ [ \ '[WIN o] is to close all other windows', diff --git a/autoload/SpaceVim/plugins/runner.vim b/autoload/SpaceVim/plugins/runner.vim index e582940e6..e79d17b91 100644 --- a/autoload/SpaceVim/plugins/runner.vim +++ b/autoload/SpaceVim/plugins/runner.vim @@ -33,7 +33,11 @@ let s:target = '' function! s:async_run(runner) abort if type(a:runner) == type('') - let cmd = printf(a:runner, bufname('%')) + try + let cmd = printf(a:runner, bufname('%')) + catch + let cmd = a:runner + endtry call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 3, 0, ['[Running] ' . cmd, '', repeat('-', 20)]) let s:lines += 3 let s:start_time = reltime() @@ -71,6 +75,9 @@ function! s:async_run(runner) abort endif endfunction +" @vimlint(EVL103, 1, a:id) +" @vimlint(EVL103, 1, a:data) +" @vimlint(EVL103, 1, a:event) function! s:on_compile_exit(id, data, event) abort if a:data == 0 let s:job_id = s:JOB.start(s:target,{ @@ -87,6 +94,9 @@ function! s:on_compile_exit(id, data, event) abort call s:update_statusline() endif endfunction +" @vimlint(EVL103, 0, a:id) +" @vimlint(EVL103, 0, a:data) +" @vimlint(EVL103, 0, a:event) function! s:update_statusline() abort redrawstatus! @@ -111,16 +121,16 @@ function! SpaceVim#plugins#runner#open() abort call s:update_statusline() endif endfunction + " @vimlint(EVL103, 1, a:job_id) " @vimlint(EVL103, 1, a:data) " @vimlint(EVL103, 1, a:event) - if has('nvim') && exists('*chanclose') let s:_out_data = [''] function! s:on_stdout(job_id, data, event) abort let s:_out_data[-1] .= a:data[0] call extend(s:_out_data, a:data[1:]) - if s:_out_data[-1] == '' + if s:_out_data[-1] ==# '' call remove(s:_out_data, -1) let lines = s:_out_data else @@ -138,7 +148,7 @@ if has('nvim') && exists('*chanclose') function! s:on_stderr(job_id, data, event) abort let s:_out_data[-1] .= a:data[0] call extend(s:_out_data, a:data[1:]) - if s:_out_data[-1] == '' + if s:_out_data[-1] ==# '' call remove(s:_out_data, -1) let lines = s:_out_data else diff --git a/docs/cn/layers/index.md b/docs/cn/layers/index.md index b4ca000bf..c79826ffe 100644 --- a/docs/cn/layers/index.md +++ b/docs/cn/layers/index.md @@ -86,6 +86,7 @@ Vim 插件以及相关配置。而 SpaceVim 是以模块的方式来组织和管 | [lang#markdown](lang/markdown/) | 这一模块为 markdown 编辑提供支持,包括格式化、自动生成文章目录、代码块等特性。 | | [lang#perl](lang/perl/) | 这一模块为 perl 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | | [lang#php](lang/php/) | 这一模块为 php 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | +| [lang#purescript](lang/purescript/) | 这一模块为 purescript 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | | [lang#python](lang/python/) | 这一模块为 python 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | | [lang#ruby](lang/ruby/) | 这一模块为 ruby 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | | [lang#rust](lang/rust/) | 这一模块为 rust 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | diff --git a/docs/cn/layers/lang/purescript.md b/docs/cn/layers/lang/purescript.md new file mode 100644 index 000000000..9579ee8c0 --- /dev/null +++ b/docs/cn/layers/lang/purescript.md @@ -0,0 +1,71 @@ +--- +title: "SpaceVim lang#purescript 模块" +description: "这一模块为 purescript 开发提供支持,包括代码补全、语法检查、代码格式化等特性。" +lang: cn +--- + +# [可用模块](../../) >> lang#purescript + + + +- [模块简介](#模块简介) +- [功能特性](#功能特性) +- [启用模块](#启用模块) +- [快捷键](#快捷键) + - [语言专属快捷键](#语言专属快捷键) + - [交互式编程](#交互式编程) + + + +## 模块简介 + +这一模块为 SpaceVim 提供了 purescript 开发支持,包括代码补全、语法检查、以及代码格式化等特性。 + +## 功能特性 + +- 代码补全 +- 文档查询 +- 跳转定义处 + +同时,SpaceVim 还为 purescript 开发提供了交互式编程、一键运行和语言服务器等功能。若要启用语言服务器,需要载入 `lsp` 模块。 + +## 启用模块 + +可通过在配置文件内加入如下配置来启用该模块: + +```toml +[[layers]] + name = "lang#purescript" +``` + +## 快捷键 + +### 语言专属快捷键 + +| 按键 | 描述 | +| --------- | --------------------------------- | +| `g d` | 跳至定义处 | +| `SPC l L` | 列出所有已载入的模块 | +| `SPC l l` | 重置并载入模块 | +| `SPC l r` | 运行当前项目 | +| `SPC l R` | 重新编译当前文件 | +| `SPC l f` | 生成函数模板 | +| `SPC l t` | 添加类型注解 | +| `SPC l a` | 在当前未至应用修改建议 | +| `SPC l A` | 应用所有修改建议 | +| `SPC l C` | 添加 case expression | +| `SPC l i` | 导入光标下的模块 | +| `SPC l p` | 搜索 pursuit for cursor ident | +| `SPC l T` | 查询光标符号类型 | + +### 交互式编程 + +启动 `pulp repl` 交互进程,快捷键为: `SPC l s i`。 + +将代码传输给 REPL 进程执行: + +| 快捷键 | 描述 | +| ----------- | ----------------------- | +| `SPC l s b` | 发送整个文件内容至 REPL | +| `SPC l s l` | 发送当前行内容至 REPL | +| `SPC l s s` | 发送已选中的内容至 REPL | diff --git a/docs/layers/index.md b/docs/layers/index.md index adba3fcf7..58bf21e65 100644 --- a/docs/layers/index.md +++ b/docs/layers/index.md @@ -88,6 +88,7 @@ enable = false | [lang#ocaml](lang/ocaml/) | This layer is for Python development, provide autocompletion, syntax checking, code format for ocaml file. | | [lang#perl](lang/perl/) | This layer is for perl development, provide autocompletion, syntax checking, code format for perl file. | | [lang#php](lang/php/) | This layer adds PHP language support to SpaceVim | +| [lang#purescript](lang/purescript/) | This layer is for purescript development, provide autocompletion, syntax checking, code format for purescript file. | | [lang#python](lang/python/) | This layer is for Python development, provide autocompletion, syntax checking, code format for python file. | | [lang#ruby](lang/ruby/) | This layer is for ruby development, provide autocompletion, syntax checking, code format for ruby file. | | [lang#rust](lang/rust/) | This layer is for rust development, provide autocompletion, syntax checking, code format for rust file. | diff --git a/docs/layers/lang/purescript.md b/docs/layers/lang/purescript.md new file mode 100644 index 000000000..346952823 --- /dev/null +++ b/docs/layers/lang/purescript.md @@ -0,0 +1,87 @@ +--- +title: "SpaceVim lang#purescript layer" +description: "This layer is for purescript development, provide autocompletion, syntax checking, code format for purescript file." +--- + +# [Available Layers](../../) >> lang#purescript + + + +- [Description](#description) +- [Features](#features) +- [Install](#install) + - [Get the compiler and recommended tools](#get-the-compiler-and-recommended--tools) + - [Layer](#layer) +- [Key bindings](#key-bindings) + - [Language specific key bindings](#language-specific-key-bindings) + - [Inferior REPL process](#inferior-repl-process) + - [Running current script](#running-current-script) + + + +## Description + +This layer is for Purescript development. PureScript is a strongly-typed functional programming language that compiles to JavaScript. + +## Features + +- Completion for Modules and functions. +- Documentation lookup for Modules and functions. +- Jump to the definition. + +SpaceVim also provides REPL, code runner and Language Server protocol support for purescript. to enable language server protocol +for purescript, you need to load `lsp` layer for purescript. + +## Install + +### Get the compiler and recommended tools + +```sh +npm install -g purescript +npm install -g pulp bower +``` + +### Layer + +To use this configuration layer, update custom configuration file with: + +```toml +[[layers]] + name = "lang#purescript" +``` + +## Key bindings + +### Language specific key bindings + +| Key binding | Description | +| ----------- | ------------------------------------- | +| `g d` | Goto identifier. | +| `SPC l L` | list loaded modules | +| `SPC l l` | reset loaded modules and load externs | +| `SPC l r` | run current project | +| `SPC l R` | rubuild current buffer | +| `SPC l f` | generate function template | +| `SPC l t` | add type annotation | +| `SPC l a` | apply current line suggestion | +| `SPC l A` | apply all suggestions | +| `SPC l C` | add case expression | +| `SPC l i` | import module under cursor | +| `SPC l p` | search pursuit for cursor ident | +| `SPC l T` | find type for cursor ident | + +### Inferior REPL process + +Start a `pulp repl` 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 | + +### Running current script + +To running current script, you can press `SPC l r` to run current file without loss focus, and the result will be shown in a runner buffer. diff --git a/docs/layers/language-server-protocol.md b/docs/layers/language-server-protocol.md index 00d8ef3ad..ce094c21a 100644 --- a/docs/layers/language-server-protocol.md +++ b/docs/layers/language-server-protocol.md @@ -96,6 +96,12 @@ julia> Pkg.clone("https://github.com/JuliaEditorSupport/LanguageServer.jl") With new package system in Julia 0.7 and above, we have a package mode in Julia REPL. in REPL, hit `]` to enter the package management mode, then `add LanguageServer` to install the package. +**PureScript** + +```sh +npm install -g purescript-language-server +``` + ## Configuration To enable lsp support for a specified filetype, you may need to load this layer with `filtypes` option, for example: @@ -114,7 +120,7 @@ default language server commands: | language | server command | | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `javascript` | `['javascript-typescript-stdio']` | -| `sh` | `['bash-language-server', 'start']` | +| `sh` | `['bash-language-server', 'start']` | | `typescript` | `['typescript-language-server', '--stdio']` | | `haskell` | `['hie', '--lsp']` | | `c` | `['clangd']` | @@ -128,6 +134,7 @@ default language server commands: | `python` | `['pyls']` | | `php` | `['php', 'path/to/bin/php-language-server.php']` | | `julia` | `['julia', '--startup-file=no', '--history-file=no', '-e', 'using LanguageServer; server = LanguageServer.LanguageServerInstance(STDIN, STDOUT, false); server.runlinter = true; run(server);']` | +| `purescript` | `['purescript-language-server', '--stdio']` | To override the server command, you may need to use `override_cmd` option: diff --git a/wiki/en/Following-HEAD.md b/wiki/en/Following-HEAD.md index 5f8de6940..b01f015b2 100644 --- a/wiki/en/Following-HEAD.md +++ b/wiki/en/Following-HEAD.md @@ -23,6 +23,7 @@ The next release is v0.9.0. - 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)) +- Add `lang#purescript` layer ([#2054](https://github.com/SpaceVim/SpaceVim/pull/2054)) ### Improvement