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

Add vimdoc support in lang#vim layer (#4010)

This commit is contained in:
Wang Shidong 2020-12-18 23:12:33 +08:00 committed by GitHub
parent 297f5ea431
commit 0052b27a15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 52 additions and 17 deletions

View File

@ -9,7 +9,7 @@
"" ""
" @section vim#command, api-vim-command " @section vim#command, api-vim-command
" @parentsection api " @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 " example for create complete function for command TEST
" > " >
" let s:CMD = SpaceVim#api#import('vim#command') " let s:CMD = SpaceVim#api#import('vim#command')

View File

@ -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:VIM = SpaceVim#api#import('vim')
let s:CMP = SpaceVim#api#import('vim#compatible')
"autocmds "autocmds
@ -62,7 +59,6 @@ function! SpaceVim#autocmds#init() abort
autocmd FocusGained * call s:reload_touchpad_status() autocmd FocusGained * call s:reload_touchpad_status()
endif endif
autocmd BufWritePre * call SpaceVim#plugins#mkdir#CreateCurrent() 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 * call SpaceVim#api#import('vim#highlight').hide_in_normal('EndOfBuffer')
autocmd ColorScheme gruvbox,jellybeans,nord,srcery,NeoSolarized call s:fix_colorschem_in_SpaceVim() autocmd ColorScheme gruvbox,jellybeans,nord,srcery,NeoSolarized call s:fix_colorschem_in_SpaceVim()
autocmd VimEnter * call SpaceVim#autocmds#VimEnter() autocmd VimEnter * call SpaceVim#autocmds#VimEnter()
@ -114,15 +110,6 @@ function! s:fixindentline() abort
let s:done = 1 let s:done = 1
endif endif
endfunction 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 function! s:fix_colorschem_in_SpaceVim() abort
if &background ==# 'dark' if &background ==# 'dark'

View File

@ -6,9 +6,19 @@
" License: GPLv3 " License: GPLv3
"============================================================================= "=============================================================================
if exists('s:auto_generate_doc')
finish
endif
let s:auto_generate_doc = 0
" Load SpaceVim API " Load SpaceVim API
let s:SID = SpaceVim#api#import('vim#sid') 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 function! SpaceVim#layers#lang#vim#plugins() abort
let plugins = [ let plugins = [
@ -40,6 +50,33 @@ function! SpaceVim#layers#lang#vim#config() abort
call SpaceVim#mapping#gd#add('vim','lookup#lookup') call SpaceVim#mapping#gd#add('vim','lookup#lookup')
call SpaceVim#mapping#space#regesit_lang_mappings('vim', function('s:language_specified_mappings')) 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*') 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 endfunction
function! s:language_specified_mappings() abort function! s:language_specified_mappings() abort

View File

@ -10,7 +10,7 @@ CONTENTS *gtags-contents*
============================================================================== ==============================================================================
INTRODUCTION *gtags-intro* 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/. with Vim. About the details, see http://www.gnu.org/software/global/.
============================================================================== ==============================================================================

View File

@ -1,6 +1,6 @@
"" ""
" @section Introduction, intro " @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/. " system with Vim. About the details, see http://www.gnu.org/software/global/.
scriptencoding utf-8 scriptencoding utf-8

View File

@ -3833,7 +3833,7 @@ winexists({winid})
============================================================================== ==============================================================================
VIM#COMMAND *SpaceVim-api-vim-command* 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 example for create complete function for command TEST
> >
let s:CMD = SpaceVim#api#import('vim#command') let s:CMD = SpaceVim#api#import('vim#command')

View File

@ -10,6 +10,7 @@ lang: zh
- [模块简介](#模块简介) - [模块简介](#模块简介)
- [启用模块](#启用模块) - [启用模块](#启用模块)
- [模块选项](#模块选项)
- [快捷键](#快捷键) - [快捷键](#快捷键)
<!-- vim-markdown-toc --> <!-- vim-markdown-toc -->
@ -27,6 +28,10 @@ lang: zh
name = "lang#vim" name = "lang#vim"
``` ```
## 模块选项
- `auto_generate_doc`: 保存 vim 脚本文件时,自动生成对应的帮助文档,这一功能依赖外部命令 [vimdoc](https://github.com/google/vimdoc)。
## 快捷键 ## 快捷键
| 快捷键 | 功能描述 | | 快捷键 | 功能描述 |

View File

@ -9,6 +9,7 @@ description: "This layer is for writting Vimscript, including code completion, s
- [Description](#description) - [Description](#description)
- [Install](#install) - [Install](#install)
- [Layer options](#layer-options)
- [Key bindings](#key-bindings) - [Key bindings](#key-bindings)
<!-- vim-markdown-toc --> <!-- vim-markdown-toc -->
@ -26,6 +27,11 @@ To use this configuration layer, update custom configuration file with:
name = "lang#vim" 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
| Key Bindings | Descriptions | | Key Bindings | Descriptions |