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

feat(chat): complete channels

This commit is contained in:
wsdjeg 2022-04-30 11:23:27 +08:00
parent ac44f30ec4
commit f0912bb7dd
2 changed files with 15 additions and 0 deletions

View File

@ -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

View File

@ -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