From 2fc1389cce91f5da6862524708cb47c4e0adbabe Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sat, 30 Apr 2022 19:02:32 +0800 Subject: [PATCH] fix(indent): fix indent --- bundle/vim-chat/autoload/chat/windows.vim | 300 +++++++++++----------- 1 file changed, 150 insertions(+), 150 deletions(-) diff --git a/bundle/vim-chat/autoload/chat/windows.vim b/bundle/vim-chat/autoload/chat/windows.vim index 730aa8ee8..3d5aebf4b 100644 --- a/bundle/vim-chat/autoload/chat/windows.vim +++ b/bundle/vim-chat/autoload/chat/windows.vim @@ -184,7 +184,7 @@ function! s:echon() abort echohl None | echon s:c_end endfunction -fu! s:windowsinit() abort +function! s:windowsinit() abort " option setl fileformat=unix setl fileencoding=utf-8 @@ -205,167 +205,167 @@ fu! s:windowsinit() abort setl nofoldenable setl cursorline setl filetype=vimchat - endf +endfunction - let s:enter_history = [] - function! s:enter() abort - if s:c_begin . s:c_char . s:c_end =~# '/quit\s*' - let s:quit_chating_win = 1 - let s:c_end = '' - let s:c_char = '' - let s:c_begin = '' - return - elseif s:c_begin . s:c_char . s:c_end =~# '/set_protocol\s*' - let s:protocol = matchstr(s:c_begin . s:c_char . s:c_end, '/set_protocol\s*\zs.*') - let s:c_end = '' - let s:c_char = '' - let s:c_begin = '' - try - call chat#{s:protocol}#get_channels() - if !has_key(s:opened_channels, s:protocol) - let s:opened_channels[s:protocol] = [] - endif - catch - endtry - call s:update_msg_screen() - return - elseif s:c_begin . s:c_char . s:c_end =~# '/set_channel\s*' - if !empty(s:protocol) - let s:current_channel = matchstr(s:c_begin . s:c_char . s:c_end, '/set_channel\s*\zs.*') - if !empty(s:current_channel) - call chat#{s:protocol}#enter_room(s:current_channel) - if index(s:opened_channels[s:protocol], s:current_channel) ==# -1 - call add(s:opened_channels[s:protocol], s:current_channel) - endif - endif - endif - let s:c_end = '' - let s:c_char = '' - let s:c_begin = '' - call s:update_msg_screen() - return - endif - call add(s:enter_history, s:c_begin . s:c_char . s:c_end) - call s:send(s:c_begin . s:c_char . s:c_end) +let s:enter_history = [] +function! s:enter() abort + if s:c_begin . s:c_char . s:c_end =~# '/quit\s*' + let s:quit_chating_win = 1 let s:c_end = '' let s:c_char = '' let s:c_begin = '' - endfunction - - let s:complete_num = 0 - 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 + elseif s:c_begin . s:c_char . s:c_end =~# '/set_protocol\s*' + let s:protocol = matchstr(s:c_begin . s:c_char . s:c_end, '/set_protocol\s*\zs.*') + let s:c_end = '' + let s:c_char = '' + let s:c_begin = '' + try + call chat#{s:protocol}#get_channels() + if !has_key(s:opened_channels, s:protocol) + let s:opened_channels[s:protocol] = [] 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 - 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)] + catch + endtry + call s:update_msg_screen() + return + elseif s:c_begin . s:c_char . s:c_end =~# '/set_channel\s*' + if !empty(s:protocol) + let s:current_channel = matchstr(s:c_begin . s:c_char . s:c_end, '/set_channel\s*\zs.*') + if !empty(s:current_channel) + call chat#{s:protocol}#enter_room(s:current_channel) + if index(s:opened_channels[s:protocol], s:current_channel) ==# -1 + call add(s:opened_channels[s:protocol], s:current_channel) + endif endif endif + let s:c_end = '' + let s:c_char = '' + let s:c_begin = '' + call s:update_msg_screen() + return + endif + call add(s:enter_history, s:c_begin . s:c_char . s:c_end) + call s:send(s:c_begin . s:c_char . s:c_end) + let s:c_end = '' + let s:c_char = '' + let s:c_begin = '' +endfunction +let s:complete_num = 0 +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)] + 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 + 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 + +endfunction +let s:complete_input_history_num = [0,0] +function! s:complete_input_history(base,num) abort + let results = filter(copy(s:enter_history), "v:val =~# '^' . a:base") + if len(results) > 0 + call add(results, a:base) + let index = ((len(results) - 1) - a:num[0] + a:num[1]) % len(results) + return results[index] + else return a:base + endif +endfunction - endfunction - let s:complete_input_history_num = [0,0] - function! s:complete_input_history(base,num) abort - let results = filter(copy(s:enter_history), "v:val =~# '^' . a:base") - if len(results) > 0 - call add(results, a:base) - let index = ((len(results) - 1) - a:num[0] + a:num[1]) % len(results) - return results[index] - else - return a:base +function! s:init_hi() abort + if get(s:, 'init_hi_done', 0) == 0 + " current channel + hi! ChattingHI1 ctermbg=003 ctermfg=Black guibg=#fabd2f guifg=#282828 + " channel with new msg + hi! ChattingHI2 ctermbg=005 ctermfg=Black guibg=#b16286 guifg=#282828 + " normal channel + hi! ChattingHI3 ctermbg=007 ctermfg=Black guibg=#8ec07c guifg=#282828 + " end + hi! ChattingHI4 ctermbg=243 guibg=#7c6f64 + " current channel + end + hi! ChattingHI5 guibg=#7c6f64 guifg=#fabd2f + " current channel + new msg channel + hi! ChattingHI6 guibg=#b16286 guifg=#fabd2f + " current channel + normal channel + hi! ChattingHI7 guibg=#8ec07c guifg=#fabd2f + " new msg channel + end + hi! ChattingHI8 guibg=#7c6f64 guifg=#b16286 + " new msg channel + current channel + hi! ChattingHI9 guibg=#fabd2f guifg=#b16286 + " new msg channel + normal channel + hi! ChattingHI10 guibg=#8ec07c guifg=#b16286 + " new msg channel + new msg channel + hi! ChattingHI11 guibg=#b16286 guifg=#b16286 + " normal channel + end + hi! ChattingHI12 guibg=#7c6f64 guifg=#8ec07c + " normal channel + normal channel + hi! ChattingHI13 guibg=#8ec07c guifg=#8ec07c + " normal channel + new msg channel + hi! ChattingHI14 guibg=#b16286 guifg=#8ec07c + " normal channel + current channel + hi! ChattingHI15 guibg=#fabd2f guifg=#8ec07c + let s:init_hi_done = 1 + endif +endfunction +function! s:update_statusline() abort + let &l:statusline = SpaceVim#layers#core#statusline#get(1) +endfunction + +function! s:previous_channel() abort + if !empty(s:protocol) && has_key(s:opened_channels, s:protocol) && index(s:opened_channels[s:protocol], s:current_channel) !=# -1 + let index = index(s:opened_channels[s:protocol], s:current_channel) + let index -=1 + let s:current_channel = s:current_channel[s:protocol][index] + call chat#{s:protocol}#enter_room(s:current_channel) + call s:update_msg_screen() + call s:update_statusline() + endif +endfunction + +function! s:next_channel() abort + if !empty(s:protocol) && has_key(s:opened_channels, s:protocol) + let index = index(s:opened_channels[s:protocol], s:current_channel) + let index += 1 + if index ==# len(s:opened_channels[s:protocol]) + let index = 0 endif - endfunction + let s:current_channel = s:current_channel[s:protocol][index] + call chat#{s:protocol}#enter_room(s:current_channel) + call s:update_msg_screen() + call s:update_statusline() + endif +endfunction - function! s:init_hi() abort - if get(s:, 'init_hi_done', 0) == 0 - " current channel - hi! ChattingHI1 ctermbg=003 ctermfg=Black guibg=#fabd2f guifg=#282828 - " channel with new msg - hi! ChattingHI2 ctermbg=005 ctermfg=Black guibg=#b16286 guifg=#282828 - " normal channel - hi! ChattingHI3 ctermbg=007 ctermfg=Black guibg=#8ec07c guifg=#282828 - " end - hi! ChattingHI4 ctermbg=243 guibg=#7c6f64 - " current channel + end - hi! ChattingHI5 guibg=#7c6f64 guifg=#fabd2f - " current channel + new msg channel - hi! ChattingHI6 guibg=#b16286 guifg=#fabd2f - " current channel + normal channel - hi! ChattingHI7 guibg=#8ec07c guifg=#fabd2f - " new msg channel + end - hi! ChattingHI8 guibg=#7c6f64 guifg=#b16286 - " new msg channel + current channel - hi! ChattingHI9 guibg=#fabd2f guifg=#b16286 - " new msg channel + normal channel - hi! ChattingHI10 guibg=#8ec07c guifg=#b16286 - " new msg channel + new msg channel - hi! ChattingHI11 guibg=#b16286 guifg=#b16286 - " normal channel + end - hi! ChattingHI12 guibg=#7c6f64 guifg=#8ec07c - " normal channel + normal channel - hi! ChattingHI13 guibg=#8ec07c guifg=#8ec07c - " normal channel + new msg channel - hi! ChattingHI14 guibg=#b16286 guifg=#8ec07c - " normal channel + current channel - hi! ChattingHI15 guibg=#fabd2f guifg=#8ec07c - let s:init_hi_done = 1 - endif - endfunction - function! s:update_statusline() abort - let &l:statusline = SpaceVim#layers#core#statusline#get(1) - endfunction +function! s:send(msg) abort + if !empty(s:protocol) && !empty(s:current_channel) + call chat#{s:protocol}#send(s:current_channel, a:msg) + endif +endfunction - function! s:previous_channel() abort - if !empty(s:protocol) && has_key(s:opened_channels, s:protocol) && index(s:opened_channels[s:protocol], s:current_channel) !=# -1 - let index = index(s:opened_channels[s:protocol], s:current_channel) - let index -=1 - let s:current_channel = s:current_channel[s:protocol][index] - call chat#{s:protocol}#enter_room(s:current_channel) - call s:update_msg_screen() - call s:update_statusline() - endif - endfunction +function! chat#windows#status() abort - function! s:next_channel() abort - if !empty(s:protocol) && has_key(s:opened_channels, s:protocol) - let index = index(s:opened_channels[s:protocol], s:current_channel) - let index += 1 - if index ==# len(s:opened_channels[s:protocol]) - let index = 0 - endif - let s:current_channel = s:current_channel[s:protocol][index] - call chat#{s:protocol}#enter_room(s:current_channel) - call s:update_msg_screen() - call s:update_statusline() - endif - endfunction + return { + \ 'channel' : s:current_channel, + \ 'protocol' : s:protocol, + \ } - function! s:send(msg) abort - if !empty(s:protocol) && !empty(s:current_channel) - call chat#{s:protocol}#send(s:current_channel, a:msg) - endif - endfunction - - function! chat#windows#status() abort - - return { - \ 'channel' : s:current_channel, - \ 'protocol' : s:protocol, - \ } - - endfunction +endfunction