Skip to content

Commit 3534e62

Browse files
committed
add doc #354
1 parent 64d7bbc commit 3534e62

File tree

2 files changed

+126
-42
lines changed

2 files changed

+126
-42
lines changed

README-cn.md

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ https://github.com/user-attachments/assets/30c265f3-e65c-47d0-8762-e9e8250d7b4d
1717

1818
- 支持 [lsp]([language-server-protocol](https://github.com/microsoft/language-server-protocol)). 通过单命令安装 LSP 服务。
1919
- 支持关键词和字典
20-
- 通过 [Snippets](https://github.com/neovim/nvim-lspconfig/wiki/Snippets) 来兼容代码片段的补全
20+
- 代码片段的补全
2121
- 高性能
2222
- 基于 TabNine 的 AI 补全助手
2323

@@ -28,6 +28,7 @@ Vim 8.2 及以上版本,Neovim 0.6.0 及以上,支持 MacOS/Linux/FreeBSD。
2828
lua 配置(基于 Packer.nvim ):
2929

3030
```lua
31+
-- lua
3132
use { 'jayli/vim-easycomplete', requires = {'SirVer/ultisnips'}}
3233
-- Tabnine AI 补全支持, 默认值 1
3334
-- 安装 tabnine ":InstallLspServer tabnine"
@@ -53,6 +54,7 @@ vim.keymap.set('n', 'gb', ':BackToOriginalBuffer<CR>')
5354
Vimscript 配置(基于vim-plug):
5455

5556
```vim
57+
" vim
5658
Plug 'jayli/vim-easycomplete'
5759
Plug 'SirVer/ultisnips'
5860
" Tabnine AI 补全支持, 默认值 1
@@ -79,7 +81,7 @@ noremap gb :BackToOriginalBuffer<CR>
7981

8082
## 使用
8183

82-
`Tab` 触发匹配,并通过 `Tab` 来选择下一个匹配项,`Shift-Tab` 选择上一个匹配项。`Ctrl-]` 跳转到定义处,`Ctrl-t`跳回(和 tags 跳转快捷键一致)。
84+
输入过程中自动显示匹配菜单,并通过 `Tab` 来选择下一个匹配项,`Shift-Tab` 选择上一个匹配项。`Ctrl-]` 跳转到定义处,`Ctrl-t`跳回(和 tags 跳转快捷键一致)。
8385

8486
使用`Ctrl-N`/`Shift-Ctrl-N` 跳转到下一个/上一个错误提示位置。
8587

@@ -222,7 +224,10 @@ LSP 服务会安装在本地路径: `~/.config/vim-easycomplete/servers`。
222224

223225
自定义增加某种 lsp 所支持的语言类型,通常情况下不需要这么做:
224226

227+
vimscript
228+
225229
```vim
230+
" vim
226231
let g:easycomplete_filetypes = {
227232
\ "sh": {
228233
\ "whitelist": ["shell"]
@@ -233,16 +238,40 @@ let g:easycomplete_filetypes = {
233238
\ }
234239
```
235240

241+
luascript
242+
243+
```lua
244+
-- lua
245+
vim.g.easycomplete_filetypes = {
246+
sh = {
247+
whitelist = {"shell"}
248+
},
249+
r = {
250+
whitelist = {"rmd", "rmarkdown"}
251+
}
252+
}
253+
```
254+
236255
### Snippets 代码片段支持
237256

238257
Vim-Easycomplete 的代码片段支持依赖 [ultisnips](https://github.com/SirVer/ultisnips)[LuaSnip](https://github.com/L3MON4D3/LuaSnip)。只需在依赖字段中引用进来即可。性能考虑,推荐优先使用 `L3MON4D3/LuaSnip`(只支持 nvim),兼容考虑使用 `SirVer/ultisnips`(支持 vim/nvim)。 你可以增加 snippets 目录到 &runtimepath 中。
239258

240259
你可以设置自己的 snippets 路径:
241260

261+
vimscript
262+
242263
```vim
264+
" vim
243265
let g:easycomplete_custom_snippet = "./path/to/your/snippets"
244266
```
245267

268+
luascript
269+
270+
```lua
271+
-- lua
272+
vim.g.easycomplete_custom_snippet = "./path/to/your/snippets"
273+
```
274+
246275
## AI 编程助手
247276

248277
除了补全菜单中包含 AI 建议项之外,插件还支持行内 AI 补全提醒。有这几种方案:
@@ -260,15 +289,26 @@ Vim-easycomplete 默认支持 Tabnine。Tabnine 是本地运算补全结果的
260289
- *line_limit*: 参与计算的行数. 越小速度越快,越大补全更准. (默认: 1000)
261290
- *max_num_result*: 在补全菜单中显示几个推荐项. (默认: 3)
262291

263-
基于 vimscript 配置:
292+
vimscript
264293

265294
```vim
295+
" vim
266296
let g:easycomplete_tabnine_config = {
267297
\ 'line_limit': 1000,
268298
\ 'max_num_result' : 3,
269299
\ }
270300
```
271301

302+
luascript
303+
304+
```lua
305+
-- lua
306+
vim.g.easycomplete_tabnine_config = {
307+
line_limit = 1000,
308+
max_num_result = 3
309+
}
310+
```
311+
272312
TabNine 不使用 APIKey 就可以运行。如果你是 Tabnine 的付费用户,可以配置 API key 获得行内补全的增强。通过在文件中敲入魔术字符`Tabnine::config`来激活配置面板。[文档](https://www.tabnine.com/faq#special_commands)
273313

274314
启用 Tabnine 的行内补全: `let g:easycomplete_tabnine_suggestion = 1`.

README.md

Lines changed: 83 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,18 @@ It contains these features:
1818
- Full [lsp]([language-server-protocol](https://github.com/microsoft/language-server-protocol)) support. Easy to install LSP Server with one command
1919
- Keywords/Directory support
2020
- Implemented based on pure vimscript
21-
- Snippet support via [Snippets](https://github.com/neovim/nvim-lspconfig/wiki/Snippets).
21+
- Snippet support.
2222
- Fast performance
2323
- AI coding assistant via [tabnine](#TabNine-Support).
2424

2525
## Installation
2626

27-
Requires Vim 8.2 or higher version on MacOS/Linux/FreeBSD. Neovim 0.6.0 or higher.
27+
Requires Vim 8.2 or higher version on MacOS/Linux/FreeBSD. Neovim 0.7.0 or higher.
2828

2929
Lua config with Packer.nvim:
3030

3131
```lua
32+
-- lua
3233
use { 'jayli/vim-easycomplete', requires = {'L3MON4D3/LuaSnip'}}
3334
-- For snippet support, 'SirVer/ultisnips' is an alternative option
3435
-- Tabnine aicoding support, default is 1
@@ -57,6 +58,7 @@ L3MON4D3/LuaSnip
5758

5859

5960
```vim
61+
" vim
6062
Plug 'jayli/vim-easycomplete'
6163
Plug 'L3MON4D3/LuaSnip' " 'SirVer/ultisnips' is a backup option
6264
" Tabnine aicoding support, default is 1
@@ -82,9 +84,11 @@ Run `:PlugInstall`.
8284

8385
## Useage
8486

85-
Use `Tab` to trigger the completion suggestions and select matched items. Use `Ctrl-]` for definition jumping, `Ctrl-t` for jumping back (Same as tags jumping).
86-
87-
Use `Ctrl-N`/`Shift-Ctrl-N` to jump to the next/previous diagnostic position.
87+
- `Tab`/`S-Tab`: select next/previous matched items.
88+
- `Ctrl-]`: definition jumping
89+
- `Ctrl-t`: jumping back (Same as tags jumping).
90+
- `Ctrl-N`/`Shift-Ctrl-N`: jump to the next/previous diagnostic position.
91+
- `Ctrl-E`: close complete menu.
8892

8993
Other optional configurations:
9094

@@ -152,8 +156,8 @@ Typing `:h easycomplete` for help.
152156

153157
There are tow ways to install lsp server.
154158

155-
1. For vim/nvim: use command`:InstallLspServer`.
156-
2. For nvim: use [mason.nvim](https://github.com/mason-org/mason.nvim), Do `:MasonInstall {lsp-server-name}`
159+
1. vim/nvim: Via command`:InstallLspServer`.
160+
2. nvim: Via [mason.nvim](https://github.com/mason-org/mason.nvim), Do `:MasonInstall {lsp-server-name}`
157161

158162
LSP Server will all be installed in local path: `~/.config/vim-easycomplete/servers`.
159163

@@ -164,36 +168,36 @@ LSP Server will all be installed in local path: `~/.config/vim-easycomplete/serv
164168

165169
All supported languages:
166170

167-
| Plugin Name | Languages | Language Server | Installer | Requirements | nvim-lsp-installer support|
168-
|-------------|-----------|:------------------------:|:------------------:|:------------:|:-------------------------:|
169-
| directory | directory | No Need | Integrated | None | - |
170-
| buf | buf & dict| No Need | Integrated | None | - |
171-
| snips | Snippets | ultisnips/LuaSnip | Integrated | python3/lua | - |
172-
| ts | js/ts | tsserver | Yes | node/npm | Yes |
173-
| deno | js/ts | denols | Yes | deno | Yes |
174-
| tn | TabNine | TabNine | Yes | None | No |
175-
| vim | Vim | vimls | Yes | node/npm | Yes |
176-
| cpp | C/C++/OC | clangd | Yes | None | Yes |
177-
| css | CSS | cssls | Yes | node/npm | Yes |
178-
| html | HTML | html | Yes | node/npm | Yes |
179-
| yml | YAML | yamlls | Yes | node/npm | Yes |
180-
| xml | Xml | lemminx | Yes | java/jdk | Yes |
181-
| sh | Bash | bashls | Yes | node/npm | Yes |
182-
| json | JSON | json-languageserver | Yes | node/npm | No |
183-
| php | php | intelephense | Yes | node/npm | Yes |
184-
| dart | dart | dartls | Yes | None | Yes |
185-
| py | Python | pylsp | Yes | python3/pip3 | Yes |
186-
| java | Java | jdtls | Yes | java11/jdk | Yes |
187-
| go | Go | gopls | Yes | go | Yes |
188-
| r | R | r-languageserver | Yes | R | No |
189-
| rb | Ruby | solargraph | Yes | ruby/bundle | No |
190-
| lua | Lua | `sumneko_lua` | Yes | Lua | Yes |
191-
| nim | Nim | nimls | Yes | nim/nimble | Yes |
192-
| rust | Rust | `rust_analyzer` | Yes | None | Yes |
193-
| kt | Kotlin | `kotlin_language_server` | Yes | java/jdk | Yes |
194-
| grvy | Groovy | groovyls | Yes | java/jdk | Yes |
195-
| cmake | cmake | cmake | Yes | python3/pip3 | Yes |
196-
| c# | C# | omnisharp-lsp | Yes | None | No |
171+
| Plugin Name | Languages | Language Server | Installer | Requirements |
172+
|-------------|-----------|:------------------------:|:------------------:|:------------:|
173+
| directory | directory | No Need | Integrated | None |
174+
| buf | buf & dict| No Need | Integrated | None |
175+
| snips | Snippets | ultisnips/LuaSnip | Integrated | python3/lua |
176+
| ts | js/ts | tsserver | Yes | node/npm |
177+
| deno | js/ts | denols | Yes | deno |
178+
| tn | TabNine | TabNine | Yes | None |
179+
| vim | Vim | vimls | Yes | node/npm |
180+
| cpp | C/C++/OC | clangd | Yes | None |
181+
| css | CSS | cssls | Yes | node/npm |
182+
| html | HTML | html | Yes | node/npm |
183+
| yml | YAML | yamlls | Yes | node/npm |
184+
| xml | Xml | lemminx | Yes | java/jdk |
185+
| sh | Bash | bashls | Yes | node/npm |
186+
| json | JSON | json-languageserver | Yes | node/npm |
187+
| php | php | intelephense | Yes | node/npm |
188+
| dart | dart | dartls | Yes | None |
189+
| py | Python | pylsp | Yes | python3/pip3 |
190+
| java | Java | jdtls | Yes | java11/jdk |
191+
| go | Go | gopls | Yes | go |
192+
| r | R | r-languageserver | Yes | R |
193+
| rb | Ruby | solargraph | Yes | ruby/bundle |
194+
| lua | Lua | `sumneko_lua` | Yes | Lua |
195+
| nim | Nim | nimls | Yes | nim/nimble |
196+
| rust | Rust | `rust_analyzer` | Yes | None |
197+
| kt | Kotlin | `kotlin_language_server` | Yes | java/jdk |
198+
| grvy | Groovy | groovyls | Yes | java/jdk |
199+
| cmake | cmake | cmake | Yes | python3/pip3 |
200+
| c# | C# | omnisharp-lsp | Yes | None |
197201

198202
More info about supported language:
199203

@@ -227,7 +231,10 @@ More info about supported language:
227231

228232
You can add filetypes whitelist for specified language plugin. In most cases, it is not necessary to do so:
229233

234+
vimscript
235+
230236
```vim
237+
" vim
231238
let g:easycomplete_filetypes = {
232239
\ "sh": {
233240
\ "whitelist": ["shell"]
@@ -238,17 +245,41 @@ let g:easycomplete_filetypes = {
238245
\ }
239246
```
240247

248+
luascript
249+
250+
```lua
251+
-- lua
252+
vim.g.easycomplete_filetypes = {
253+
sh = {
254+
whitelist = {"shell"}
255+
},
256+
r = {
257+
whitelist = {"rmd", "rmarkdown"}
258+
}
259+
}
260+
```
261+
241262
### Snippet Support
242263

243264
The snippet completion of Vim-EasyComplete relies on ultisnip or luasnip. They are both compatible with Vim-EasyComplete by simply place it in the dependent field. UltiSnips required python3 installed. You can use your own snippets path to replace the default snippets.
244265

266+
vimscript
267+
245268
```vim
269+
" vim
246270
let g:easycomplete_custom_snippet = "./path/to/your/snippets"
247271
```
248272

249-
[LuaSnip](https://github.com/L3MON4D3/LuaSnip) is better choice for nvim.
273+
luascript
274+
275+
```lua
276+
-- lua
277+
vim.g.easycomplete_custom_snippet = "./path/to/your/snippets"
278+
```
250279

251-
You can add your own snippet directory to `&runtimepath`.
280+
You can alse add your own snippet directory to `&runtimepath`.
281+
282+
[LuaSnip](https://github.com/L3MON4D3/LuaSnip) is better choice for nvim.
252283

253284
## AI Coding Inline Suggestion
254285

@@ -265,13 +296,26 @@ Config TabNine via `g:easycomplete_tabnine_config` witch contains two properties
265296
- *line_limit*: The number of lines before and after the cursor to send to TabNine. If the option is smaller, the performance may be improved. (default: 1000)
266297
- *max_num_result*: Max results from TabNine showing in the complete menu. (default: 3)
267298

299+
vimscript
300+
268301
```vim
302+
" vim
269303
let g:easycomplete_tabnine_config = {
270304
\ 'line_limit': 1000,
271305
\ 'max_num_result' : 3,
272306
\ }
273307
```
274308

309+
luascript
310+
311+
```lua
312+
-- lua
313+
vim.g.easycomplete_tabnine_config = {
314+
line_limit = 1000,
315+
max_num_result = 3
316+
}
317+
```
318+
275319
TabNine works well without APIKey. If you have a Tabnine's Pro API key or purchased a subscription license. To configure, you'll need to use the [TabNine' magic string](https://www.tabnine.com/faq#special_commands) (Type `Tabnine::config` in insert mode) to open the configuration panel.
276320

277321
Enable TabNine inline suggestion: `let g:easycomplete_tabnine_suggestion = 1`.

0 commit comments

Comments
 (0)