353 lines
11 KiB
Plaintext
353 lines
11 KiB
Plaintext
" If anything not work as expected. Please make sure all plugins
|
|
" are installed by running:
|
|
" :PlugInstall
|
|
|
|
" Environment {
|
|
|
|
" Basics {
|
|
set nocompatible " Must be first line
|
|
" }
|
|
" }
|
|
"
|
|
" Plugin directory
|
|
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'
|
|
" syntax highlighting(and more) for typescript
|
|
" {
|
|
Plug 'leafgarland/typescript-vim'
|
|
" }
|
|
" {
|
|
Plug 'alvan/vim-closetag'
|
|
let g:closetag_filenames = '*.html,*.xhtml,*.phtml, *.js'
|
|
" }
|
|
|
|
"{
|
|
"Plug 'altercation/vim-colors-solarized'
|
|
"}
|
|
|
|
Plug 'scrooloose/nerdtree'
|
|
|
|
" for markdown{
|
|
Plug 'godlygeek/tabular'
|
|
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'
|
|
"let g:AutoPairsFlyMode = 1
|
|
|
|
" }
|
|
" {
|
|
Plug 'mg979/vim-visual-multi'
|
|
" }
|
|
"if has('nvim') && str2float(g:nvim_version) >= 0.5
|
|
" Plug 'nvim-lualine/lualine.nvim'
|
|
"else
|
|
Plug 'vim-airline/vim-airline'
|
|
Plug 'vim-airline/vim-airline-themes'
|
|
"endif
|
|
|
|
" For nvim-bufferline
|
|
" {
|
|
"Plug 'kyazdani42/nvim-web-devicons'
|
|
"Plug 'akinsho/nvim-bufferline.lua'
|
|
" }
|
|
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
|
|
|
|
" nvim support only theme
|
|
" {
|
|
"Plug 'projekt0n/github-nvim-theme'
|
|
" }
|
|
|
|
" vim theme
|
|
" {
|
|
Plug 'danilo-augusto/vim-afterglow'
|
|
Plug 'NLKNguyen/papercolor-theme'
|
|
" }
|
|
|
|
if g:vim_type == 'nvim' && g:vim_version > 0.5
|
|
Plug 'xiyaowong/nvim-transparent'
|
|
endif
|
|
Plug 'EdenEast/nightfox.nvim'
|
|
|
|
call plug#end()
|
|
|
|
" Helper functions
|
|
" {
|
|
|
|
" }
|
|
|
|
" Plugin Preferences
|
|
" {
|
|
" 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']
|
|
|
|
" space-d jump to definition if coc is installed
|
|
"nnoremap <silent><nowait> <space>d :call CocAction('jumpDefinition', v: false)<CR>
|
|
"nnoremap <silent><nowait> <space>r :call CocAction('jumpReferences', v: false)<CR>
|
|
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
|
|
if filereadable(expand(g:vim_dir . '.transparent_theme.signal'))
|
|
let g:transparent_theme = v:true
|
|
else
|
|
let g:transparent_theme = v:false
|
|
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:afterglow_inherit_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:afterglow_inherit_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
|
|
|
|
" ToggleTransparent background
|
|
" only works in dark theme
|
|
function! ToggleTransparent()
|
|
if g:transparent_theme == v:true
|
|
call DisableTransparent()
|
|
let g:transparent_theme = v:false
|
|
if filereadable(expand(g:vim_dir . '.transparent_theme.signal'))
|
|
call delete(expand(g:vim_dir . ".transparent_theme.signal"))
|
|
endif
|
|
else
|
|
call EnableTransparent()
|
|
let g:transparent_theme = v:true
|
|
call system("touch " . g:vim_dir . ".transparent_theme.signal")
|
|
endif
|
|
endfunction
|
|
|
|
noremap <leader>tb :call ToggleTransparent()<CR>
|
|
|
|
" {
|
|
" 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 = 'Nightfox'
|
|
let g:dark_theme = 'Nordfox'
|
|
let g:light_theme = 'Dayfox'
|
|
|
|
" }
|
|
|
|
" {
|
|
" vim theme
|
|
elseif isdirectory(expand(plugin_dir . "/vim-afterglow"))
|
|
if isdirectory(expand(plugin_dir . "/papercolor-theme"))
|
|
let g:light_theme = 'PaperColor'
|
|
endif
|
|
"let g:afterglow_inherit_background=1
|
|
let g:dark_theme = 'afterglow'
|
|
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_theme
|
|
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 system("touch " . g:vim_dir . ".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
|
|
if filereadable(expand(g:vim_dir . '.light_theme.signal'))
|
|
call delete(expand(g:vim_dir . ".light_theme.signal"))
|
|
endif
|
|
endif
|
|
|
|
if g:transparent_theme
|
|
call EnableTransparent()
|
|
else
|
|
call DisableTransparent()
|
|
endif
|
|
endfunction
|
|
|
|
noremap <leader>bg :call ToggleBG()<CR>
|
|
" }
|
|
|