From f0912bb7ddef60400e4e8bbfdd3e8887bf5378f0 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sat, 30 Apr 2022 11:23:27 +0800 Subject: [PATCH] feat(chat): complete channels --- bundle/vim-chat/autoload/chat/gitter.vim | 5 +++++ bundle/vim-chat/autoload/chat/windows.vim | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/bundle/vim-chat/autoload/chat/gitter.vim b/bundle/vim-chat/autoload/chat/gitter.vim index 0a25591bb..e7bd5835c 100644 --- a/bundle/vim-chat/autoload/chat/gitter.vim +++ b/bundle/vim-chat/autoload/chat/gitter.vim @@ -119,6 +119,11 @@ function! s:gitter_fetch_exit(id, data, event) abort endfor endfunction +let s:channels = ['SpaceVim'] +function! chat#gitter#get_channels() abort + return s:channels +endfunction + function! chat#gitter#send(msg) abort call s:JOB.start(printf(g:gitter_send_command, substitute(a:msg, '"', '\\\"', 'g'))) endfunction diff --git a/bundle/vim-chat/autoload/chat/windows.vim b/bundle/vim-chat/autoload/chat/windows.vim index 1a897ff8c..1f8db78ad 100644 --- a/bundle/vim-chat/autoload/chat/windows.vim +++ b/bundle/vim-chat/autoload/chat/windows.vim @@ -253,6 +253,16 @@ function! s:complete(base,num) abort if len(rsl) > 0 return matchstr(a:base, '^/set_protocol\s*') . rsl[a:num % len(rsl)] endif + elseif a:base =~# '^/set_channel\s*\w*$' && !empty(s:protocol) + let channels = [] + try + let channels = chat#{s:protocol}#get_channels() + catch + endtry + let rsl = filter(copy(channels), "v:val =~# matchstr(a:base, '\w*$') .'[^\ .]*'") + if len(rsl) > 0 + return matchstr(a:base, '^/set_channel\s*') . rsl[a:num % len(rsl)] + endif endif return a:base