add delay execution

This commit is contained in:
Nachuan Tang
2023-03-23 17:29:54 -04:00
parent 8cda9923dc
commit e0518c302f
3 changed files with 640 additions and 686 deletions
+23 -26
View File
@@ -78,44 +78,41 @@
autocmd FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
augroup END
" http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session
" Restore cursor to file position in previous editing session
function! ResCur()
if line("'\"") <= line("$")
silent! normal! g`"
return 1
endif
endfunction
" " http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session
" " Restore cursor to file position in previous editing session
" function! ResCur()
" if line("'\"") <= line("$")
" silent! normal! g`"
" return 1
" endif
" endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
augroup END
" augroup resCur
" autocmd!
" autocmd BufWinEnter * call ResCur()
" augroup END
" Setting up the directories {
set backup " Backups are nice ...
if has('persistent_undo')
set undofile " So is persistent undo ...
set undolevels=1000 " Maximum number of changes that can be undone
set undoreload=10000 " Maximum number lines to save for undo on a buffer reload
endif
" set backup " Backups are nice ...
if has('persistent_undo')
set undofile " So is persistent undo ...
set undolevels=1000 " Maximum number of changes that can be undone
set undoreload=10000 " Maximum number lines to save for undo on a buffer reload
endif
" }
" }
" Vim UI {
"
" set tabpagemax=15 " Only show 15 tabs
" set showmode " Display the current mode
set nocursorline " Highlight current line
set cmdheight=1 " get rid of the extra useless line at the bottom(if not working, probably a plugin is changing the value)
if has('cmdline_info')
set ruler " Show the ruler
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " A ruler on steroids
set showcmd " Show partial commands in status line and
endif
" if has('cmdline_info')
" set ruler " Show the ruler
" set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " A ruler on steroids
" set showcmd " Show partial commands in status line and
" endif
set backspace=indent,eol,start " Backspace for dummies
+556 -660
View File
File diff suppressed because it is too large Load Diff
+61
View File
@@ -5,6 +5,21 @@ function! Notify(msg)
echo msg
endfunction
" Check if plugin exists
function! HasPlug(plug_name, ...)
let plug_dir_name = get(a:, 1, a:plug_name) " optional argument for the name of plug's folder
if has_key(g:plugs, a:plug_name) && isdirectory(g:plugin_dir . "/" . plug_dir_name)
if has_key(g:plugs[a:plug_name], 'for') || has_key(g:plugs[a:plug_name], 'on')
if (has_key(g:plugs[a:plug_name], 'for') && len(g:plugs[a:plug_name]['for']) == 0) ||
\ (has_key(g:plugs[a:plug_name], 'on') && len(g:plugs[a:plug_name]['on']) == 0)
return v:false
endif
endif
return v:true
endif
return v:false
endfunction
" This function is used to save a variable to a file
function! SaveVariable(var, file)
let serialized = string(a:var)
@@ -204,3 +219,49 @@ fun! TrimWhitespace()
keeppatterns %s/\s\+$//e
call winrestview(l:save)
endfun
""" AIRLINE EXTENSIONS """
if HasPlug('vim-airline')
function! AirlineCocStatus()
if ! exists('*CocAction')
return
endif
" let loading = ["⢿", "⣻", "⣽", "⣾", "⣷", "⣯", "⣟", "⡿"]
let loading = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]
try
let result = CocAction('services')
catch
return
endtry
let state = ''
let id = ''
for e in result
if e['languageIds'][0] == &ft
let state = e['state']
let id = e['id']
endif
endfor
" messy way to get time in millisecond in vim
let time = float2nr(str2float(reltime()->reltimestr()[4:]) * 1000)
let speed = 800
let loadidx = time % speed
let msg = 'lsp:' . id
if state == "starting"
let s:coc_lsp_loading = 1
return msg . " " . loading[loadidx/(speed/10)] . " "
endif
if exists('s:coc_lsp_loading')
unlet s:coc_lsp_loading
endif
return msg . " ✔ "
endfunction
function! AirlineBufferNumber()
return len(g:index_to_buffer)
endfunction
endif
""" AIRLINE EXTENSIONS END """