fix bug
This commit is contained in:
+48
-46
@@ -409,9 +409,9 @@ endfunction
|
|||||||
|
|
||||||
" dark or light
|
" dark or light
|
||||||
if filereadable(g:vim_dir . '.light_theme.signal')
|
if filereadable(g:vim_dir . '.light_theme.signal')
|
||||||
let g:dark_or_white_theme = 'light'
|
let g:dark_or_light_theme = 'light'
|
||||||
else
|
else
|
||||||
let g:dark_or_white_theme = 'dark'
|
let g:dark_or_light_theme = 'dark'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" what to use for dark theme
|
" what to use for dark theme
|
||||||
@@ -423,15 +423,37 @@ endfunction
|
|||||||
let g:light_theme = 'default'
|
let g:light_theme = 'default'
|
||||||
let g:airline_light_theme = "silver"
|
let g:airline_light_theme = "silver"
|
||||||
|
|
||||||
|
" delete signal file if exist
|
||||||
|
function! DeleteSignalFile(name)
|
||||||
|
if filereadable(g:vim_dir . a:name)
|
||||||
|
call delete(g:vim_dir . a:name)
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Create signal file if not exist
|
||||||
|
function! CreateSignalFile(name)
|
||||||
|
call system("touch " . g:vim_dir . a:name)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" all signal files:
|
||||||
|
" .transparent_light_theme.signal
|
||||||
|
" .transparent_dark_theme.signal
|
||||||
|
function! SignalFileExists(filename)
|
||||||
|
if filereadable(g:vim_dir . a:filename)
|
||||||
|
return v:true
|
||||||
|
endif
|
||||||
|
return v:false
|
||||||
|
endfunction
|
||||||
|
|
||||||
" transparent backgroud for supported terminal emulator
|
" transparent backgroud for supported terminal emulator
|
||||||
" check if transparent_dark_theme.signl or transparent_light_theme.signl
|
" check if transparent_dark_theme.signl or transparent_light_theme.signl
|
||||||
" exist and set respect variable
|
" exist and set respect variable
|
||||||
let g:transparent_dark_theme = v:false
|
let g:transparent_dark_theme = v:false
|
||||||
let g:transparent_light_theme = v:false
|
let g:transparent_light_theme = v:false
|
||||||
if filereadable(g:vim_dir . '.transparent_dark_theme.signal')
|
if SignalFileExists('.transparent_dark_theme.signal')
|
||||||
let g:transparent_dark_theme = v:true
|
let g:transparent_dark_theme = v:true
|
||||||
endif
|
endif
|
||||||
if filereadable(g:vim_dir . '.transparent_light_theme.signal')
|
if SignalFileExists('.transparent_light_theme.signal')
|
||||||
let g:transparent_light_theme = v:true
|
let g:transparent_light_theme = v:true
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -439,19 +461,19 @@ endfunction
|
|||||||
set background=dark
|
set background=dark
|
||||||
hi clear
|
hi clear
|
||||||
execute("colorscheme " . g:dark_theme)
|
execute("colorscheme " . g:dark_theme)
|
||||||
let g:dark_or_white_theme = 'dark'
|
let g:dark_or_light_theme = 'dark'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SetLightTheme()
|
function! SetLightTheme()
|
||||||
set background=light
|
set background=light
|
||||||
hi clear
|
hi clear
|
||||||
execute("colorscheme " . g:light_theme)
|
execute("colorscheme " . g:light_theme)
|
||||||
let g:dark_or_white_theme = 'light'
|
let g:dark_or_light_theme = 'light'
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Change bottom airline/lualine theme
|
" Change bottom airline/lualine theme
|
||||||
" Currently only support airline
|
" Currently only support airline
|
||||||
function! SetAirlineTheme(theme)
|
function! SetStatusLineTheme(theme)
|
||||||
if g:vim_type == 'nvim' && g:vim_version >= 0.5
|
if g:vim_type == 'nvim' && g:vim_version >= 0.5
|
||||||
"execute('AirlineTheme ' . a:theme)
|
"execute('AirlineTheme ' . a:theme)
|
||||||
else
|
else
|
||||||
@@ -477,7 +499,7 @@ endfunction
|
|||||||
highlight CocWarningSign ctermbg=none
|
highlight CocWarningSign ctermbg=none
|
||||||
highlight CocInfoSign ctermbg=none
|
highlight CocInfoSign ctermbg=none
|
||||||
highlight CocHintSign ctermbg=none
|
highlight CocHintSign ctermbg=none
|
||||||
if g:dark_or_white_theme == 'dark'
|
if g:dark_or_light_theme == 'dark'
|
||||||
highlight! link TempColor Visual
|
highlight! link TempColor Visual
|
||||||
highlight! link CocFloating TempColor
|
highlight! link CocFloating TempColor
|
||||||
highlight! link CocErrorFloat TempColor
|
highlight! link CocErrorFloat TempColor
|
||||||
@@ -493,7 +515,7 @@ endfunction
|
|||||||
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
||||||
:TransparentEnable
|
:TransparentEnable
|
||||||
else
|
else
|
||||||
if g:dark_or_white_theme == 'dark'
|
if g:dark_or_light_theme == 'dark'
|
||||||
let g:PaperColor_Theme_Options = {
|
let g:PaperColor_Theme_Options = {
|
||||||
\ 'theme': {
|
\ 'theme': {
|
||||||
\ 'default.dark': {
|
\ 'default.dark': {
|
||||||
@@ -502,7 +524,7 @@ endfunction
|
|||||||
\ }
|
\ }
|
||||||
\ }
|
\ }
|
||||||
execute("colorscheme " . g:dark_theme)
|
execute("colorscheme " . g:dark_theme)
|
||||||
elseif g:dark_or_white_theme == 'light'
|
elseif g:dark_or_light_theme == 'light'
|
||||||
let g:PaperColor_Theme_Options = {
|
let g:PaperColor_Theme_Options = {
|
||||||
\ 'theme': {
|
\ 'theme': {
|
||||||
\ 'default.light': {
|
\ 'default.light': {
|
||||||
@@ -513,14 +535,14 @@ endfunction
|
|||||||
execute("colorscheme " . g:light_theme)
|
execute("colorscheme " . g:light_theme)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
call TransparentBackgroundFix()
|
" call TransparentBackgroundFix()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! DisableTransparent()
|
function! DisableTransparent()
|
||||||
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
||||||
:TransparentDisable
|
:TransparentDisable
|
||||||
else
|
else
|
||||||
if g:dark_or_white_theme == 'dark'
|
if g:dark_or_light_theme == 'dark'
|
||||||
let g:PaperColor_Theme_Options = {
|
let g:PaperColor_Theme_Options = {
|
||||||
\ 'theme': {
|
\ 'theme': {
|
||||||
\ 'default.dark': {
|
\ 'default.dark': {
|
||||||
@@ -529,7 +551,7 @@ endfunction
|
|||||||
\ }
|
\ }
|
||||||
\ }
|
\ }
|
||||||
execute("colorscheme " . g:dark_theme)
|
execute("colorscheme " . g:dark_theme)
|
||||||
elseif g:dark_or_white_theme == 'light'
|
elseif g:dark_or_light_theme == 'light'
|
||||||
let g:PaperColor_Theme_Options = {
|
let g:PaperColor_Theme_Options = {
|
||||||
\ 'theme': {
|
\ 'theme': {
|
||||||
\ 'default.light': {
|
\ 'default.light': {
|
||||||
@@ -538,36 +560,25 @@ endfunction
|
|||||||
\ }
|
\ }
|
||||||
\ }
|
\ }
|
||||||
execute("colorscheme " . g:light_theme)
|
execute("colorscheme " . g:light_theme)
|
||||||
|
DeleteSignalFile()
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" delete signal file if exist
|
|
||||||
function! DeleteSignalFile(name)
|
|
||||||
if filereadable(g:vim_dir . a:name)
|
|
||||||
call delete(g:vim_dir . a:name)
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" Create signal file if not exist
|
|
||||||
function! CreateSignalFile(name)
|
|
||||||
call system("touch " . g:vim_dir . a:name)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" ToggleTransparent background
|
" ToggleTransparent background
|
||||||
" only works in dark theme
|
" only works in dark theme
|
||||||
function! ToggleTransparent()
|
function! ToggleTransparent()
|
||||||
if g:transparent_dark_theme && g:dark_or_white_theme == 'dark'
|
if g:transparent_dark_theme && g:dark_or_light_theme == 'dark'
|
||||||
call DisableTransparent()
|
call DisableTransparent()
|
||||||
let g:transparent_dark_theme = v:false
|
let g:transparent_dark_theme = v:false
|
||||||
call DeleteSignalFile('.transparent_dark_theme.signal')
|
call DeleteSignalFile('.transparent_dark_theme.signal')
|
||||||
elseif g:transparent_light_theme && g:dark_or_white_theme == 'light'
|
elseif g:transparent_light_theme && g:dark_or_light_theme == 'light'
|
||||||
call DisableTransparent()
|
call DisableTransparent()
|
||||||
let g:transparent_light_theme = v:false
|
let g:transparent_light_theme = v:false
|
||||||
call DeleteSignalFile('.transparent_light_theme.signal')
|
call DeleteSignalFile('.transparent_light_theme.signal')
|
||||||
else
|
else
|
||||||
call EnableTransparent()
|
call EnableTransparent()
|
||||||
if g:dark_or_white_theme == 'dark'
|
if g:dark_or_light_theme == 'dark'
|
||||||
let g:transparent_dark_theme = v:true
|
let g:transparent_dark_theme = v:true
|
||||||
call CreateSignalFile('.transparent_dark_theme.signal')
|
call CreateSignalFile('.transparent_dark_theme.signal')
|
||||||
else
|
else
|
||||||
@@ -589,13 +600,13 @@ endfunction
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" nvim only theme
|
" nvim only theme
|
||||||
if has('nvim')
|
if g:vim_type == 'nvim'
|
||||||
if g:vim_version >= 0.8 && HasPlug("nightfox.nvim")
|
if g:vim_version >= 0.8 && HasPlug("nightfox.nvim")
|
||||||
let g:light_theme = 'dawnfox'
|
let g:light_theme = 'dawnfox'
|
||||||
"let g:dark_theme = 'nightfox'
|
"let g:dark_theme = 'nightfox'
|
||||||
end
|
end
|
||||||
|
|
||||||
if g:vim_version >= 0.5 && HasPlug("/github-nvim-theme")
|
if g:vim_version >= 0.5 && HasPlug("github-nvim-theme")
|
||||||
let g:dark_theme = 'github_dark'
|
let g:dark_theme = 'github_dark'
|
||||||
" let g:dark_theme = 'github_dark_default'
|
" let g:dark_theme = 'github_dark_default'
|
||||||
" let g:dark_theme = 'github_dimmed'
|
" let g:dark_theme = 'github_dimmed'
|
||||||
@@ -604,7 +615,7 @@ endfunction
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
if g:dark_or_white_theme == 'dark'
|
if g:dark_or_light_theme == 'dark'
|
||||||
let g:airline_theme=g:airline_dark_theme
|
let g:airline_theme=g:airline_dark_theme
|
||||||
call SetDarkTheme()
|
call SetDarkTheme()
|
||||||
else
|
else
|
||||||
@@ -614,13 +625,13 @@ endfunction
|
|||||||
|
|
||||||
" Since in .vimrc we cannot call plugin function as they
|
" Since in .vimrc we cannot call plugin function as they
|
||||||
" are not loaded (:help startup)
|
" are not loaded (:help startup)
|
||||||
if (g:transparent_dark_theme && g:dark_or_white_theme == 'dark') || (g:transparent_light_theme && g:dark_or_white_theme == 'light')
|
if (g:transparent_dark_theme && g:dark_or_light_theme == 'dark') || (g:transparent_light_theme && g:dark_or_light_theme == 'light')
|
||||||
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
||||||
let g:transparent_enabled = v:true
|
let g:transparent_enabled = v:true
|
||||||
else
|
else
|
||||||
call EnableTransparent()
|
call EnableTransparent()
|
||||||
endif
|
endif
|
||||||
call TransparentBackgroundFix()
|
" call TransparentBackgroundFix()
|
||||||
else
|
else
|
||||||
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
||||||
let g:transparent_enabled = v:false
|
let g:transparent_enabled = v:false
|
||||||
@@ -632,18 +643,18 @@ endfunction
|
|||||||
" Allow to trigger background
|
" Allow to trigger background
|
||||||
function! ToggleBG()
|
function! ToggleBG()
|
||||||
" Inversion
|
" Inversion
|
||||||
if g:dark_or_white_theme == "dark"
|
if g:dark_or_light_theme == "dark"
|
||||||
call SetLightTheme()
|
call SetLightTheme()
|
||||||
call SetAirlineTheme(g:airline_light_theme)
|
call SetStatusLineTheme(g:airline_light_theme)
|
||||||
call CreateSignalFile('.light_theme.signal')
|
call CreateSignalFile('.light_theme.signal')
|
||||||
else
|
else
|
||||||
call SetDarkTheme()
|
call SetDarkTheme()
|
||||||
call SetAirlineTheme(g:airline_dark_theme)
|
call SetStatusLineTheme(g:airline_dark_theme)
|
||||||
" for saving theme state
|
" for saving theme state
|
||||||
call DeleteSignalFile(".light_theme.signal")
|
call DeleteSignalFile(".light_theme.signal")
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if g:transparent_dark_theme && g:dark_or_white_theme == 'dark' || g:transparent_light_theme && g:dark_or_white_theme == 'light'
|
if (g:transparent_dark_theme && g:dark_or_light_theme == 'dark') || (g:transparent_light_theme && g:dark_or_light_theme == 'light')
|
||||||
call EnableTransparent()
|
call EnableTransparent()
|
||||||
else
|
else
|
||||||
call DisableTransparent()
|
call DisableTransparent()
|
||||||
@@ -673,15 +684,6 @@ endfunction
|
|||||||
" leader num change tab
|
" leader num change tab
|
||||||
" only for vim or nvim without lualine
|
" only for vim or nvim without lualine
|
||||||
if g:vim_type == 'vim' || (g:vim_type == 'nvim' && g:vim_version < 0.5)
|
if g:vim_type == 'vim' || (g:vim_type == 'nvim' && g:vim_version < 0.5)
|
||||||
" nnoremap <Leader>1 :b1<CR>
|
|
||||||
" nnoremap <Leader>2 :b2<CR>
|
|
||||||
" nnoremap <Leader>3 :b3<CR>
|
|
||||||
" nnoremap <Leader>4 :b4<CR>
|
|
||||||
" nnoremap <Leader>5 :b5<CR>
|
|
||||||
" nnoremap <Leader>6 :b6<CR>
|
|
||||||
" nnoremap <Leader>7 :b7<CR>
|
|
||||||
" nnoremap <Leader>8 :b8<CR>
|
|
||||||
" nnoremap <Leader>9 :b9<CR>
|
|
||||||
nnoremap <silent> <nowait> <Leader>1 :call bufferline#jump(1)<CR>
|
nnoremap <silent> <nowait> <Leader>1 :call bufferline#jump(1)<CR>
|
||||||
nnoremap <silent> <nowait> <Leader>2 :call bufferline#jump(2)<CR>
|
nnoremap <silent> <nowait> <Leader>2 :call bufferline#jump(2)<CR>
|
||||||
nnoremap <silent> <nowait> <Leader>3 :call bufferline#jump(3)<CR>
|
nnoremap <silent> <nowait> <Leader>3 :call bufferline#jump(3)<CR>
|
||||||
|
|||||||
Reference in New Issue
Block a user