From 5c81fb3da9f5321d84ae472a55928b4336287497 Mon Sep 17 00:00:00 2001 From: Wang Shidong Date: Tue, 14 Aug 2018 21:18:05 +0800 Subject: [PATCH] Improve lang#perl layer (#2041) * Add perl layer doc * Update perl layer --- autoload/SpaceVim/layers/lang/perl.vim | 35 +++++++++-- docs/cn/layers/index.md | 81 +++++++++++++------------- docs/cn/layers/lang/perl.md | 65 +++++++++++++++++++++ docs/layers/index.md | 5 +- docs/layers/lang/perl.md | 59 +++++++++++++++++++ wiki/en/Following-HEAD.md | 1 + 6 files changed, 198 insertions(+), 48 deletions(-) create mode 100644 docs/cn/layers/lang/perl.md create mode 100644 docs/layers/lang/perl.md diff --git a/autoload/SpaceVim/layers/lang/perl.vim b/autoload/SpaceVim/layers/lang/perl.vim index 519c8598e..69145abbc 100644 --- a/autoload/SpaceVim/layers/lang/perl.vim +++ b/autoload/SpaceVim/layers/lang/perl.vim @@ -8,12 +8,37 @@ function! SpaceVim#layers#lang#perl#plugins() abort - let plugins = [] - call add(plugins, ['WolfgangMehner/perl-support', {'on_ft' : 'perl'}]) - call add(plugins, ['c9s/perlomni.vim', {'on_ft' : 'perl'}]) - return plugins + let plugins = [] + call add(plugins, ['c9s/perlomni.vim', {'on_ft' : 'perl'}]) + call add(plugins, ['vim-perl/vim-perl', {'on_ft' : 'perl'}]) + call add(plugins, ['hotchpotch/perldoc-vim', {'on_cmd' : 'Perldoc'}]) + return plugins endfunction function! SpaceVim#layers#lang#perl#config() abort - + let g:perldoc_no_default_key_mappings = 1 + call SpaceVim#plugins#runner#reg_runner('perl', 'perl %s') + call SpaceVim#mapping#space#regesit_lang_mappings('perl', function('s:language_specified_mappings')) + call SpaceVim#plugins#repl#reg('perl', ['perl', '-de', '42']) +endfunction +function! s:language_specified_mappings() abort + nnoremap K :Perldoc + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'], + \ 'Perldoc', 'show_document', 1) + 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("perl")', + \ '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/cn/layers/index.md b/docs/cn/layers/index.md index b02dd3df1..737b14030 100644 --- a/docs/cn/layers/index.md +++ b/docs/cn/layers/index.md @@ -57,46 +57,47 @@ Vim 插件以及相关配置。而 SpaceVim 是以模块的方式来组织和管 ## 可用模块 -| 名称 | 描述 | -| ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | -| [VersionControl](VersionControl/) | 这一模块为 SpaceVim 提供了通用的代码版本控制支持,该模块支持 Git、Mercurial、Bazaar、SVN 等等多种后台工具。 | -| [autocomplete](autocomplete/) | 这一模块为 SpaceVim 提供了自动补全的框架,包括语法补全等多种补全来源,同时提供了代码块自动完成等特性。 | -| [chat](chat/) | chat 模块为 SpaceVim 提供了一个聊天框架,目前支持微信聊天和 QQ 聊天,同时支持自定义聊天服务器。 | -| [checkers](checkers/) | 这一模块为 SpaceVim 提供了代码语法检查的特性,同时提供代码实时检查,并列出语法错误的位置 | -| [chinese](chinese/) | 该模块为中文用户提供了中文的 Vim 帮助文档,同时提供部分插件的中文帮助文档。 | -| [colorscheme](colorscheme/) | colorscheme 模块为 SpaceVim 提供了一系列的常用颜色主题,默认情况下使用深色 gruvbox 作为默认主题。该模块提供了快速切换主题、随即主题等特性 | -| [cscope](cscope/) | cscope 模块为 SpaceVim 他提供了一个智能的 cscope 和 pycscope 辅助工具,可以快速调用 cscope 常用命令 | -| [ctrlp](ctrlp/) | 提供以 ctrlp 为核心的模糊查找机制,支持模糊搜索文件、历史纪录、函数列表等。 | -| [debug](debug/) | 这一模块为 SpaceVim 提供了 debug 的常用功能,采用 vebugger 作为后台框架,支持多种 debug 工具。 | -| [default](default/) | SpaceVim default 模块并不包含插件,但提供了一些更好的默认设置, | -| [denite](denite/) | 提供以 denite 为核心的异步模糊查找机制,支持模糊搜索文件、历史纪录、函数列表等。 | -| [fzf](fzf/) | 提供以 fzf 为核心的异步模糊查找机制,支持模糊搜索文件、历史纪录、函数列表等。 | -| [git](git/) | 这一模块为 SpaceVim 提供了 git 支持,根据当前 Vim 版本特性,选择 gina 或者 gita 作为默认的后台 git 插件。 | -| [lang#c](lang/c/) | This layer is for c/c++/object-c development | -| [lang#dart](lang/dart/) | This layer is for dart development, provide autocompletion, syntax checking, code format for dart file. | -| [lang#elixir](lang/elixir/) | This layer is for elixir development, provide autocompletion, syntax checking, code format for elixir file. | -| [lang#go](lang/go/) | This layer is for golang development. It also provides additional language-specific key mappings. | -| [lang#haskell](lang/haskell/) | This layer is for haskell development | -| [lang#html](lang/html/) | Edit html in SpaceVim, with this layer, this layer provides code completion, syntax checking and code formatting for html. | -| [lang#java](lang/java/) | This layer is for Java development. All the features such as code completion, formatting, syntax checking, REPL and debug have be done in this layer. | -| [lang#javascript](lang/javascript/) | This layer is for JaveScript development | -| [lang#julia](lang/julia/) | 这一模块为 julia 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | -| [lang#lisp](lang/lisp/) | for lisp development | -| [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#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. | -| [lang#ruby](lang/ruby/) | This layer is for ruby development, provide autocompletion, syntax checking, code format for ruby file. | -| [lang#typescript](lang/typescript/) | This layer is for TypeScript development | -| [lang#vim](lang/vim/) | This layer is for writting vim script, including code completion, syntax checking and buffer formatting | -| [language-server-protocol](language-server-protocol/) | lsp 模块为 SpaceVim 提供 language server protocol 的支持,提供更多语言相关服务 | -| [leaderf](leaderf/) | 提供以 leaderf 为核心的异步模糊查找机制,支持模糊搜索文件、历史纪录、函数列表等。 | -| [shell](shell/) | 这一模块为 SpaceVim 提供了终端集成特性,优化内置终端的使用体验 | -| [tags](tags/) | tags 模块提供全局的 tags 索引管理,提供快速检索定义和引用的功能。 | -| [tools#dash](tools/dash/) | 该模块提供对 Dash 支持,可快速查找光标位置的单词 | -| [tools](tools/) | 集成多种常用工具,包括日历、计算器、等等多种工具类插件,该模块针对 vim8 以及 neovim 提供了更好的插件选择。 | -| [ui](ui/) | SpaceVim ui 模块提供了一个 IDE-like 的界面,包括状态栏、文件树、语法数等等特性。 | -| [unite](unite/) | 提供以 unite 为核心的模糊查找机制,支持模糊搜索文件、历史纪录、函数列表等。 | +| 名称 | 描述 | +| ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | +| [VersionControl](VersionControl/) | 这一模块为 SpaceVim 提供了通用的代码版本控制支持,该模块支持 Git、Mercurial、Bazaar、SVN 等等多种后台工具。 | +| [autocomplete](autocomplete/) | 这一模块为 SpaceVim 提供了自动补全的框架,包括语法补全等多种补全来源,同时提供了代码块自动完成等特性。 | +| [chat](chat/) | chat 模块为 SpaceVim 提供了一个聊天框架,目前支持微信聊天和 QQ 聊天,同时支持自定义聊天服务器。 | +| [checkers](checkers/) | 这一模块为 SpaceVim 提供了代码语法检查的特性,同时提供代码实时检查,并列出语法错误的位置 | +| [chinese](chinese/) | 该模块为中文用户提供了中文的 Vim 帮助文档,同时提供部分插件的中文帮助文档。 | +| [colorscheme](colorscheme/) | colorscheme 模块为 SpaceVim 提供了一系列的常用颜色主题,默认情况下使用深色 gruvbox 作为默认主题。该模块提供了快速切换主题、随即主题等特性 | +| [cscope](cscope/) | cscope 模块为 SpaceVim 他提供了一个智能的 cscope 和 pycscope 辅助工具,可以快速调用 cscope 常用命令 | +| [ctrlp](ctrlp/) | 提供以 ctrlp 为核心的模糊查找机制,支持模糊搜索文件、历史纪录、函数列表等。 | +| [debug](debug/) | 这一模块为 SpaceVim 提供了 debug 的常用功能,采用 vebugger 作为后台框架,支持多种 debug 工具。 | +| [default](default/) | SpaceVim default 模块并不包含插件,但提供了一些更好的默认设置, | +| [denite](denite/) | 提供以 denite 为核心的异步模糊查找机制,支持模糊搜索文件、历史纪录、函数列表等。 | +| [fzf](fzf/) | 提供以 fzf 为核心的异步模糊查找机制,支持模糊搜索文件、历史纪录、函数列表等。 | +| [git](git/) | 这一模块为 SpaceVim 提供了 git 支持,根据当前 Vim 版本特性,选择 gina 或者 gita 作为默认的后台 git 插件。 | +| [lang#c](lang/c/) | 这一模块为 c/c++/object-c 的开发提供了支持,包括代码补全、语法检查等特性。 | +| [lang#dart](lang/dart/) | 这一模块为 dart 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | +| [lang#elixir](lang/elixir/) | 这一模块为 elixir 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | +| [lang#go](lang/go/) | 这一模块为 go 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | +| [lang#haskell](lang/haskell/) | 这一模块为 haskell 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | +| [lang#html](lang/html/) | 这一模块为 html 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | +| [lang#java](lang/java/) | 这一模块为 java 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | +| [lang#javascript](lang/javascript/) | 这一模块为 javascript 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | +| [lang#julia](lang/julia/) | 这一模块为 julia 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | +| [lang#lisp](lang/lisp/) | 这一模块为 lisp 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | +| [lang#lua](lang/lua/) | 这一模块为 lua 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | +| [lang#markdown](lang/markdown/) | 这一模块为 markdown 编辑提供支持,包括格式化、自动生成文章目录、代码块等特性。 | +| [lang#perl](lang/perl/) | 这一模块为 perl 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | +| [lang#php](lang/php/) | 这一模块为 php 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | +| [lang#python](lang/python/) | 这一模块为 python 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | +| [lang#ruby](lang/ruby/) | 这一模块为 ruby 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | +| [lang#typescript](lang/typescript/) | 这一模块为 typescript 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | +| [lang#vim](lang/vim/) | 这一模块为 vim script 开发提供支持,包括代码补全、语法检查、代码格式化等特性。 | +| [language-server-protocol](language-server-protocol/) | lsp 模块为 SpaceVim 提供 language server protocol 的支持,提供更多语言相关服务 | +| [leaderf](leaderf/) | 提供以 leaderf 为核心的异步模糊查找机制,支持模糊搜索文件、历史纪录、函数列表等。 | +| [shell](shell/) | 这一模块为 SpaceVim 提供了终端集成特性,优化内置终端的使用体验 | +| [tags](tags/) | tags 模块提供全局的 tags 索引管理,提供快速检索定义和引用的功能。 | +| [tools#dash](tools/dash/) | 该模块提供对 Dash 支持,可快速查找光标位置的单词 | +| [tools](tools/) | 集成多种常用工具,包括日历、计算器、等等多种工具类插件,该模块针对 vim8 以及 neovim 提供了更好的插件选择。 | +| [ui](ui/) | SpaceVim ui 模块提供了一个 IDE-like 的界面,包括状态栏、文件树、语法数等等特性。 | +| [unite](unite/) | 提供以 unite 为核心的模糊查找机制,支持模糊搜索文件、历史纪录、函数列表等。 | diff --git a/docs/cn/layers/lang/perl.md b/docs/cn/layers/lang/perl.md new file mode 100644 index 000000000..73a9b1e51 --- /dev/null +++ b/docs/cn/layers/lang/perl.md @@ -0,0 +1,65 @@ +--- +title: "SpaceVim lang#perl 模块" +description: "这一模块为 perl 开发提供支持,包括代码补全、语法检查、代码格式化等特性。" +lang: cn +--- + +# [可用模块](../../) >> lang#perl + + + +- [模块简介](#模块简介) +- [功能特性](#功能特性) +- [启用模块](#启用模块) +- [快捷键](#快捷键) + - [语言专属快捷键](#语言专属快捷键) + - [交互式编程](#交互式编程) + - [运行当前脚本](#运行当前脚本) + + + +## 模块简介 + +这一模块为 SpaceVim 提供了 perl 开发支持,包括代码补全、语法检查、以及代码格式化等特性。 + +## 功能特性 + +- 代码补全 +- 语法高亮 +- 文档查询 + +同时,SpaceVim 还为 perl 开发提供了交互式编程和一键运行等功能。 + +## 启用模块 + +可通过在配置文件内加入如下配置来启用该模块: + +```toml +[[layers]] + name = "lang#perl" +``` + +## 快捷键 + +### 语言专属快捷键 + +| 按键 | 功能描述 | +| --------------- | --------------------------------------- | +| `SPC l d` / `K` | 展示光标函数或变量相关文档 | + +### 交互式编程 + +启动 `perl -de 42` 交互进程,快捷键为: `SPC l s i`。 + +将代码传输给 REPL 进程执行: + +| 快捷键 | 描述 | +| ----------- | ----------------------- | +| `SPC l s b` | 发送整个文件内容至 REPL | +| `SPC l s l` | 发送当前行内容至 REPL | +| `SPC l s s` | 发送已选中的内容至 REPL | + +### 运行当前脚本 + +在编辑 perl 文件是,可通过快捷键 `SPC l r` 快速异步运行当前文件,运行结果会展示在一个独立的执行窗口内。 + diff --git a/docs/layers/index.md b/docs/layers/index.md index f107433b8..843cfb413 100644 --- a/docs/layers/index.md +++ b/docs/layers/index.md @@ -50,7 +50,6 @@ enable = false ## Available layers - | Name | Description | | ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [VersionControl](VersionControl/) | This layers provides general version control feature for vim. It should work with all VC backends such as Git, Mercurial, Bazaar, SVN, etc… | @@ -80,13 +79,14 @@ enable = false | [lang#html](lang/html/) | Edit html in SpaceVim, with this layer, this layer provides code completion, syntax checking and code formatting for html. | | [lang#java](lang/java/) | This layer is for Java development. All the features such as code completion, formatting, syntax checking, REPL and debug have be done in this layer. | | [lang#javascript](lang/javascript/) | This layer is for JaveScript development | -| [lang#julia](lang/julia/) | This layer is for julia development, provide autocompletion, syntax checking and code formatting | +| [lang#julia](lang/julia/) | This layer is for julia development, provide autocompletion, syntax checking and code formatting | | [lang#kotlin](lang/kotlin/) | This layer adds kotlin language support to SpaceVim | | [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#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#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. | @@ -104,7 +104,6 @@ enable = false | [ui](ui/) | Awesome UI layer for SpaceVim, provide IDE-like UI for neovim and vim in both TUI and GUI | | [unite](unite/) | This layers provide a heavily customized Unite centric work-flow | - diff --git a/docs/layers/lang/perl.md b/docs/layers/lang/perl.md new file mode 100644 index 000000000..9911faadf --- /dev/null +++ b/docs/layers/lang/perl.md @@ -0,0 +1,59 @@ +--- +title: "SpaceVim lang#perl layer" +description: "This layer is for perl development, provide autocompletion, syntax checking, code format for perl file." +--- + +# [Available Layers](../../) >> lang#perl + + + +- [Description](#description) +- [Features](#features) +- [Install](#install) + - [Layer](#layer) +- [Key bindings](#key-bindings) + - [Inferior REPL process](#inferior-repl-process) + - [Running current script](#running-current-script) + + + +## Description + +This layer is for perl development. + +## Features + +- Completion for Modules and functions. +- Documentation lookup for Modules and functions. +- Jump to the definition. + +SpaceVim also provides REPL/Debug support for perl. + +## Install + +### Layer + +To use this configuration layer, update custom configuration file with: + +```toml +[[layers]] + name = "lang#perl" +``` + +## Key bindings + +### Inferior REPL process + +Start a `perl` 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/wiki/en/Following-HEAD.md b/wiki/en/Following-HEAD.md index 0e3560c51..c536cfd4f 100644 --- a/wiki/en/Following-HEAD.md +++ b/wiki/en/Following-HEAD.md @@ -34,6 +34,7 @@ The next release is v0.9.0. - Improve debug info ([#1991](https://github.com/SpaceVim/SpaceVim/pull/1991)) - Improve tmux layer ([#1970](https://github.com/SpaceVim/SpaceVim/pull/1970)) - Improve statusline mode text and color ([#2034](https://github.com/SpaceVim/SpaceVim/pull/2034)) +- Improve `lang#perl` layer, add layer doc ([#2041](https://github.com/SpaceVim/SpaceVim/pull/2041)) ### Changed