1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-13 13:10:39 +08:00

Add doc for vim#message api (#3805)

This commit is contained in:
Wang Shidong 2020-09-14 22:47:49 +08:00 committed by GitHub
parent 63c9c24681
commit e5f8b3c5f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 184 additions and 91 deletions

View File

@ -9,6 +9,12 @@
""
" @section vim#message, api-vim-message
" @parentsection api
" `vim#message` API provide functions for generating colored message in vim's
" command line.
"
" echo({hi}, {msg})
"
" print message with {hi} highlight group.
let s:self = {}
@ -22,6 +28,15 @@ function! s:self.echo(hl, msg) abort
endtry
endfunction
function! s:self.echon(hl, msg) abort
execute 'echohl' a:hl
try
echon a:msg
finally
echohl None
endtry
endfunction
function! s:self.echomsg(hl, msg) abort
execute 'echohl' a:hl
try
@ -42,20 +57,20 @@ function! s:self.warn(msg) abort
endfunction
function! s:self.confirm(msg) abort
echohl WarningMsg
echon a:msg . '? (y or n) '
echohl NONE
let rst = nr2char(getchar())
" clear the cmdline
redraw!
if rst =~? 'y' || rst == nr2char(13)
return 1
else
return 0
endif
echohl WarningMsg
echon a:msg . '? (y or n) '
echohl NONE
let rst = nr2char(getchar())
" clear the cmdline
redraw!
if rst =~? 'y' || rst == nr2char(13)
return 1
else
return 0
endif
endfunction
function! SpaceVim#api#vim#message#get() abort
return deepcopy(s:self)
return deepcopy(s:self)
endfunction

View File

@ -3670,6 +3670,13 @@ getjumplist()
==============================================================================
VIM#MESSAGE *SpaceVim-api-vim-message*
`vim#message` API provide functions for generating colored message in vim's
command line.
echo({hi}, {msg})
print message with {hi} highlight group.
==============================================================================
FAQ *SpaceVim-faq*

View File

