Use modern autocmd_add() and autocmd_delete() APIs
This commit is contained in:
parent
30349936d7
commit
5d4b144604
1 changed files with 15 additions and 8 deletions
|
|
@ -147,11 +147,20 @@ export def Connect(room_name: string): void
|
|||
Send({type: 'connect', room: room_name})
|
||||
|
||||
# set up autocmds to send changes
|
||||
augroup CollabVim
|
||||
autocmd!
|
||||
autocmd TextChanged,TextChangedI * call SendBuffer()
|
||||
autocmd CursorMoved,CursorMovedI <buffer> call SendCursor()
|
||||
augroup END
|
||||
autocmd_add([
|
||||
{
|
||||
group: 'CollabVim',
|
||||
event: ['TextChanged', 'TextChangedI'],
|
||||
pattern: '*',
|
||||
cmd: 'SendBuffer()'
|
||||
},
|
||||
{
|
||||
group: 'CollabVim',
|
||||
event: ['CursorMoved', 'CursorMovedI'],
|
||||
bufnr: bufnr(),
|
||||
cmd: 'SendCursor()'
|
||||
}
|
||||
])
|
||||
enddef
|
||||
|
||||
export def Disconnect(): void
|
||||
|
|
@ -165,9 +174,7 @@ export def Disconnect(): void
|
|||
connected = false
|
||||
ready = false
|
||||
room = ""
|
||||
augroup CollabVim
|
||||
autocmd!
|
||||
augroup END
|
||||
autocmd_delete([{group: 'CollabVim'}])
|
||||
echom '[collab] disconnected'
|
||||
enddef
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue