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

feat(chat): complete build-in protocol

This commit is contained in:
wsdjeg 2022-04-30 10:56:34 +08:00
parent 5aba3f35d6
commit ac44f30ec4

View File

@ -39,6 +39,7 @@ let s:messages = []
let s:close_windows_char = ["\<Esc>", "\<C-c>"]
let s:protocol = ''
let s:chatting_commands = ['/set_protocol', '/set_channel']
let s:all_protocols = ['gitter']
function! chat#windows#open() abort
if bufwinnr(s:name) < 0
if bufnr(s:name) != -1
@ -245,7 +246,12 @@ function! s:complete(base,num) abort
if a:base =~# '^/[a-z_A-Z]*$'
let rsl = filter(copy(s:chatting_commands), "v:val =~# a:base .'[^\ .]*'")
if len(rsl) > 0
return rsl[a:num % len(rsl)] . ' '
return rsl[a:num % len(rsl)]
endif
elseif a:base =~# '^/set_protocol\s*\w*$'
let rsl = filter(copy(s:all_protocols), "v:val =~# matchstr(a:base, '\w*$') .'[^\ .]*'")
if len(rsl) > 0
return matchstr(a:base, '^/set_protocol\s*') . rsl[a:num % len(rsl)]
endif
endif