mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-12 17:55:41 +08:00
Add vimdoc support in lang#vim layer (#4010)
This commit is contained in:
parent
297f5ea431
commit
0052b27a15
@ -9,7 +9,7 @@
|
||||
""
|
||||
" @section vim#command, api-vim-command
|
||||
" @parentsection api
|
||||
" This api is for create complete function for custom vim command. This is
|
||||
" This api is for creating complete function for custom vim command. This is
|
||||
" example for create complete function for command TEST
|
||||
" >
|
||||
" let s:CMD = SpaceVim#api#import('vim#command')
|
||||
|
@ -7,10 +7,7 @@
|
||||
"=============================================================================
|
||||
|
||||
|
||||
let s:SYS = SpaceVim#api#import('system')
|
||||
let s:JOB = SpaceVim#api#import('job')
|
||||
let s:VIM = SpaceVim#api#import('vim')
|
||||
let s:CMP = SpaceVim#api#import('vim#compatible')
|
||||
|
||||
|
||||
"autocmds
|
||||
@ -62,7 +59,6 @@ function! SpaceVim#autocmds#init() abort
|
||||
autocmd FocusGained * call s:reload_touchpad_status()
|
||||
endif
|
||||
autocmd BufWritePre * call SpaceVim#plugins#mkdir#CreateCurrent()
|
||||
autocmd BufWritePost *.vim call s:generate_doc()
|
||||
autocmd ColorScheme * call SpaceVim#api#import('vim#highlight').hide_in_normal('EndOfBuffer')
|
||||
autocmd ColorScheme gruvbox,jellybeans,nord,srcery,NeoSolarized call s:fix_colorschem_in_SpaceVim()
|
||||
autocmd VimEnter * call SpaceVim#autocmds#VimEnter()
|
||||
@ -114,15 +110,6 @@ function! s:fixindentline() abort
|
||||
let s:done = 1
|
||||
endif
|
||||
endfunction
|
||||
function! s:generate_doc() abort
|
||||
" neovim in windows executable function is broken
|
||||
" https://github.com/neovim/neovim/issues/9391
|
||||
if filereadable('./addon-info.json') && executable('vimdoc') && !s:SYS.isWindows
|
||||
call s:JOB.start(['vimdoc', '.'])
|
||||
elseif filereadable('./addon-info.json') && executable('python')
|
||||
call s:JOB.start(['python', '-m', 'vimdoc', '.'])
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:fix_colorschem_in_SpaceVim() abort
|
||||
if &background ==# 'dark'
|
||||
|
@ -6,9 +6,19 @@
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
if exists('s:auto_generate_doc')
|
||||
finish
|
||||
endif
|
||||
|
||||
|
||||
let s:auto_generate_doc = 0
|
||||
|
||||
" Load SpaceVim API
|
||||
|
||||
let s:SID = SpaceVim#api#import('vim#sid')
|
||||
let s:JOB = SpaceVim#api#import('job')
|
||||
let s:SYS = SpaceVim#api#import('system')
|
||||
let s:FILE = SpaceVim#api#import('file')
|
||||
|
||||
function! SpaceVim#layers#lang#vim#plugins() abort
|
||||
let plugins = [
|
||||
@ -40,6 +50,33 @@ function! SpaceVim#layers#lang#vim#config() abort
|
||||
call SpaceVim#mapping#gd#add('vim','lookup#lookup')
|
||||
call SpaceVim#mapping#space#regesit_lang_mappings('vim', function('s:language_specified_mappings'))
|
||||
call SpaceVim#plugins#highlight#reg_expr('vim', '\s*\<fu\%[nction]\>!\?\s*', '\s*\<endf\%[unction]\>\s*')
|
||||
if s:auto_generate_doc
|
||||
augroup spacevim_layer_lang_vim
|
||||
autocmd!
|
||||
autocmd BufWritePost *.vim call s:generate_doc()
|
||||
augroup END
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:generate_doc() abort
|
||||
" neovim in windows executable function is broken
|
||||
" https://github.com/neovim/neovim/issues/9391
|
||||
let fd = expand('%:p')
|
||||
let addon_info = s:FILE.findfile('addon-info.json', fd)
|
||||
if !empty(addon_info)
|
||||
let dir = s:FILE.unify_path(addon_info, ':h')
|
||||
if executable('vimdoc') && !s:SYS.isWindows
|
||||
call s:JOB.start(['vimdoc', dir])
|
||||
elseif executable('python')
|
||||
call s:JOB.start(['python', '-m', 'vimdoc', dir])
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lang#vim#set_variable(var) abort
|
||||
|
||||
let s:auto_generate_doc = get(a:var, 'auto_generate_doc', s:auto_generate_doc)
|
||||
|
||||
endfunction
|
||||
|
||||
function! s:language_specified_mappings() abort
|
||||
|
@ -10,7 +10,7 @@ CONTENTS *gtags-contents*
|
||||
==============================================================================
|
||||
INTRODUCTION *gtags-intro*
|
||||
|
||||
The gtags.vim plug-in script integrates the GNU GLOBAL source code tag system
|
||||
The gtags.vim plugin script integrates the GNU GLOBAL source code tag system
|
||||
with Vim. About the details, see http://www.gnu.org/software/global/.
|
||||
|
||||
==============================================================================
|
||||
|
@ -1,6 +1,6 @@
|
||||
""
|
||||
" @section Introduction, intro
|
||||
" The gtags.vim plug-in script integrates the GNU GLOBAL source code tag
|
||||
" The gtags.vim plugin script integrates the GNU GLOBAL source code tag
|
||||
" system with Vim. About the details, see http://www.gnu.org/software/global/.
|
||||
|
||||
scriptencoding utf-8
|
||||
|
@ -3833,7 +3833,7 @@ winexists({winid})
|
||||
==============================================================================
|
||||
VIM#COMMAND *SpaceVim-api-vim-command*
|
||||
|
||||
This api is for create complete function for custom vim command. This is
|
||||
This api is for creating complete function for custom vim command. This is
|
||||
example for create complete function for command TEST
|
||||
>
|
||||
let s:CMD = SpaceVim#api#import('vim#command')
|
||||
|
@ -10,6 +10,7 @@ lang: zh
|
||||
|
||||
- [模块简介](#模块简介)
|
||||
- [启用模块](#启用模块)
|
||||
- [模块选项](#模块选项)
|
||||
- [快捷键](#快捷键)
|
||||
|
||||
<!-- vim-markdown-toc -->
|
||||
@ -27,6 +28,10 @@ lang: zh
|
||||
name = "lang#vim"
|
||||
```
|
||||
|
||||
## 模块选项
|
||||
|
||||
- `auto_generate_doc`: 保存 vim 脚本文件时,自动生成对应的帮助文档,这一功能依赖外部命令 [vimdoc](https://github.com/google/vimdoc)。
|
||||
|
||||
## 快捷键
|
||||
|
||||
| 快捷键 | 功能描述 |
|
||||
|
@ -9,6 +9,7 @@ description: "This layer is for writting Vimscript, including code completion, s
|
||||
|
||||
- [Description](#description)
|
||||
- [Install](#install)
|
||||
- [Layer options](#layer-options)
|
||||
- [Key bindings](#key-bindings)
|
||||
|
||||
<!-- vim-markdown-toc -->
|
||||
@ -26,6 +27,11 @@ To use this configuration layer, update custom configuration file with:
|
||||
name = "lang#vim"
|
||||
```
|
||||
|
||||
## Layer options
|
||||
|
||||
- `auto_generate_doc`: generate help documentation automatically.
|
||||
To generate help documentation, you need to install [vimdoc](https://github.com/google/vimdoc)
|
||||
|
||||
## Key bindings
|
||||
|
||||
| Key Bindings | Descriptions |
|
||||
|
Loading…
x
Reference in New Issue
Block a user