1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-15 08:09:11 +08:00

feat(chat): complete username after @

This commit is contained in:
wsdjeg 2022-05-01 15:32:52 +08:00
parent ff1f770ca9
commit 5d103f7984
2 changed files with 8 additions and 0 deletions

View File

@ -62,6 +62,7 @@ function! s:gitter_stdout(id, data, event) abort
let msg = s:JSON.json_decode(message)
call chat#windows#push({
\ 'user' : msg.fromUser.displayName,
\ 'username' : msg.fromUser.username,
\ 'room' : room,
\ 'msg' : msg.text,
\ 'time': s:format_time(msg.sent),
@ -144,6 +145,7 @@ function! s:gitter_fetch_exit(id, data, event) abort
for msg in messages
call add(msgs, {
\ 'user' : msg.fromUser.displayName,
\ 'username' : msg.fromUser.username,
\ 'room' : room,
\ 'msg' : msg.text,
\ 'time': s:format_time(msg.sent),

View File

@ -323,6 +323,12 @@ function! s:complete(base,num) abort
if len(rsl) > 0
return rsl[a:num % len(rsl)]
endif
elseif a:base =~# '@\S*$'
let nicks = uniq(map(filter(deepcopy(s:messages), 'v:val["room"] ==# s:current_channel'), '"@" . v:val.username'))
let rsl = filter(nicks, "v:val =~# '^' . matchstr(a:base, '@\\S*$')")
if len(rsl) > 0
return substitute(a:base, '@\S*$', 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