mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-02 22:20:06 +08:00
feat(chat): complete channels
This commit is contained in:
parent
ac44f30ec4
commit
f0912bb7dd
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user