feat(compe): implement nvim-compe integration

This commit is contained in:
Rainer Borene
2021-02-12 13:12:37 -03:00
parent 7237d8d8d6
commit fe42bd982f
3 changed files with 34 additions and 0 deletions

View File

@@ -123,6 +123,14 @@ Tmux complete is automatically integrated with the following plugins:
Unite tmuxcomplete/lines " opens a menu containing words from adjacent tmux windows and lines where they were found
```
- [nvim-compe](https://github.com/hrsh7th/nvim-compe)
You can use tmux complete as a compe source:
```vim
let g:compe.source.tmux = v:true
```
## Installation
Use your favorite plugin manager.

22
lua/compe_tmux/init.lua Normal file
View File

@@ -0,0 +1,22 @@
local compe = require'compe'
local Source = {}
function Source.get_metadata(_)
return {
priority = 10,
dup = 0,
menu = '[Tmux]'
}
end
function Source.determine(_, context)
return compe.helper.determine(context)
end
function Source.complete(_, context)
local items = vim.fn["tmuxcomplete#complete"](0, context.input)
context.callback({ items = items })
end
return Source

View File

@@ -20,6 +20,10 @@ function! s:init()
autocmd User asyncomplete_setup call asyncomplete#sources#tmuxcomplete#register(s:options)
autocmd User Ncm2Plugin call ncm2#sources#tmuxcomplete#register()
if exists('g:loaded_compe')
lua require'compe'.register_source('tmux', require'compe_tmux')
endif
endfunction
call s:init()