410 lines
13 KiB
Plaintext
410 lines
13 KiB
Plaintext
" If anything not work as expected. Please make sure all plugins
|
|
" are installed by running:
|
|
" :PlugInstall
|
|
"
|
|
" Content
|
|
" ('#' jump to the topic)
|
|
"
|
|
" Plugin_Install
|
|
" Plugin_Preferences
|
|
" Theme_Appearance
|
|
" Key_Mappings
|
|
|
|
|
|
" Environment {
|
|
|
|
" Basics {
|
|
set nocompatible " Must be first line
|
|
" }
|
|
" }
|
|
|
|
" Plugin_Install
|
|
" {
|
|
" Plugin environment
|
|
let config_dir = '~/.dotfiles/'
|
|
let plugin_dir = '~/.vim/plugged/'
|
|
let g:vim_dir = '~/.vim/'
|
|
|
|
call plug#begin(plugin_dir)
|
|
|
|
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
|
Plug 'rust-lang/rust.vim'
|
|
Plug 'leafgarland/typescript-vim'
|
|
|
|
" {
|
|
Plug 'alvan/vim-closetag'
|
|
let g:closetag_filenames = '*.html,*.xhtml,*.phtml, *.js'
|
|
" }
|
|
|
|
Plug 'scrooloose/nerdtree'
|
|
|
|
Plug 'godlygeek/tabular'
|
|
" for markdown{
|
|
Plug 'preservim/vim-markdown'
|
|
"}
|
|
|
|
" for window resize{
|
|
Plug 'simeji/winresizer'
|
|
let g:winresizer_start_key = '<leader-r>'
|
|
let g:winresizer_vert_resize = 2
|
|
let g:winresizer_horiz_resize = 2
|
|
" }
|
|
|
|
Plug 'tpope/vim-surround'
|
|
Plug 'rhysd/conflict-marker.vim'
|
|
|
|
" {
|
|
Plug 'jiangmiao/auto-pairs'
|
|
" }
|
|
Plug 'mg979/vim-visual-multi'
|
|
|
|
Plug 'vim-airline/vim-airline'
|
|
Plug 'vim-airline/vim-airline-themes'
|
|
|
|
" The bottom buffer display
|
|
Plug 'bling/vim-bufferline'
|
|
Plug 'easymotion/vim-easymotion'
|
|
Plug 'nathanaelkane/vim-indent-guides'
|
|
Plug 'vim-scripts/restore_view.vim'
|
|
|
|
if executable('fzf')
|
|
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
|
|
endif
|
|
|
|
Plug 'NLKNguyen/papercolor-theme'
|
|
|
|
" only work with nvim > 0.5
|
|
" For other versions, just loading the plugin may
|
|
" cause error
|
|
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
|
Plug 'xiyaowong/nvim-transparent'
|
|
endif
|
|
|
|
Plug 'EdenEast/nightfox.nvim'
|
|
|
|
call plug#end()
|
|
" }
|
|
|
|
" Plugin_Preferences
|
|
" {
|
|
" godlygeek/tabular {
|
|
if isdirectory(expand(plugin_dir . "/tabular"))
|
|
nmap <leader>t= :Tabularize /=<CR>
|
|
vmap <leader>t= :Tabularize /=<CR>
|
|
|
|
nmap <leader>t\| :Tab /\|<CR>
|
|
vmap <leader>t\| :Tab /\|<CR>
|
|
|
|
nmap <leader>t: :Tab /:\zs<CR>
|
|
vmap <leader>t: :Tab /:\zs<CR>
|
|
endif
|
|
|
|
" }
|
|
|
|
" xiyaowong/nvim-transparent {
|
|
|
|
" }
|
|
|
|
" NerdTree {
|
|
if isdirectory(expand(plugin_dir . "/nerdtree"))
|
|
let g:NERDShutUp=1
|
|
nnoremap <C-e> :NERDTreeToggle<CR>
|
|
nnoremap <leader>e :NERDTreeToggle<CR>
|
|
"nmap <leader>e :NERDTreeFind<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
|
|
endif
|
|
" }
|
|
" indent_guides {
|
|
if isdirectory(expand(plugin_dir . "/vim-indent-guides/"))
|
|
let g:indent_guides_start_level = 2
|
|
let g:indent_guides_guide_size = 1
|
|
let g:indent_guides_enable_on_vim_startup = 0
|
|
map <leader>i :IndentGuidesToggle<CR>
|
|
|
|
endif
|
|
" }
|
|
|
|
"if has('nvim') && str2float(g:nvim_version) >= 0.5 && isdirectory(expand(plugin_dir . "/lualine.nvim"))
|
|
" nvim-lualine/lualine.nvim {
|
|
" }
|
|
"else
|
|
" vim-airline {
|
|
" Set configuration options for the statusline plugin vim-airline.
|
|
" Use the powerline theme and optionally enable powerline symbols.
|
|
let g:airline_section_b = ''
|
|
let g:airline_section_z = ''
|
|
let g:airline_section_y = ''
|
|
let g:airline_section_x = ''
|
|
let g:airline_section_warning = ''
|
|
"let g:airline#extensions#tabline#left_sep = ''
|
|
"let g:airline#extensions#tabline#left_alt_sep = '|'
|
|
|
|
if isdirectory(expand(plugin_dir . "/vim-airline-themes/"))
|
|
"let g:airline_theme = 'solarized'
|
|
endif
|
|
" }
|
|
"endif
|
|
|
|
" junegunnjunegunn/fzf {
|
|
" [Buffers] Jump to the existing window if possible
|
|
let g:fzf_buffers_jump = 1
|
|
"let $FZF_DEFAULT_COMMAND = 'find -L'
|
|
let $FZF_DEFAULT_COMMAND='find . \( -name node_modules -o -name .git \) -prune -o -print'
|
|
noremap <leader>f :FZF<CR>
|
|
" }
|
|
|
|
" neoclide/coc.nvim {
|
|
" add desired extensions to the following global variable
|
|
" coc-tsserver: javascript
|
|
" coc-pyright: python
|
|
" coc-clangd: c/c++, may need to install clangd seperatly
|
|
let g:coc_global_extensions = ['coc-pyright', 'coc-rls', 'coc-clangd', 'coc-tsserver', 'coc-html', 'coc-cmake', 'coc-sql', 'coc-json']
|
|
|
|
if filereadable(expand(config_dir . "/.exp-coc-config"))
|
|
exec "source " . config_dir . "/.exp-coc-config"
|
|
endif
|
|
|
|
" }
|
|
" }
|
|
|
|
" Theme_Appearance
|
|
" {
|
|
" dark or light
|
|
if filereadable(expand(g:vim_dir . '.light_theme.signal'))
|
|
let g:theme_color = 'light'
|
|
else
|
|
let g:theme_color = 'dark'
|
|
endif
|
|
|
|
" what to use for dark theme
|
|
let g:dark_theme = ''
|
|
let g:airline_dark_theme = "deus"
|
|
|
|
" what to use for light theme
|
|
let g:light_theme = ''
|
|
let g:airline_light_theme = "silver"
|
|
|
|
" 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(expand(g:vim_dir . '.transparent_dark_theme.signal'))
|
|
let g:transparent_dark_theme = v:true
|
|
endif
|
|
if filereadable(expand(g:vim_dir . '.transparent_light_theme.signal'))
|
|
let g:transparent_light_theme = v:true
|
|
endif
|
|
|
|
" Change bottom airline/lualine theme
|
|
" Currently only support airline
|
|
function! SetAirlineTheme(theme)
|
|
if has('nvim') && g:vim_version >= 0.5
|
|
execute('AirlineTheme ' . a:theme)
|
|
else
|
|
execute('AirlineTheme ' . a:theme)
|
|
endif
|
|
endfunction
|
|
|
|
function! EnableTransparent()
|
|
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
|
:TransparentEnable
|
|
elseif g:theme_color == 'dark'
|
|
let g:PaperColor_Theme_Options = {
|
|
\ 'theme': {
|
|
\ 'default.dark': {
|
|
\ 'transparent_background': 1
|
|
\ }
|
|
\ }
|
|
\ }
|
|
execute("colorscheme " . g:dark_theme)
|
|
elseif g:theme_color == 'light'
|
|
let g:PaperColor_Theme_Options = {
|
|
\ 'theme': {
|
|
\ 'default.light': {
|
|
\ 'transparent_background': 1
|
|
\ }
|
|
\ }
|
|
\ }
|
|
execute("colorscheme " . g:light_theme)
|
|
endif
|
|
endfunction
|
|
|
|
function! DisableTransparent()
|
|
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
|
:TransparentDisable
|
|
elseif g:theme_color == 'dark'
|
|
let g:PaperColor_Theme_Options = {
|
|
\ 'theme': {
|
|
\ 'default.dark': {
|
|
\ 'transparent_background': 0
|
|
\ }
|
|
\ }
|
|
\ }
|
|
execute("colorscheme " . g:dark_theme)
|
|
elseif g:theme_color == 'light'
|
|
let g:PaperColor_Theme_Options = {
|
|
\ 'theme': {
|
|
\ 'default.light': {
|
|
\ 'transparent_background': 0
|
|
\ }
|
|
\ }
|
|
\ }
|
|
execute("colorscheme " . g:light_theme)
|
|
endif
|
|
endfunction
|
|
|
|
" delete signal file if exist
|
|
function! DeleteSignalFile(name)
|
|
if filereadable(expand(g:vim_dir . a:name))
|
|
call delete(expand(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:theme_color == 'dark'
|
|
call DisableTransparent()
|
|
let g:transparent_dark_theme = v:false
|
|
call DeleteSignalFile('.transparent_dark_theme.signal')
|
|
elseif g:transparent_light_theme && g:theme_color == 'light'
|
|
call DisableTransparent()
|
|
let g:transparent_light_theme = v:false
|
|
call DeleteSignalFile('.transparent_light_theme.signal')
|
|
else
|
|
call EnableTransparent()
|
|
if g:theme_color == 'dark'
|
|
let g:transparent_dark_theme = v:true
|
|
call CreateSignalFile('.transparent_dark_theme.signal')
|
|
else
|
|
let g:transparent_light_theme = v:true
|
|
call CreateSignalFile('.transparent_light_theme.signal')
|
|
endif
|
|
endif
|
|
endfunction
|
|
|
|
|
|
" {
|
|
" nvim only theme
|
|
|
|
" has('nvim') check if it's running on nvim rather than
|
|
" having neovim on your machine
|
|
"if isdirectory(expand(plugin_dir . "/github-nvim-theme")) && has('nvim') && g:vim_version >= 0.5
|
|
" let g:github_function_style = "italic"
|
|
" "let g:github_sidebars = ["qf", "vista_kind", "terminal", "packer"]
|
|
"
|
|
" let g:dark_theme = 'github_dark'
|
|
" let g:light_theme = 'github_light'
|
|
if isdirectory(expand(plugin_dir . "/nightfox.nvim")) && has('nvim') && g:vim_version >= 0.5
|
|
"let g:dark_theme = 'nordfox'
|
|
let g:light_theme = 'dawnfox'
|
|
let g:dark_theme = 'nightfox'
|
|
let g:airline_dark_theme = "hybrid"
|
|
" }
|
|
|
|
" {
|
|
" vim theme
|
|
elseif isdirectory(expand(plugin_dir . "/papercolor-theme"))
|
|
" improve coc color in this theme
|
|
let g:light_theme = 'PaperColor'
|
|
let g:dark_theme = 'PaperColor'
|
|
endif
|
|
|
|
" }
|
|
|
|
if g:theme_color == 'dark'
|
|
set background=dark
|
|
execute("colorscheme " . g:dark_theme)
|
|
let g:airline_theme=g:airline_dark_theme
|
|
else
|
|
set background=light
|
|
execute("colorscheme " . g:light_theme)
|
|
let g:airline_theme=g:airline_light_theme
|
|
endif
|
|
|
|
" since in .vimrc we cannot call plugin function as they
|
|
" are not loaded (:help startup)
|
|
if g:transparent_dark_theme && g:theme_color == 'dark' || g:transparent_light_theme && g:theme_color == 'light'
|
|
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
|
let g:transparent_enabled = v:true
|
|
else
|
|
call EnableTransparent()
|
|
endif
|
|
else
|
|
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
|
let g:transparent_enabled = v:false
|
|
else
|
|
call DisableTransparent()
|
|
endif
|
|
endif
|
|
|
|
" Allow to trigger background
|
|
function! ToggleBG()
|
|
" Inversion
|
|
if g:theme_color == "dark"
|
|
set background=light
|
|
execute("colorscheme " . g:light_theme)
|
|
call SetAirlineTheme(g:airline_light_theme)
|
|
let g:theme_color = 'light'
|
|
call CreateSignalFile('.light_theme.signal')
|
|
else
|
|
set background=dark
|
|
execute("colorscheme " . g:dark_theme)
|
|
call SetAirlineTheme(g:airline_dark_theme)
|
|
let g:theme_color = 'dark'
|
|
" for saving theme state
|
|
call DeleteSignalFile(".light_theme.signal")
|
|
endif
|
|
|
|
if g:transparent_dark_theme && g:theme_color == 'dark' || g:transparent_light_theme && g:theme_color == 'light'
|
|
call EnableTransparent()
|
|
else
|
|
call DisableTransparent()
|
|
endif
|
|
endfunction
|
|
|
|
" }
|
|
|
|
" Key_Mappings
|
|
" (This doesn't include plugin specific mapping.
|
|
" For them please check plugin Preferences)
|
|
" {
|
|
|
|
" Toggle dark/light theme
|
|
noremap <leader>bg :call ToggleBG()<CR>
|
|
|
|
" Toggle transparent background
|
|
noremap <leader>tb :call ToggleTransparent()<CR>
|
|
|
|
" Buffer navigation
|
|
nnoremap <space>q :bprevious<CR>
|
|
nnoremap <space>e :bnext<CR>
|
|
|
|
" leader s change all occurence
|
|
nnoremap <Leader>s :%s/\<<C-r><C-w>\>/
|
|
|
|
" leader num change tab
|
|
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>
|
|
" }
|