@ -1,28 +1,28 @@
---
title: "cmdlinemenu api"
description: "cmdlinemenu API provides interface for making choices in a command line."
---
# [Available APIs](../) >> cmdlinemenu
<!-- vim-markdown-toc GFM -->
- [Intro](#intro)
<!-- vim-markdown-toc -->
## Intro
cmdlinemenu API provides interface for making choices in a command line.
here is an example for using this API:
```vim
let menu = SpaceVim#api#import('cmdlinemenu')
let ques = [
\ ['basic mode', function('s:basic_mode')],
\ ['dark powered mode', function('s:awesome_mode')],
\ ]
call menu.menu(ques)
```
---
title: "cmdlinemenu API"
description: "cmdlinemenu API provides interface for making choices in a command line."
---
# [Available APIs](../) >> cmdlinemenu
<!-- vim-markdown-toc GFM -->
- [Intro](#intro)
<!-- vim-markdown-toc -->
## Intro
cmdlinemenu API provides interface for making choices in a command line.
here is an example for using this API:
```vim
let menu = SpaceVim#api#import('cmdlinemenu')
let ques = [
\ ['basic mode', function('s:basic_mode')],
\ ['dark powered mode', function('s:awesome_mode')],
\ ]
call menu.menu(ques)
```

View File

@ -1,5 +1,5 @@
---
title: "file api"
title: "file API"
description: "file API provides some basic functions and values for current os."
---

View File

@ -1,5 +1,5 @@
---
title: "job api"
title: "job API"
description: "job API provides some basic functions for running a job"
---

View File

@ -1,5 +1,5 @@
---
title: "messletters api"
title: "messletters API"
description: "messletters API provides some basic functions for generating messletters"
---

View File

@ -1,5 +1,5 @@
---
title: "password api"
title: "password API"
description: "password API provides some basic functions for generating password"
---

View File

@ -1,5 +1,5 @@
---
title: "system api"
title: "system API"
description: "system API provides some basic functions and values for current os."
---

View File

@ -1,5 +1,5 @@
---
title: "transient state api"
title: "transient state API"
description: "transient state API provides some basic functions and values for current os."
---

View File

@ -1,5 +1,5 @@
---
title: "unicode#spinners api"
title: "unicode#spinners API"
description: "unicode#spinners API provides some basic functions for starting spinners timer"
---

View File

@ -1,5 +1,5 @@
---
title: "vim api"
title: "vim API"
description: "vim API provides general vim functions."
---

View File

@ -1,5 +1,5 @@
---
title: "vim#buffer api"
title: "vim#buffer API"
description: "vim#buffer API provides some basic functions for setting and getting config of vim buffer."
---
@ -14,10 +14,13 @@ description: "vim#buffer API provides some basic functions for setting and getti
## Intro
vim#buffer API provides some basic functions for setting and getting config of vim buffer.
`vim#buffer` API provides some basic functions for setting and getting config of vim buffer.
Here is an example for using this API:
```vim
let s:BUFFER = SpaceVim#api#import('vim#buffer')
let br = s:BUFFER.bufadd('')
call s:BUFFER.buf_set_lines(br, 1, -1, 0,['line 1', 'line 2', 'line 3'])
```
## Functions

View File

@ -1,5 +1,5 @@
---
title: "vim#command api"
title: "vim#command API"
description: "vim#command API provides some basic functions and values for creatting vim custom command."
---

View File

@ -1,5 +1,5 @@
---
title: "vim#highlight api"
title: "vim#highlight API"
description: "vim#highlight API provides some basic functions and values for getting and setting highlight info."
---

32
docs/api/vim/message.md Normal file
View File

@ -0,0 +1,32 @@
---
title: "vim#message API"
description: "vim#message API provides some basic functions to generate colored messages."
---
# [Available APIs](../../) >> vim#message
<!-- vim-markdown-toc GFM -->
- [Intro](#intro)
- [Functions](#functions)
<!-- vim-markdown-toc -->
## Intro
vim#message API provides some basic functions to generate colored messages.
```vim
let s:MSG = SpaceVim#api#import('vim#message)
call s:MSG.echom('String', 'hello world!')
```
## Functions
here is a list of functions implement in this api.
| function name | description |
| ---------------- | --------------------------------------- |
| `echo(hl, msg)` | print message with `hl` highlight group |
| `echom(hl, msg)` | run `echom` with `hl` highlight group |
| `echon(hl, msg)` | run `echon` with `hl` highlight group |

View File

@ -1,5 +1,5 @@
---
title: "vim#signatures api"
title: "vim#signatures API"
description: "vim#signatures API provides some basic functions for showing signatures info."
---

View File

@ -1,5 +1,5 @@
---
title: "vim#window api"
title: "vim#window API"
description: "vim#window API provides some basic functions for setting and getting config of vim window."
---

View File

@ -1,5 +1,5 @@
---
title: "web#html api"
title: "web#html API"
description: "web#html API provides some basic functions and values for parser html file."
---

View File

@ -1,5 +1,5 @@
---
title: "web#http api"
title: "web#http API"
description: "web#http API provides some basic functions and values for http request"
---

View File

@ -1,5 +1,5 @@
---
title: "web#xml api"
title: "web#xml API"
description: "web#xml API provides some basic functions and values for parser xml file."
---

View File

@ -1,10 +1,10 @@
---
title: "公共 API"
description: "SpaceVim 公共 API 提供了一套开发插件的公共函数,以及 Neovim 和 Vim 的兼容组件。"
title: "可用接口"
description: "SpaceVim 接口函数库提供了一套开发插件的公共接口,以及 Neovim 和 Vim 的兼容组件。"
lang: zh
---
# [主页](../) >> 公共 API
# [主页](../) >> 可用接口
<!-- vim-markdown-toc GFM -->
@ -56,6 +56,7 @@ echom s:file.pathSeparator
| [unicode#spinners](unicode/spinners/) | unicode#spinners API 可启用一个定时器,根据指定的名称定时更新进度条符号 |
| [vim#command](vim/command/) | vim#command API 提供一些设置和获取 Vim 命令的基础函数。 |
| [vim#highlight](vim/highlight/) | vim#highlight API 提供一些设置和获取 Vim 高亮信息的基础函数。 |
| [vim#message](vim/message/) | vim#message API 提供一些设置和获取 Vim 提示消息的函数。 |
| [vim#signatures](vim/signatures/) | vim#signatures API 提供一些设置和获取 Vim 提示消息的函数。 |
<!-- SpaceVim api cn list end -->

View File

@ -1,21 +1,30 @@
---
title: "cmdlinemenu 函数"
description: "cmdlinemenu 函数提供了一套通过命令行进行选择的快捷接口。"
title: "cmdlinemenu 接口"
description: "cmdlinemenu 接口函数提供了一套通过命令行进行选择的快捷接口。"
lang: zh
---
# [公共 API](../) >> cmdlinemenu
# [可用接口](../) >> cmdlinemenu
<!-- vim-markdown-toc GFM -->
- [简介](#简介)
- [函数列表](#函数列表)
- [使用示例](#使用示例)
<!-- vim-markdown-toc -->
## 简介
cmdlinemenu 函数提供了一套通过命令行进行选择的快捷接口。
`cmdlinemenu` 接口函数提供了一套通过命令行进行选择的快捷接口。
## 函数列表
| 函数名称 | 功能描述 |
| ------------ | ------------------------------ |
| `menu(opts)` | 基于 `opts` 定义,打开选择菜单 |
## 使用示例
以下是一个使用该函数的示例:
@ -27,5 +36,3 @@ let ques = [
\ ]
call menu.menu(ques)
```

View File

@ -1,9 +1,9 @@
---
title: "data#dict api"
description: "data#dict API 提供了一些处理字典变量的常用方法,包括基础的增删改查。"
title: "data#dict 接口"
description: "data#dict 接口提供了一些处理字典变量的常用方法,包括基础的增删改查。"
---
# [Available APIs](../../) >> data#dict
# [可用接口](../../) >> data#dict
<!-- vim-markdown-toc GFM -->
@ -14,7 +14,7 @@ description: "data#dict API 提供了一些处理字典变量的常用方法,
## 简介
`data#dict` API 提供了一些处理字典类型变量的方法,包括基础的增删改查。
`data#dict` 接口提供了一些处理字典类型变量的方法,包括基础的增删改查。
```vim
let s:DICT = SpaceVim#api#import('data#dict')

View File

@ -4,7 +4,7 @@ description: "文件函数提供了基础的文件读写相关函数,兼容不
lang: zh
---
# [公共 API](../) >> file
# [可用接口](../) >> file
<!-- vim-markdown-toc GFM -->

View File

@ -1,10 +1,10 @@
---
title: "异步协同 API"
description: "兼容 neovim 和 vim 的异步协同 API,对于旧版 vim 采用非异步机制"
title: "job 接口"
description: "兼容 neovim 和 vim 的异步协同接口,对于旧版 vim 采用非异步机制"
lang: zh
---
# [公共 API](../) >> job
# [可用接口](../) >> job
<!-- vim-markdown-toc GFM -->
@ -16,7 +16,7 @@ lang: zh
#### 简介
`job`API 提供了一套可以兼容 neovim 和 vim 的异步控制机制,具体实现模型是参考的 neovim 的模型。
`job` 接口提供了一套可以兼容 neovim 和 vim 的异步控制机制,具体实现模型是参考的 neovim 的模型。
#### 函数及变量

View File

@ -4,7 +4,7 @@ description: "system 函数提供了系统相关函数,包括判断当前系
lang: zh
---
# [公共 API](../) >> system
# [可用接口](../) >> system
<!-- vim-markdown-toc GFM -->

View File

@ -1,10 +1,10 @@
---
title: "unicode#spinners api"
title: "unicode#spinners 接口"
description: "unicode#spinners API 可启用一个定时器,根据指定的名称定时更新进度条符号"
lang: zh
---
# [公共 API](../../) >> unicode#spinners
# [可用接口](../../) >> unicode#spinners
<!-- vim-markdown-toc GFM -->

View File

@ -1,10 +1,10 @@
---
title: "vim#command api"
description: "vim#command API 提供一些设置和获取 Vim 命令的基础函数。"
title: "vim#command 接口"
description: "vim#command 接口提供一些设置和获取 Vim 命令的基础函数。"
lang: zh
---
# [可用 APIs](../../) >> vim#command
# [可用接口](../../) >> vim#command
<!-- vim-markdown-toc GFM -->
@ -15,7 +15,7 @@ lang: zh
## 简介
vim#command API 提供一些设置和获取 Vim 命令的基础函数。
`vim#command` 接口提供一些设置和获取 Vim 命令的基础函数。
```vim
let s:CMD = SpaceVim#api#import('vim#command')

View File

@ -1,5 +1,5 @@
---
title: "vim#highlight api"
title: "vim#highlight 接口"
description: "vim#highlight API 提供一些设置和获取 Vim 高亮信息的基础函数。"
lang: zh
---
@ -8,16 +8,16 @@ lang: zh
<!-- vim-markdown-toc GFM -->
- [Intro](#intro)
- [Functions](#functions)
- [简介](#简介)
- [函数列表](#函数列表)
<!-- vim-markdown-toc -->
## Intro
## 简介
vim#highlight API provides some basic functions and values for getting and setting highlight info.
`vim#highlight` 接口提供了基础的设置高亮颜色的函数库可用于定义和解析高亮组highlight group
## Functions
## 函数列表
| function name | description |
| ------------------------- | ---------------------------------------- |
@ -28,3 +28,5 @@ vim#highlight API provides some basic functions and values for getting and setti
| `syntax_at(...)` | get syntax info at a position |
| `syntax_of(pattern, ...)` | get syntax info of a pattern |

View File

@ -0,0 +1,26 @@
---
title: "vim#message 接口"
description: "vim#message API 提供一些设置和获取 Vim 提示消息的函数。"
lang: zh
---
# [可用接口](../../) >> vim#message
<!-- vim-markdown-toc GFM -->
- [模块简介](#模块简介)
- [函数及变量](#函数及变量)
<!-- vim-markdown-toc -->
## 模块简介
`vim#message` API 提供一些设置和获取 Vim 提示消息的函数。
## 函数及变量
| 函数名称 | 功能描述 |
| ---------------- | ------------------------- |
| `echo(hl, msg)` | 使用 `hl` 高亮打印消息 |
| `echom(hl, msg)` | 使用`hl` 高亮运行 `echom` |
| `echon(hl, msg)` | 使用`hl` 高亮运行 `echon` |

View File

@ -1,10 +1,10 @@
---
title: "vim#signatures api"
title: "vim#signatures 接口"
description: "vim#signatures API 提供一些设置和获取 Vim 提示消息的函数。"
lang: zh
---
# [可用 APIs](../../) >> vim#signatures
# [可用接口](../../) >> vim#signatures
<!-- vim-markdown-toc GFM -->