Merge branch 'dev' of https://github.com/Donaldttt/dotfiles into dev
This commit is contained in:
+24
-4
@@ -14,10 +14,10 @@ bind-key -r C-h resize-pane -L
|
||||
bind-key -r C-l resize-pane -R
|
||||
|
||||
# vim-like pane switching
|
||||
bind-key -n C-k select-pane -U
|
||||
bind-key -n C-j select-pane -D
|
||||
bind-key -n C-h select-pane -L
|
||||
bind-key -n C-l select-pane -R
|
||||
# bind-key -n C-k select-pane -U
|
||||
# bind-key -n C-j select-pane -D
|
||||
# bind-key -n C-h select-pane -L
|
||||
# bind-key -n C-l select-pane -R
|
||||
|
||||
# and now unbind keys
|
||||
unbind Up
|
||||
@@ -29,3 +29,23 @@ unbind C-Up
|
||||
unbind C-Down
|
||||
unbind C-Left
|
||||
unbind C-Right
|
||||
|
||||
# Smart pane switching with awareness of Vim splits.
|
||||
# See: https://github.com/christoomey/vim-tmux-navigator
|
||||
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
|
||||
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?)(diff)?$'"
|
||||
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
|
||||
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
|
||||
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
|
||||
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
|
||||
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
|
||||
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
|
||||
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
|
||||
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
|
||||
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
|
||||
|
||||
bind-key -T copy-mode-vi 'C-h' select-pane -L
|
||||
bind-key -T copy-mode-vi 'C-j' select-pane -D
|
||||
bind-key -T copy-mode-vi 'C-k' select-pane -U
|
||||
bind-key -T copy-mode-vi 'C-l' select-pane -R
|
||||
bind-key -T copy-mode-vi 'C-\' select-pane -l
|
||||
|
||||
+96
-82
@@ -49,6 +49,7 @@
|
||||
Plug 'vim-scripts/restore_view.vim'
|
||||
Plug 'mhinz/vim-startify'
|
||||
|
||||
Plug 'christoomey/vim-tmux-navigator'
|
||||
if executable('fzf')
|
||||
" fzf#install() makes sure that you have the latest binary, comment out because I don't want it to install binary for me
|
||||
Plug 'junegunn/fzf' ", { 'do': { -> fzf#install() } }
|
||||
@@ -79,7 +80,7 @@
|
||||
" The bottom buffer display
|
||||
Plug 'Donaldttt/vim-bufferline'
|
||||
Plug 'ryanoasis/vim-devicons'
|
||||
Plug 'Yggdroot/indentLine'
|
||||
" Plug 'Yggdroot/indentLine'
|
||||
endif
|
||||
|
||||
if executable('node')
|
||||
@@ -134,6 +135,16 @@ endfunction
|
||||
let g:indentLine_fileTypeExclude = ['startify']
|
||||
endif
|
||||
" }
|
||||
|
||||
if HasPlug('vim-tmux-navigator')
|
||||
let g:tmux_navigator_no_mappings = 1
|
||||
|
||||
noremap <silent> <c-h> :<C-U>TmuxNavigateLeft<cr>
|
||||
noremap <silent> <c-j> :<C-U>TmuxNavigateDown<cr>
|
||||
noremap <silent> <c-k> :<C-U>TmuxNavigateUp<cr>
|
||||
noremap <silent> <c-l> :<C-U>TmuxNavigateRight<cr>
|
||||
" noremap <silent> {Previous-Mapping} :<C-U>TmuxNavigatePrevious<cr>
|
||||
endif
|
||||
|
||||
" mhinz/vim-startify {
|
||||
if HasPlug("vim-startify")
|
||||
@@ -199,7 +210,7 @@ endfunction
|
||||
" }
|
||||
|
||||
" easymotion/vim-easymotion {
|
||||
|
||||
if HasPlug("vim-easymotion")
|
||||
" <Leader>f{char} to move to {char}
|
||||
map <Leader>f <Plug>(easymotion-bd-f)
|
||||
nmap <Leader>f <Plug>(easymotion-overwin-f)
|
||||
@@ -214,6 +225,7 @@ endfunction
|
||||
" Move to word
|
||||
map <Leader>w <Plug>(easymotion-bd-w)
|
||||
nmap <Leader>w <Plug>(easymotion-overwin-w)
|
||||
endif
|
||||
|
||||
" }
|
||||
|
||||
@@ -252,46 +264,46 @@ endfunction
|
||||
" }
|
||||
|
||||
" NerdTree {
|
||||
if (g:vim_type == 'vim' || g:vim_version < 0.8) && HasPlug('nerdtree')
|
||||
let g:NERDShutUp=1
|
||||
if (g:vim_type == 'vim' || g:vim_version < 0.8) && HasPlug('nerdtree')
|
||||
let g:NERDShutUp=1
|
||||
|
||||
" work around for nerdtree bug: https://github.com/preservim/nerdtree/issues/1321
|
||||
let g:NERDTreeMinimalMenu = v:true
|
||||
let g:NERDTreeMinimalUI = v:true
|
||||
" work around for nerdtree bug: https://github.com/preservim/nerdtree/issues/1321
|
||||
let g:NERDTreeMinimalMenu = v:true
|
||||
let g:NERDTreeMinimalUI = v:true
|
||||
|
||||
"nnoremap <C-e> :NERDTreeToggle<CR>
|
||||
function! NERDTreeFindToggle()
|
||||
let my_filetype = &filetype
|
||||
let specical_fts = ['nerdtree', 'startify']
|
||||
if my_filetype == '' || index(specical_fts, my_filetype) >= 0
|
||||
:NERDTreeToggle
|
||||
else
|
||||
:NERDTreeFind
|
||||
endif
|
||||
endfunction
|
||||
nnoremap <silent> <leader>e :call NERDTreeFindToggle()<CR>
|
||||
"nnoremap <C-e> :NERDTreeToggle<CR>
|
||||
function! NERDTreeFindToggle()
|
||||
let my_filetype = &filetype
|
||||
let specical_fts = ['nerdtree', 'startify']
|
||||
if my_filetype == '' || index(specical_fts, my_filetype) >= 0
|
||||
:NERDTreeToggle
|
||||
else
|
||||
:NERDTreeFind
|
||||
endif
|
||||
endfunction
|
||||
nnoremap <silent> <leader>e :call NERDTreeFindToggle()<CR>
|
||||
|
||||
"let NERDTreeShowBookmarks=1
|
||||
"let NERDTreeIgnore=['\.py[cd]$', '\~$', '\.swo$', '\.swp$', '^\.git$', '^\.hg$', '^\.svn$', '\.bzr$']
|
||||
let NERDTreeChDirMode = 0
|
||||
let NERDTreeQuitOnOpen = 1
|
||||
let NERDTreeMouseMode = 2
|
||||
let NERDTreeShowHidden = 1
|
||||
let NERDTreeKeepTreeInNewTab = 1
|
||||
"let NERDTreeShowBookmarks=1
|
||||
"let NERDTreeIgnore=['\.py[cd]$', '\~$', '\.swo$', '\.swp$', '^\.git$', '^\.hg$', '^\.svn$', '\.bzr$']
|
||||
let NERDTreeChDirMode = 0
|
||||
let NERDTreeQuitOnOpen = 1
|
||||
let NERDTreeMouseMode = 2
|
||||
let NERDTreeShowHidden = 1
|
||||
let NERDTreeKeepTreeInNewTab = 1
|
||||
|
||||
" Exit Vim if NERDTree is the only window remaining in the only tab.
|
||||
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
|
||||
endif
|
||||
" Exit Vim if NERDTree is the only window remaining in the only tab.
|
||||
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
|
||||
endif
|
||||
" }
|
||||
|
||||
" nvim-tree.lua {
|
||||
if g:vim_type == 'nvim' && HasPlug("nvim-tree.lua")
|
||||
if g:vim_type == 'nvim' && HasPlug("nvim-tree.lua")
|
||||
|
||||
" Hide vim bottom statusline
|
||||
" autocmd FileType NvimTree setlocal noshowmode noruler laststatus=0 noshowcmd
|
||||
" set noshowmode noruler laststatus=0 noshowcmd
|
||||
" autocmd BufRead,BufNewFile NvimTree set laststatus=0 " This will work instead
|
||||
endif
|
||||
" Hide vim bottom statusline
|
||||
" autocmd FileType NvimTree setlocal noshowmode noruler laststatus=0 noshowcmd
|
||||
" set noshowmode noruler laststatus=0 noshowcmd
|
||||
" autocmd BufRead,BufNewFile NvimTree set laststatus=0 " This will work instead
|
||||
endif
|
||||
" }
|
||||
|
||||
"if has('nvim') && str2float(g:nvim_version) >= 0.5 && HasPlug("lualine.nvim")
|
||||
@@ -409,9 +421,9 @@ endfunction
|
||||
|
||||
" dark or light
|
||||
if filereadable(g:vim_dir . '.light_theme.signal')
|
||||
let g:dark_or_white_theme = 'light'
|
||||
let g:dark_or_light_theme = 'light'
|
||||
else
|
||||
let g:dark_or_white_theme = 'dark'
|
||||
let g:dark_or_light_theme = 'dark'
|
||||
endif
|
||||
|
||||
" what to use for dark theme
|
||||
@@ -423,15 +435,37 @@ endfunction
|
||||
let g:light_theme = 'default'
|
||||
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
|
||||
" check if transparent_dark_theme.signl or transparent_light_theme.signl
|
||||
" exist and set respect variable
|
||||
let g:transparent_dark_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
|
||||
endif
|
||||
if filereadable(g:vim_dir . '.transparent_light_theme.signal')
|
||||
if SignalFileExists('.transparent_light_theme.signal')
|
||||
let g:transparent_light_theme = v:true
|
||||
endif
|
||||
|
||||
@@ -439,19 +473,19 @@ endfunction
|
||||
set background=dark
|
||||
hi clear
|
||||
execute("colorscheme " . g:dark_theme)
|
||||
let g:dark_or_white_theme = 'dark'
|
||||
let g:dark_or_light_theme = 'dark'
|
||||
endfunction
|
||||
|
||||
function! SetLightTheme()
|
||||
set background=light
|
||||
hi clear
|
||||
execute("colorscheme " . g:light_theme)
|
||||
let g:dark_or_white_theme = 'light'
|
||||
let g:dark_or_light_theme = 'light'
|
||||
endfunction
|
||||
|
||||
" Change bottom airline/lualine theme
|
||||
" Currently only support airline
|
||||
function! SetAirlineTheme(theme)
|
||||
function! SetStatusLineTheme(theme)
|
||||
if g:vim_type == 'nvim' && g:vim_version >= 0.5
|
||||
"execute('AirlineTheme ' . a:theme)
|
||||
else
|
||||
@@ -477,7 +511,7 @@ endfunction
|
||||
highlight CocWarningSign ctermbg=none
|
||||
highlight CocInfoSign 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 CocFloating TempColor
|
||||
highlight! link CocErrorFloat TempColor
|
||||
@@ -493,7 +527,7 @@ endfunction
|
||||
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
||||
:TransparentEnable
|
||||
else
|
||||
if g:dark_or_white_theme == 'dark'
|
||||
if g:dark_or_light_theme == 'dark'
|
||||
let g:PaperColor_Theme_Options = {
|
||||
\ 'theme': {
|
||||
\ 'default.dark': {
|
||||
@@ -502,7 +536,7 @@ endfunction
|
||||
\ }
|
||||
\ }
|
||||
execute("colorscheme " . g:dark_theme)
|
||||
elseif g:dark_or_white_theme == 'light'
|
||||
elseif g:dark_or_light_theme == 'light'
|
||||
let g:PaperColor_Theme_Options = {
|
||||
\ 'theme': {
|
||||
\ 'default.light': {
|
||||
@@ -513,14 +547,14 @@ endfunction
|
||||
execute("colorscheme " . g:light_theme)
|
||||
endif
|
||||
endif
|
||||
call TransparentBackgroundFix()
|
||||
" call TransparentBackgroundFix()
|
||||
endfunction
|
||||
|
||||
function! DisableTransparent()
|
||||
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
||||
:TransparentDisable
|
||||
else
|
||||
if g:dark_or_white_theme == 'dark'
|
||||
if g:dark_or_light_theme == 'dark'
|
||||
let g:PaperColor_Theme_Options = {
|
||||
\ 'theme': {
|
||||
\ 'default.dark': {
|
||||
@@ -529,7 +563,7 @@ endfunction
|
||||
\ }
|
||||
\ }
|
||||
execute("colorscheme " . g:dark_theme)
|
||||
elseif g:dark_or_white_theme == 'light'
|
||||
elseif g:dark_or_light_theme == 'light'
|
||||
let g:PaperColor_Theme_Options = {
|
||||
\ 'theme': {
|
||||
\ 'default.light': {
|
||||
@@ -538,36 +572,25 @@ endfunction
|
||||
\ }
|
||||
\ }
|
||||
execute("colorscheme " . g:light_theme)
|
||||
DeleteSignalFile()
|
||||
endif
|
||||
endif
|
||||
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
|
||||
" only works in dark theme
|
||||
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()
|
||||
let g:transparent_dark_theme = v:false
|
||||
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()
|
||||
let g:transparent_light_theme = v:false
|
||||
call DeleteSignalFile('.transparent_light_theme.signal')
|
||||
else
|
||||
call EnableTransparent()
|
||||
if g:dark_or_white_theme == 'dark'
|
||||
if g:dark_or_light_theme == 'dark'
|
||||
let g:transparent_dark_theme = v:true
|
||||
call CreateSignalFile('.transparent_dark_theme.signal')
|
||||
else
|
||||
@@ -580,7 +603,7 @@ endfunction
|
||||
|
||||
" vim theme
|
||||
if !has('nvim') && HasPlug("papercolor-theme") && HasPlug('papercolor-theme')
|
||||
set t_Co=256
|
||||
set t_Co=256
|
||||
" improve coc color in this theme
|
||||
let g:light_theme = 'PaperColor'
|
||||
let g:dark_theme = 'PaperColor'
|
||||
@@ -589,13 +612,13 @@ endfunction
|
||||
endif
|
||||
|
||||
" nvim only theme
|
||||
if has('nvim')
|
||||
if g:vim_type == 'nvim'
|
||||
if g:vim_version >= 0.8 && HasPlug("nightfox.nvim")
|
||||
let g:light_theme = 'dawnfox'
|
||||
"let g:dark_theme = 'nightfox'
|
||||
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_default'
|
||||
" let g:dark_theme = 'github_dimmed'
|
||||
@@ -604,7 +627,7 @@ endfunction
|
||||
endif
|
||||
|
||||
|
||||
if g:dark_or_white_theme == 'dark'
|
||||
if g:dark_or_light_theme == 'dark'
|
||||
let g:airline_theme=g:airline_dark_theme
|
||||
call SetDarkTheme()
|
||||
else
|
||||
@@ -614,13 +637,13 @@ endfunction
|
||||
|
||||
" Since in .vimrc we cannot call plugin function as they
|
||||
" 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
|
||||
let g:transparent_enabled = v:true
|
||||
else
|
||||
call EnableTransparent()
|
||||
endif
|
||||
call TransparentBackgroundFix()
|
||||
" call TransparentBackgroundFix()
|
||||
else
|
||||
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
||||
let g:transparent_enabled = v:false
|
||||
@@ -632,18 +655,18 @@ endfunction
|
||||
" Allow to trigger background
|
||||
function! ToggleBG()
|
||||
" Inversion
|
||||
if g:dark_or_white_theme == "dark"
|
||||
if g:dark_or_light_theme == "dark"
|
||||
call SetLightTheme()
|
||||
call SetAirlineTheme(g:airline_light_theme)
|
||||
call SetStatusLineTheme(g:airline_light_theme)
|
||||
call CreateSignalFile('.light_theme.signal')
|
||||
else
|
||||
call SetDarkTheme()
|
||||
call SetAirlineTheme(g:airline_dark_theme)
|
||||
call SetStatusLineTheme(g:airline_dark_theme)
|
||||
" for saving theme state
|
||||
call DeleteSignalFile(".light_theme.signal")
|
||||
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()
|
||||
else
|
||||
call DisableTransparent()
|
||||
@@ -668,20 +691,11 @@ endfunction
|
||||
nnoremap <silent> <space>e :bnext<CR>
|
||||
|
||||
" leader s change all occurence
|
||||
nnoremap <silent> <Leader>s :%s/\<<C-r><C-w>\>/
|
||||
nnoremap <Leader>s :%s/\<<C-r><C-w>\>/
|
||||
|
||||
" leader num change tab
|
||||
" only for vim or nvim without lualine
|
||||
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>2 :call bufferline#jump(2)<CR>
|
||||
nnoremap <silent> <nowait> <Leader>3 :call bufferline#jump(3)<CR>
|
||||
|
||||
Reference in New Issue
Block a user