aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorjdhao <jdhao@hotmail.com>2020-10-31 01:13:09 +0800
committerjdhao <jdhao@hotmail.com>2020-10-31 01:13:09 +0800
commitd0827ae776a83cddb30a4e7dada8d9f491cde334 (patch)
tree9c4c39037c9e1288ceaa87a49c604c3bc7e28e94 /core
parentbbceffe9cf7d806503930b82b0ac987d0fd9c0bd (diff)
move custom settings to core/ directory
Diffstat (limited to 'core')
-rw-r--r--core/autocommands.vim77
-rw-r--r--core/mappings.vim213
-rw-r--r--core/options.vim167
-rw-r--r--core/plugins.vim847
-rw-r--r--core/ui.vim111
-rw-r--r--core/variables.vim56
6 files changed, 1471 insertions, 0 deletions
diff --git a/core/autocommands.vim b/core/autocommands.vim
new file mode 100644
index 0000000..a64770d
--- /dev/null
+++ b/core/autocommands.vim
@@ -0,0 +1,77 @@
+"{ Auto commands
+" Do not use smart case in command line mode, extracted from https://vi.stackexchange.com/a/16511/15292.
+augroup dynamic_smartcase
+ autocmd!
+ autocmd CmdLineEnter : set nosmartcase
+ autocmd CmdLineLeave : set smartcase
+augroup END
+
+augroup term_settings
+ autocmd!
+ " Do not use number and relative number for terminal inside nvim
+ autocmd TermOpen * setlocal norelativenumber nonumber
+ " Go to insert mode by default to start typing command
+ autocmd TermOpen * startinsert
+augroup END
+
+" More accurate syntax highlighting? (see `:h syn-sync`)
+augroup accurate_syn_highlight
+ autocmd!
+ autocmd BufEnter * :syntax sync fromstart
+augroup END
+
+" Return to last edit position when opening a file
+augroup resume_edit_position
+ autocmd!
+ autocmd BufReadPost *
+ \ if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit' | execute "normal! g`\"zvzz" | endif
+augroup END
+
+" Display a message when the current file is not in utf-8 format.
+" Note that we need to use `unsilent` command here because of this issue:
+" https://github.com/vim/vim/issues/4379
+augroup non_utf8_file_warn
+ autocmd!
+ autocmd BufRead * if &fileencoding != 'utf-8' | unsilent echomsg 'File not in UTF-8 format!' | endif
+augroup END
+
+" Automatically reload the file if it is changed outside of Nvim, see
+" https://unix.stackexchange.com/a/383044/221410. It seems that `checktime`
+" command does not work in command line. We need to check if we are in command
+" line before executing this command. See also
+" https://vi.stackexchange.com/a/20397/15292.
+augroup auto_read
+ autocmd!
+ autocmd FocusGained,BufEnter,CursorHold,CursorHoldI *
+ \ if mode() == 'n' && getcmdwintype() == '' | checktime | endif
+ autocmd FileChangedShellPost * echohl WarningMsg
+ \ | echo "File changed on disk. Buffer reloaded!" | echohl None
+augroup END
+
+augroup numbertoggle
+ autocmd!
+ autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu | set rnu | endif
+ autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif
+augroup END
+
+" highlight yanked region, see `:h lua-highlight`
+augroup custom_highlight
+ autocmd!
+ autocmd ColorScheme * highlight YankColor ctermfg=59 ctermbg=41 guifg=#34495E guibg=#2ECC71
+augroup END
+
+augroup highlight_yank
+ autocmd!
+ au TextYankPost * silent! lua vim.highlight.on_yank{higroup="YankColor", timeout=300}
+augroup END
+
+" Clear cmd line message
+function! s:empty_message(timer)
+ if mode() ==# 'n' | echo '' | endif
+endfunction
+
+augroup cmd_msg_cls
+ autocmd!
+ autocmd CursorHold * call timer_start(25000, funcref('s:empty_message'))
+augroup END
+"}
diff --git a/core/mappings.vim b/core/mappings.vim
new file mode 100644
index 0000000..26bb3f3
--- /dev/null
+++ b/core/mappings.vim
@@ -0,0 +1,213 @@
+"{ Custom key mappings
+" Save key strokes (now we do not need to press shift to enter command mode).
+" Vim-sneak has also mapped `;`, so using the below mapping will break the map
+" used by vim-sneak
+nnoremap ; :
+xnoremap ; :
+
+" Quicker way to open command window
+nnoremap q; q:
+
+" Quicker <Esc> in insert mode
+inoremap jk <Esc>
+
+" Turn the word under cursor to upper case
+inoremap <c-u> <Esc>viwUea
+
+" Turn the current word into title case
+inoremap <c-t> <Esc>b~lea
+
+" Paste non-linewise text above or below current cursor,
+" see https://stackoverflow.com/a/1346777/6064933
+nnoremap <leader>p m`o<ESC>p``
+nnoremap <leader>P m`O<ESC>p``
+
+" Shortcut for faster save and quit
+nnoremap <silent> <leader>w :<C-U>update<CR>
+" Saves the file if modified and quit
+nnoremap <silent> <leader>q :<C-U>x<CR>
+" Quit all opened buffers
+nnoremap <silent> <leader>Q :<C-U>qa<CR>
+
+" Navigation in the location and quickfix list
+nnoremap <silent> [l :<C-U>lprevious<CR>zv
+nnoremap <silent> ]l :<C-U>lnext<CR>zv
+nnoremap <silent> [L :<C-U>lfirst<CR>zv
+nnoremap <silent> ]L :<C-U>llast<CR>zv
+nnoremap <silent> [q :<C-U>cprevious<CR>zv
+nnoremap <silent> ]q :<C-U>cnext<CR>zv
+nnoremap <silent> [Q :<C-U>cfirst<CR>zv
+nnoremap <silent> ]Q :<C-U>clast<CR>zv
+
+" Close location list or quickfix list if they are present,
+" see https://superuser.com/q/355325/736190
+nnoremap<silent> \x :<C-U>windo lclose <bar> cclose<CR>
+
+" Close a buffer and switching to another buffer, do not close the
+" window, see https://stackoverflow.com/q/4465095/6064933
+nnoremap <silent> \d :<C-U>bprevious <bar> bdelete #<CR>
+
+" Insert a blank line below or above current line (do not move the cursor),
+" see https://stackoverflow.com/a/16136133/6064933
+nnoremap <expr> oo printf('m`%so<ESC>``', v:count1)
+nnoremap <expr> OO printf('m`%sO<ESC>``', v:count1)
+
+" nnoremap oo @='m`o<c-v><Esc>``'<cr>
+" nnoremap OO @='m`O<c-v><Esc>``'<cr>
+
+" the following two mappings work, but if you change double quote to single, it
+" will not work
+" nnoremap oo @="m`o\<lt>Esc>``"<cr>
+" nnoremap oo @="m`o\e``"<cr>
+
+" Insert a space after current character
+nnoremap <Space><Space> a<Space><ESC>h
+
+" Yank from current cursor position to the end of the line (make it
+" consistent with the behavior of D, C)
+nnoremap Y y$
+
+" Move the cursor based on physical lines, not the actual lines.
+nnoremap <expr> j (v:count == 0 ? 'gj' : 'j')
+nnoremap <expr> k (v:count == 0 ? 'gk' : 'k')
+nnoremap ^ g^
+nnoremap 0 g0
+
+" Do not include white space characters when using $ in visual mode,
+" see https://vi.stackexchange.com/q/12607/15292
+xnoremap $ g_
+
+" Jump to matching pairs easily in normal mode
+nnoremap <Tab> %
+
+" Go to start or end of line easier
+nnoremap H ^
+xnoremap H ^
+nnoremap L g_
+xnoremap L g_
+
+" Fast window switching, inspiration from
+" https://stackoverflow.com/a/4373470/6064933
+nnoremap <M-left> <C-w>h
+nnoremap <M-right> <C-w>l
+nnoremap <M-down> <C-w>j
+nnoremap <M-up> <C-w>k
+
+" Continuous visual shifting (does not exit Visual mode), `gv` means
+" to reselect previous visual area, see https://superuser.com/q/310417/736190
+xnoremap < <gv
+xnoremap > >gv
+
+" When completion menu is shown, use <cr> to select an item and do not add an
+" annoying newline. Otherwise, <enter> is what it is. For more info , see
+" https://superuser.com/a/941082/736190 and
+" https://unix.stackexchange.com/q/162528/221410
+inoremap <expr> <cr> ((pumvisible())?("\<C-Y>"):("\<cr>"))
+" Use <esc> to close auto-completion menu
+inoremap <expr> <esc> ((pumvisible())?("\<C-e>"):("\<esc>"))
+
+" Tab-complete, see https://vi.stackexchange.com/q/19675/15292.
+inoremap <expr> <tab> pumvisible() ? "\<c-n>" : "\<tab>"
+inoremap <expr> <s-tab> pumvisible() ? "\<c-p>" : "\<s-tab>"
+
+" Edit and reload init.vim quickly
+nnoremap <silent> <leader>ev :<C-U>tabnew $MYVIMRC <bar> tcd %:h<cr>
+nnoremap <silent> <leader>sv :<C-U>silent update $MYVIMRC <bar> source $MYVIMRC <bar>
+ \ echomsg "Nvim config successfully reloaded!"<cr>
+
+" Reselect the text that has just been pasted, see also https://stackoverflow.com/a/4317090/6064933.
+nnoremap <expr> <leader>v printf('`[%s`]', getregtype()[0])
+
+" Search in selected region
+vnoremap / :<C-U>call feedkeys('/\%>'.(line("'<")-1).'l\%<'.(line("'>")+1)."l")<CR>
+
+" Find and replace (like Sublime Text 3)
+nnoremap <C-H> :%s/
+xnoremap <C-H> :s/
+
+" Change current working directory locally and print cwd after that,
+" see https://vim.fandom.com/wiki/Set_working_directory_to_the_current_file
+nnoremap <silent> <leader>cd :<C-U>lcd %:p:h<CR>:pwd<CR>
+
+" Use Esc to quit builtin terminal
+tnoremap <ESC> <C-\><C-n>
+
+" Toggle spell checking (autosave does not play well with z=, so we disable it
+" when we are doing spell checking)
+nnoremap <silent> <F11> :<C-U>set spell! <bar> :AutoSaveToggle<cr>
+inoremap <silent> <F11> <C-O>:<C-U>set spell! <bar> :AutoSaveToggle<cr>
+
+" Decrease indent level in insert mode with shift+tab
+inoremap <S-Tab> <ESC><<i
+
+" Change text without putting it into the vim register,
+" see https://stackoverflow.com/q/54255/6064933
+nnoremap c "_c
+nnoremap C "_C
+nnoremap cc "_cc
+xnoremap c "_c
+
+" Remove trailing whitespace characters
+nnoremap <silent> <leader><Space> :<C-U>call utils#StripTrailingWhitespaces()<CR>
+
+" check the syntax group of current cursor position
+nnoremap <silent> <leader>st :<C-U>call utils#SynGroup()<CR>
+
+" Clear highlighting
+if maparg('<C-L>', 'n') ==# ''
+ nnoremap <silent> <C-L> :<C-U>nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
+endif
+
+" Copy entire buffer.
+nnoremap <silent> <leader>y :<C-U>%y<CR>
+
+" Toggle cursor column
+nnoremap <silent> <leader>cl :<C-U>call utils#ToggleCursorCol()<CR>
+
+" Move current line up and down
+nnoremap <silent> <A-k> <Cmd>call utils#SwitchLine(line('.'), 'up')<CR>
+nnoremap <silent> <A-j> <Cmd>call utils#SwitchLine(line('.'), 'down')<CR>
+
+" Move current visual-line selection up and down
+xnoremap <silent> <A-k> :<C-U>call utils#MoveSelection('up')<CR>
+xnoremap <silent> <A-j> :<C-U>call utils#MoveSelection('down')<CR>
+
+" Replace visual selection with text in register, but not contaminate the
+" register, see also https://stackoverflow.com/q/10723700/6064933.
+xnoremap p "_c<ESC>p
+
+nnoremap <silent> gb :<C-U>call <SID>GoToBuffer(v:count, 'forward')<CR>
+nnoremap <silent> gB :<C-U>call <SID>GoToBuffer(v:count, 'backward')<CR>
+
+function! s:GoToBuffer(count, direction) abort
+ if a:count == 0
+ if a:direction ==# 'forward'
+ bnext
+ elseif a:direction ==# 'backward'
+ bprevious
+ else
+ echoerr 'Bad argument ' a:direction
+ endif
+ return
+ endif
+ " Check the validity of buffer number.
+ if index(s:GetBufNums(), a:count) == -1
+ echohl WarningMsg | echomsg 'Invalid bufnr: ' a:count | echohl None
+ return
+ endif
+
+ " Do not use {count} for gB (it is less useful)
+ if a:direction ==# 'forward'
+ silent execute('buffer' . a:count)
+ endif
+endfunction
+
+function! s:GetBufNums() abort
+ return map(copy(getbufinfo({'buflisted':1})), 'v:val.bufnr')
+endfunction
+
+nnoremap <Left> <C-W>h
+nnoremap <Right> <C-W>l
+nnoremap <Up> <C-W>k
+nnoremap <Down> <C-W>j
+"}
diff --git a/core/options.vim b/core/options.vim
new file mode 100644
index 0000000..9b8dda1
--- /dev/null
+++ b/core/options.vim
@@ -0,0 +1,167 @@
+scriptencoding utf-8
+
+"{ Builtin options and settings
+" change filechar for folding, vertical split, and message separator
+set fillchars=fold:\ ,vert:\│,msgsep:‾
+
+" Paste mode toggle, it seems that Neovim's bracketed paste mode
+" does not work very well for nvim-qt, so we use good-old paste mode
+set pastetoggle=<F12>
+
+" Split window below/right when creating horizontal/vertical windows
+set splitbelow splitright
+
+" Time in milliseconds to wait for a mapped sequence to complete,
+" see https://unix.stackexchange.com/q/36882/221410 for more info
+set timeoutlen=1000
+
+set updatetime=1000 " For CursorHold events
+
+" Clipboard settings, always use clipboard for all delete, yank, change, put
+" operation, see https://stackoverflow.com/q/30691466/6064933
+if !empty(provider#clipboard#Executable())
+ set clipboard+=unnamedplus
+endif
+
+" Disable creating swapfiles, see https://stackoverflow.com/q/821902/6064933
+set noswapfile
+
+" Set up backup directory
+let g:backupdir=expand(stdpath('data') . '/backup')
+if !isdirectory(g:backupdir)
+ call mkdir(g:backupdir, 'p')
+endif
+let &backupdir=g:backupdir
+
+set backupcopy=yes " copy the original file to backupdir and overwrite it
+
+" General tab settings
+set tabstop=4 " number of visual spaces per TAB
+set softtabstop=4 " number of spaces in tab when editing
+set shiftwidth=4 " number of spaces to use for autoindent
+set expandtab " expand tab to spaces so that tabs are spaces
+
+" Set matching pairs of characters and highlight matching brackets
+set matchpairs+=<:>,「:」,『:』,【:】,“:”,‘:’,《:》
+
+set number relativenumber " Show line number and relative line number
+
+" Ignore case in general, but become case-sensitive when uppercase is present
+set ignorecase smartcase
+
+" File and script encoding settings for vim
+set fileencoding=utf-8
+set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
+
+" Break line at predefined characters
+set linebreak
+" Character to show before the lines that have been soft-wrapped
+set showbreak=↪
+
+" List all matches and complete till longest common string
+set wildmode=list:longest
+set wildignorecase " ignore file and dir name cases in cmd-completion
+
+set cursorline " Show current line where the cursor is
+
+" Minimum lines to keep above and below cursor when scrolling
+set scrolloff=3
+
+" Use mouse to select and resize windows, etc.
+set mouse=nic " Enable mouse in several mode
+set mousemodel=popup " Set the behaviour of mouse
+
+" Do not show mode on command line since vim-airline can show it
+set noshowmode
+
+set fileformats=unix,dos " Fileformats to use for new files
+
+set inccommand=nosplit " Show the result of substitution in real time for preview
+
+" Ignore certain files and folders when globbing
+set wildignore+=*.o,*.obj,*.bin,*.dll,*.exe
+set wildignore+=*/.git/*,*/.svn/*,*/__pycache__/*,*/build/**
+set wildignore+=*.pyc
+set wildignore+=*.DS_Store
+set wildignore+=*.aux,*.bbl,*.blg,*.brf,*.fls,*.fdb_latexmk,*.synctex.gz
+
+" Ask for confirmation when handling unsaved or read-only files
+set confirm
+
+set visualbell noerrorbells " Do not use visual and errorbells
+set history=500 " The number of command and search history to keep
+
+" Use list mode and customized listchars
+set list listchars=tab:▸\ ,extends:❯,precedes:❮,nbsp:+
+
+" Auto-write the file based on some condition
+set autowrite
+
+" Show hostname, full path of file and last-mod time on the window title. The
+" meaning of the format str for strftime can be found in
+" http://man7.org/linux/man-pages/man3/strftime.3.html. The function to get
+" lastmod time is drawn from https://stackoverflow.com/q/8426736/6064933
+set title
+set titlestring=
+if g:is_linux
+ set titlestring+=%(%{hostname()}\ \ %)
+endif
+set titlestring+=%(%{expand('%:p:~')}\ \ %)
+set titlestring+=%{strftime('%Y-%m-%d\ %H:%M',getftime(expand('%')))}
+
+" Persistent undo even after you close a file and re-open it
+set undofile
+
+" Do not show "match xx of xx" and other messages during auto-completion
+set shortmess+=c
+
+" Completion behaviour
+" set completeopt+=noinsert " Auto select the first completion entry
+set completeopt+=menuone " Show menu even if there is only one item
+set completeopt-=preview " Disable the preview window
+
+set pumheight=10 " Maximum number of items to show in popup menu
+
+" Insert mode key word completion setting
+set complete+=kspell complete-=w complete-=b complete-=u complete-=t
+
+set spelllang=en,cjk " Spell languages
+set spellsuggest+=10 " The number of suggestions shown in the screen for z=
+
+" Align indent to next multiple value of shiftwidth. For its meaning,
+" see http://vim.1045645.n5.nabble.com/shiftround-option-td5712100.html
+set shiftround
+
+set virtualedit=block " Virtual edit is useful for visual block edit
+
+" Correctly break multi-byte characters such as CJK,
+" see https://stackoverflow.com/q/32669814/6064933
+set formatoptions+=mM
+
+" Tilde (~) is an operator, thus must be followed by motions like `e` or `w`.
+set tildeop
+
+" Do not add two spaces after a period when joining lines or formatting texts,
+" see https://stackoverflow.com/q/4760428/6064933
+set nojoinspaces
+
+set synmaxcol=200 " Text after this column number is not highlighted
+set nostartofline
+
+" External program to use for grep command
+if executable('rg')
+ set grepprg=rg\ --vimgrep\ --no-heading\ --smart-case
+ set grepformat=%f:%l:%c:%m
+endif
+
+" Highlight groups for cursor color
+augroup cursor_color
+ autocmd!
+ autocmd ColorScheme * highlight Cursor cterm=bold gui=bold guibg=cyan guifg=black
+ autocmd ColorScheme * highlight Cursor2 guifg=red guibg=red
+augroup END
+
+" Set up cursor color and shape in various mode, ref:
+" https://github.com/neovim/neovim/wiki/FAQ#how-to-change-cursor-color-in-the-terminal
+set guicursor=n-v-c:block-Cursor/lCursor,i-ci-ve:ver25-Cursor2/lCursor2,r-cr:hor20,o:hor20
+"}
diff --git a/core/plugins.vim b/core/plugins.vim
new file mode 100644
index 0000000..eabda6f
--- /dev/null
+++ b/core/plugins.vim
@@ -0,0 +1,847 @@
+scriptencoding utf-8
+"{ Plugin installation
+"{{ Vim-plug related settings.
+" The root directory to install all plugins.
+let g:PLUGIN_HOME=expand(stdpath('data') . '/plugged')
+
+if empty(readdir(g:PLUGIN_HOME))
+ augroup plug_init
+ autocmd!
+ autocmd VimEnter * PlugInstall --sync | quit |source $MYVIMRC
+ augroup END
+endif
+"}}
+
+"{{ Autocompletion related plugins
+call plug#begin(g:PLUGIN_HOME)
+" Auto-completion
+Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
+
+if executable('clang') && (g:is_mac || g:is_linux)
+ Plug 'deoplete-plugins/deoplete-clang'
+endif
+
+" Python source for deoplete
+Plug 'zchee/deoplete-jedi', { 'for': 'python' }
+
+" Vim source for deoplete
+Plug 'Shougo/neco-vim', { 'for': 'vim' }
+"}}
+
+"{{ Python-related plugins
+" Python completion, goto definition etc.
+Plug 'davidhalter/jedi-vim', { 'for': 'python' }
+
+" Python syntax highlighting and more
+if g:is_mac || g:is_win
+ Plug 'numirias/semshi', { 'do': ':UpdateRemotePlugins' }
+endif
+
+" Python indent (follows the PEP8 style)
+Plug 'Vimjas/vim-python-pep8-indent', {'for': 'python'}
+
+" Python-related text object
+Plug 'jeetsukumaran/vim-pythonsense'
+Plug 'machakann/vim-swap'
+"}}
+
+"{{ Search related plugins
+" Super fast movement with vim-sneak
+Plug 'justinmk/vim-sneak'
+
+" Clear highlight search automatically for you
+Plug 'romainl/vim-cool'
+
+" Show current search term in different color
+Plug 'PeterRincker/vim-searchlight'
+
+" Show match number for incsearch
+Plug 'osyo-manga/vim-anzu'
+
+" Stay after pressing * and search selected text
+Plug 'haya14busa/vim-asterisk'
+
+" File search, tag search and more
+if g:is_win
+ Plug 'Yggdroot/LeaderF'
+else
+ Plug 'Yggdroot/LeaderF', { 'do': './install.sh' }
+endif
+
+" Another similar plugin is command-t
+" Plug 'wincent/command-t'
+
+" Another grep tool (similar to Sublime Text Ctrl+Shift+F)
+" Plug 'dyng/ctrlsf.vim'
+
+" A greping tool
+" Plug 'mhinz/vim-grepper', { 'on': ['Grepper', '<plug>(GrepperOperator)'] }
+"}}
+
+"{{ UI: Color, theme etc.
+" A list of colorscheme plugin you may want to try. Find what suits you.
+Plug 'lifepillar/vim-gruvbox8'
+Plug 'srcery-colors/srcery-vim'
+Plug 'ajmwagar/vim-deus'
+Plug 'YorickPeterse/happy_hacking.vim'
+Plug 'lifepillar/vim-solarized8'
+" Do not try other monokai-tasty and monokai-pro anymore, they
+" all have bad DiffDelete highlight issues.
+Plug 'sickill/vim-monokai'
+Plug 'rakr/vim-one'
+Plug 'kaicataldo/material.vim'
+Plug 'joshdick/onedark.vim'
+Plug 'KeitaNakamura/neodark.vim'
+Plug 'jsit/toast.vim'
+
+if !exists('g:started_by_firenvim')
+ " colorful status line and theme
+ Plug 'vim-airline/vim-airline'
+ Plug 'vim-airline/vim-airline-themes'
+ Plug 'mhinz/vim-startify'
+endif
+"}}
+
+"{{ Plugin to deal with URL
+" Highlight URLs inside vim
+Plug 'itchyny/vim-highlighturl'
+
+" For Windows and Mac, we can open an URL in the browser. For Linux, it may
+" not be possible since we maybe in a server which disables GUI.
+if g:is_win || g:is_mac
+ " open URL in browser
+ Plug 'tyru/open-browser.vim'
+endif
+"}}
+
+"{{ Navigation and tags plugin
+" Only install these plugins if ctags are installed on the system
+if executable('ctags')
+ " plugin to manage your tags
+ Plug 'ludovicchabant/vim-gutentags'
+ " show file tags in vim window
+ Plug 'liuchengxu/vista.vim'
+endif
+"}}
+
+"{{ File editting plugin
+" Snippet engine and snippet template
+Plug 'SirVer/ultisnips'
+Plug 'honza/vim-snippets'
+
+" Automatic insertion and deletion of a pair of characters
+Plug 'jiangmiao/auto-pairs'
+
+" Comment plugin
+Plug 'tpope/vim-commentary'
+
+" Multiple cursor plugin like Sublime Text?
+" Plug 'mg979/vim-visual-multi'
+
+" Title character case
+Plug 'christoomey/vim-titlecase'
+
+" Autosave files on certain events
+Plug '907th/vim-auto-save'
+
+" Show undo history visually
+Plug 'simnalamburt/vim-mundo'
+
+" Manage your yank history
+if g:is_win || g:is_mac
+ Plug 'svermeulen/vim-yoink'
+endif
+
+Plug 'bfredl/nvim-miniyank'
+
+" Handy unix command inside Vim (Rename, Move etc.)
+Plug 'tpope/vim-eunuch'
+
+" Repeat vim motions
+Plug 'tpope/vim-repeat'
+
+" Show the content of register in preview window
+" Plug 'junegunn/vim-peekaboo'
+"}}
+
+"{{ Linting, formating
+" Syntax check and make
+" Plug 'neomake/neomake'
+
+" Another linting plugin
+Plug 'dense-analysis/ale'
+
+" Auto format tools
+Plug 'sbdchd/neoformat', { 'on': 'Neoformat' }
+" Plug 'Chiel92/vim-autoformat'
+"}}
+
+"{{ Git related plugins
+" Show git change (change, delete, add) signs in vim sign column
+Plug 'mhinz/vim-signify'
+" Another similar plugin
+" Plug 'airblade/vim-gitgutter'
+
+" Git command inside vim
+Plug 'tpope/vim-fugitive'
+Plug 'rhysd/git-messenger.vim'
+
+" Git commit browser
+Plug 'junegunn/gv.vim', { 'on': 'GV' }
+"}}
+
+"{{ Plugins for markdown writing
+" Another markdown plugin
+Plug 'plasticboy/vim-markdown', { 'for': 'markdown' }
+
+" Faster footnote generation
+Plug 'vim-pandoc/vim-markdownfootnotes', { 'for': 'markdown' }
+
+" Vim tabular plugin for manipulate tabular, required by markdown plugins
+Plug 'godlygeek/tabular', {'on': 'Tabularize'}
+
+" Markdown JSON header highlight plugin
+Plug 'elzr/vim-json', { 'for': ['json', 'markdown'] }
+
+" Markdown previewing (only for Mac and Windows)
+if g:is_win || g:is_mac
+ Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug'] }
+endif
+
+" emoji
+" Plug 'https://gitlab.com/gi1242/vim-emoji-ab'
+Plug 'fszymanski/deoplete-emoji', {'for': 'markdown'}
+
+if g:is_mac
+ Plug 'rhysd/vim-grammarous'
+endif
+
+Plug 'chrisbra/unicode.vim'
+"}}
+
+"{{ Text object plugins
+" Additional powerful text object for vim, this plugin should be studied
+" carefully to use its full power
+Plug 'wellle/targets.vim'
+
+" Plugin to manipulate characer pairs quickly
+" Plug 'tpope/vim-surround'
+Plug 'machakann/vim-sandwich'
+
+" Add indent object for vim (useful for languages like Python)
+Plug 'michaeljsmith/vim-indent-object'
+"}}
+
+"{{ LaTeX editting and previewing plugin
+" Only use these plugin on Windows and Mac and when LaTeX is installed
+if ( g:is_win || g:is_mac ) && executable('latex')
+ " vimtex use autoload feature of Vim, so it is not necessary to use `for`
+ " keyword of vim-plug to try to lazy-load it,
+ " see https://github.com/junegunn/vim-plug/issues/785
+ Plug 'lervag/vimtex'
+
+ " Plug 'matze/vim-tex-fold', {'for': 'tex'}
+ " Plug 'Konfekt/FastFold'
+endif
+"}}
+
+"{{ Tmux related plugins
+" Since tmux is only available on Linux and Mac, we only enable these plugins
+" for Linux and Mac
+if (g:is_linux || g:is_mac) && executable('tmux')
+ " Let vim detect tmux focus event correctly, see
+ " https://github.com/neovim/neovim/issues/9486 and
+ " https://vi.stackexchange.com/q/18515/15292
+ Plug 'tmux-plugins/vim-tmux-focus-events'
+
+ " .tmux.conf syntax highlighting and setting check
+ Plug 'tmux-plugins/vim-tmux', { 'for': 'tmux' }
+endif
+"}}
+
+"{{ HTML related
+Plug 'mattn/emmet-vim'
+"}}
+
+"{{ Misc plugins
+" Modern matchit implementation
+Plug 'andymass/vim-matchup'
+
+" Smoothie motions
+Plug 'psliwka/vim-smoothie'
+
+Plug 'tpope/vim-scriptease'
+
+" Asynchronous command execution
+Plug 'skywind3000/asyncrun.vim'
+" Another asynchronous plugin
+" Plug 'tpope/vim-dispatch'
+Plug 'cespare/vim-toml'
+
+" Edit text area in browser using nvim
+if g:is_mac || g:is_win
+ Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }
+endif
+
+" Debugger plugin
+if g:is_mac || g:is_linux
+ Plug 'sakhnik/nvim-gdb', { 'do': ':!./install.sh \| UpdateRemotePlugins' }
+endif
+call plug#end()
+"}}
+"}
+
+"{ Plugin settings
+"{{ Vim-plug settings
+" Use shortnames for common vim-plug command to reduce typing.
+" To use these shortcut: first activate command line with `:`, then input the
+" short alias, e.g., `pi`, then press <space>, the alias will be expanded
+" to the full command automatically
+call utils#Cabbrev('pi', 'PlugInstall')
+call utils#Cabbrev('pud', 'PlugUpdate')
+call utils#Cabbrev('pug', 'PlugUpgrade')
+call utils#Cabbrev('ps', 'PlugStatus')
+call utils#Cabbrev('pc', 'PlugClean')
+"}}
+
+"{{ Auto-completion related
+"""""""""""""""""""""""""""" deoplete settings""""""""""""""""""""""""""
+" Wheter to enable deoplete automatically after start nvim
+let g:deoplete#enable_at_startup = 1
+
+" Maximum candidate window width
+call deoplete#custom#source('_', 'max_menu_width', 80)
+
+" Minimum character length needed to activate auto-completion.
+call deoplete#custom#source('_', 'min_pattern_length', 1)
+
+" Whether to disable completion for certain syntax
+" call deoplete#custom#source('_', {
+" \ 'filetype': ['vim'],
+" \ 'disabled_syntaxes': ['String']
+" \ })
+call deoplete#custom#source('_', {
+ \ 'filetype': ['python'],
+ \ 'disabled_syntaxes': ['Comment']
+ \ })
+
+" Ignore certain sources, because they only cause nosie most of the time
+call deoplete#custom#option('ignore_sources', {
+ \ '_': ['around', 'buffer', 'tag']
+ \ })
+
+" Candidate list item number limit
+call deoplete#custom#option('max_list', 30)
+
+" The number of processes used for the deoplete parallel feature.
+call deoplete#custom#option('num_processes', 16)
+
+" The delay for completion after input, measured in milliseconds.
+call deoplete#custom#option('auto_complete_delay', 100)
+
+" Enable deoplete auto-completion
+call deoplete#custom#option('auto_complete', v:true)
+
+"""""""""""""""""""""""""UltiSnips settings"""""""""""""""""""
+" Trigger configuration. Do not use <tab> if you use YouCompleteMe
+let g:UltiSnipsExpandTrigger='<c-j>'
+
+" Do not look for SnipMate snippets
+let g:UltiSnipsEnableSnipMate = 0
+
+" Shortcut to jump forward and backward in tabstop positions
+let g:UltiSnipsJumpForwardTrigger='<c-j>'
+let g:UltiSnipsJumpBackwardTrigger='<c-k>'
+
+" Configuration for custom snippets directory, see
+" https://jdhao.github.io/2019/04/17/neovim_snippet_s1/ for details.
+let g:UltiSnipsSnippetDirectories=['UltiSnips', 'my_snippets']
+"}}
+
+"{{ Python-related
+""""""""""""""""""deoplete-jedi settings"""""""""""""""""""""""""""
+" Whether to show doc string
+let g:deoplete#sources#jedi#show_docstring = 0
+
+" For large package, set autocomplete wait time longer
+let g:deoplete#sources#jedi#server_timeout = 50
+
+" Ignore jedi errors during completion
+let g:deoplete#sources#jedi#ignore_errors = 1
+
+""""""""""""""""""""""""jedi-vim settings"""""""""""""""""""
+" Disable autocompletion, because I use deoplete for auto-completion
+let g:jedi#completions_enabled = 0
+
+" Whether to show function call signature
+let g:jedi#show_call_signatures = '0'
+
+"""""""""""""""""""""""""" semshi settings """""""""""""""""""""""""""""""
+" Do not highlight for all occurances of variable under cursor
+let g:semshi#mark_selected_nodes=0
+
+" Do not show error sign since linting plugin is specicialized for that
+let g:semshi#error_sign=v:false
+"}}
+
+"{{ Search related
+"""""""""""""""""""""""""""""vim-sneak settings"""""""""""""""""""""""
+" Use sneak label mode
+let g:sneak#label = 1
+
+nmap f <Plug>Sneak_s
+xmap f <Plug>Sneak_s
+onoremap <silent> f :call sneak#wrap(v:operator, 2, 0, 1, 1)<CR>
+nmap F <Plug>Sneak_S
+xmap F <Plug>Sneak_S
+onoremap <silent> F :call sneak#wrap(v:operator, 2, 1, 1, 1)<CR>
+
+" Immediately after entering sneak mode, you can press f and F to go to next
+" or previous match
+let g:sneak#s_next = 1
+
+"""""""""""""""""""""""""""""vim-anzu settings"""""""""""""""""""""""
+nmap n <Plug>(anzu-n-with-echo)zzzv
+nmap N <Plug>(anzu-N-with-echo)zzzv
+
+" Maximum number of words to search
+let g:anzu_search_limit = 500000
+
+" Message to show for search pattern
+let g:anzu_status_format = '/%p [%i/%l]'
+
+"""""""""""""""""""""""""""""vim-asterisk settings"""""""""""""""""""""
+nmap * <Plug>(asterisk-z*)
+nmap # <Plug>(asterisk-z#)
+xmap * <Plug>(asterisk-z*)
+xmap # <Plug>(asterisk-z#)
+
+"""""""""""""""""""""""""""""LeaderF settings"""""""""""""""""""""
+" Do not use cache file
+let g:Lf_UseCache = 0
+
+" Ignore certain files and directories when searching files
+let g:Lf_WildIgnore = {
+ \ 'dir': ['.git', '__pycache__', '.DS_Store'],
+ \ 'file': ['*.exe', '*.dll', '*.so', '*.o', '*.pyc', '*.jpg', '*.png',
+ \ '*.gif', '*.db', '*.tgz', '*.tar.gz', '*.gz', '*.zip', '*.bin', '*.pptx',
+ \ '*.xlsx', '*.docx', '*.pdf', '*.tmp', '*.wmv', '*.mkv', '*.mp4',
+ \ '*.rmvb']
+ \}
+
+" Do not show fancy icons for Linux server.
+if g:is_linux
+ let g:Lf_ShowDevIcons = 0
+endif
+
+" Only fuzzy-search files names
+let g:Lf_DefaultMode = 'NameOnly'
+
+let g:Lf_PopupColorscheme = 'gruvbox_default'
+
+" Popup window settings
+let g:Lf_PopupWidth = 0.5
+let g:Lf_PopupPosition = [0, &columns/4]
+
+" Do not use version control tool to list files under a directory since
+" submodules are not searched by default.
+let g:Lf_UseVersionControlTool = 0
+
+" Disable default mapping
+let g:Lf_ShortcutF = ''
+let g:Lf_ShortcutB = ''
+
+" set up working directory for git repository
+let g:Lf_WorkingDirectoryMode = 'a'
+
+" Search files in popup window
+nnoremap <silent> <leader>f :<C-U>Leaderf file --popup<CR>
+" Search vim help files
+nnoremap <silent> <leader>h :<C-U>Leaderf help --popup<CR>
+" Search tags in current buffer
+nnoremap <silent> <leader>t :<C-U>Leaderf bufTag --popup<CR>
+"}}
+
+"{{ URL related
+""""""""""""""""""""""""""""open-browser.vim settings"""""""""""""""""""
+if g:is_win || g:is_mac
+ " Disable netrw's gx mapping.
+ let g:netrw_nogx = 1
+
+ " Use another mapping for the open URL method
+ nmap ob <Plug>(openbrowser-smart-search)
+ vmap ob <Plug>(openbrowser-smart-search)
+endif
+"}}
+
+"{{ Navigation and tags
+""""""""""""""""""""""""""" vista settings """"""""""""""""""""""""""""""""""
+" Double click to go to a tag
+nnoremap <silent> <2-LeftMouse> :<C-U>call vista#cursor#FoldOrJump()<CR>
+
+let g:vista#renderer#icons = {
+\ 'member': '',
+\ }
+
+" Do not echo message on command line
+let g:vista_echo_cursor = 0
+" Stay in current window when vista window is opened
+let g:vista_stay_on_open = 0
+
+nnoremap <silent> <Space>t :<C-U>Vista!!<CR>
+
+function! s:close_vista_win() abort
+ if winnr('$') == 1 && getbufvar(bufnr(), '&filetype') ==# 'vista'
+ quit
+ endif
+endfunction
+
+augroup vista_close_win
+ autocmd!
+ autocmd BufEnter * call s:close_vista_win()
+augroup END
+"}}
+
+"{{ File editting
+""""""""""""""""""""""""""""vim-titlecase settings"""""""""""""""""""""""
+" Do not use the default mapping provided
+let g:titlecase_map_keys = 0
+
+nmap <leader>gt <Plug>Titlecase
+vmap <leader>gt <Plug>Titlecase
+nmap <leader>gT <Plug>TitlecaseLine
+
+""""""""""""""""""""""""vim-auto-save settings"""""""""""""""""""""""
+" Enable autosave on nvim startup
+let g:auto_save = 1
+
+" A list of events to trigger autosave
+let g:auto_save_events = ['InsertLeave', 'TextChanged']
+
+" Whether to show autosave status on command line
+let g:auto_save_silent = 0
+
+""""""""""""""""""""""""vim-mundo settings"""""""""""""""""""""""
+let g:mundo_verbose_graph = 0
+let g:mundo_width = 80
+
+nnoremap <silent> <Space>u :MundoToggle<CR>
+
+""""""""""""""""""""""""""""vim-yoink settings"""""""""""""""""""""""""
+if g:is_win || g:is_mac
+ " ctrl-n and ctrl-p will not work if you add the TextChanged event to vim-auto-save events.
+ " nmap <c-n> <plug>(YoinkPostPasteSwapBack)
+ " nmap <c-p> <plug>(YoinkPostPasteSwapForward)
+
+ " The following p/P mappings are also needed for ctrl-n and ctrl-p to work
+ " nmap p <plug>(YoinkPaste_p)
+ " nmap P <plug>(YoinkPaste_P)
+
+ " Cycle the yank stack with the following mappings
+ nmap [y <plug>(YoinkRotateBack)
+ nmap ]y <plug>(YoinkRotateForward)
+
+ " Do not change the cursor position
+ nmap y <plug>(YoinkYankPreserveCursorPosition)
+ xmap y <plug>(YoinkYankPreserveCursorPosition)
+
+ " Move cursor to end of paste after multiline paste
+ let g:yoinkMoveCursorToEndOfPaste = 0
+
+ " Record yanks in system clipboard
+ let g:yoinkSyncSystemClipboardOnFocus = 1
+endif
+
+""""""""""""""""""""""""""""nvim-minipyank settings"""""""""""""""""""""""""
+nmap p <Plug>(miniyank-autoput)
+nmap P <Plug>(miniyank-autoPut)
+"}}
+
+"{{ Linting and formating
+"""""""""""""""""""""""""""""" ale settings """""""""""""""""""""""
+" linters for different filetypes
+let g:ale_linters = {
+ \ 'python': ['pylint'],
+ \ 'vim': ['vint'],
+ \ 'cpp': ['clang'],
+ \ 'c': ['clang']
+\}
+
+" Only run linters in the g:ale_linters dictionary
+let g:ale_linters_explicit = 1
+
+" Linter signs
+let g:ale_sign_error = 'x'
+let g:ale_sign_warning = '!'
+
+"""""""""""""""""""""""""""""" neoformat settings """""""""""""""""""""""
+let g:neoformat_enabled_python = ['black', 'yapf']
+let g:neoformat_cpp_clangformat = {
+ \ 'exe': 'clang-format',
+ \ 'args': ['--style="{IndentWidth: 4}"']
+\}
+let g:neoformat_c_clangformat = {
+ \ 'exe': 'clang-format',
+ \ 'args': ['--style="{IndentWidth: 4}"']
+\}
+
+let g:neoformat_enabled_cpp = ['clangformat']
+let g:neoformat_enabled_c = ['clangformat']
+"}}
+
+"{{ Git-related
+"""""""""""""""""""""""""vim-signify settings""""""""""""""""""""""""""""""
+" The VCS to use
+let g:signify_vcs_list = [ 'git' ]
+
+" Change the sign for certain operations
+let g:signify_sign_change = '~'
+"}}
+
+"{{ Markdown writing
+"""""""""""""""""""""""""plasticboy/vim-markdown settings"""""""""""""""""""
+" Disable header folding
+let g:vim_markdown_folding_disabled = 1
+
+" Whether to use conceal feature in markdown
+let g:vim_markdown_conceal = 1
+
+" Disable math tex conceal and syntax highlight
+let g:tex_conceal = ''
+let g:vim_markdown_math = 0
+
+" Support front matter of various format
+let g:vim_markdown_frontmatter = 1 " for YAML format
+let g:vim_markdown_toml_frontmatter = 1 " for TOML format
+let g:vim_markdown_json_frontmatter = 1 " for JSON format
+
+" Let the TOC window autofit so that it doesn't take too much space
+let g:vim_markdown_toc_autofit = 1
+
+"""""""""""""""""""""""""markdown-preview settings"""""""""""""""""""
+" Only setting this for suitable platforms
+if g:is_win || g:is_mac
+ " Do not close the preview tab when switching to other buffers
+ let g:mkdp_auto_close = 0
+
+ " Shortcuts to start and stop markdown previewing
+ nnoremap <silent> <M-m> :<C-U>MarkdownPreview<CR>
+ nnoremap <silent> <M-S-m> :<C-U>MarkdownPreviewStop<CR>
+endif
+
+""""""""""""""""""""""""vim-markdownfootnotes settings""""""""""""""""""""""""
+" Replace the default mappings provided by the plugin
+imap ^^ <Plug>AddVimFootnote
+nmap ^^ <Plug>AddVimFootnote
+imap @@ <Plug>ReturnFromFootnote
+nmap @@ <Plug>ReturnFromFootnote
+
+""""""""""""""""""""""""vim-grammarous settings""""""""""""""""""""""""""""""
+if g:is_mac
+ let g:grammarous#languagetool_cmd = 'languagetool'
+ nmap <leader>x <Plug>(grammarous-close-info-window)
+ nmap <c-n> <Plug>(grammarous-move-to-next-error)
+ nmap <c-p> <Plug>(grammarous-move-to-previous-error)
+ let g:grammarous#disabled_rules = {
+ \ '*' : ['WHITESPACE_RULE', 'EN_QUOTES', 'ARROWS', 'SENTENCE_WHITESPACE',
+ \ 'WORD_CONTAINS_UNDERSCORE', 'COMMA_PARENTHESIS_WHITESPACE',
+ \ 'EN_UNPAIRED_BRACKETS', 'UPPERCASE_SENTENCE_START',
+ \ 'ENGLISH_WORD_REPEAT_BEGINNING_RULE', 'DASH_RULE', 'PLUS_MINUS',
+ \ 'PUNCTUATION_PARAGRAPH_END', 'MULTIPLICATION_SIGN', 'PRP_CHECKOUT',
+ \ 'CAN_CHECKOUT', 'SOME_OF_THE', 'DOUBLE_PUNCTUATION', 'HELL',
+ \ 'CURRENCY', 'POSSESSIVE_APOSTROPHE', 'ENGLISH_WORD_REPEAT_RULE',
+ \ 'NON_STANDARD_WORD', 'AU'],
+ \ }
+endif
+
+""""""""""""""""""""""""unicode.vim settings""""""""""""""""""""""""""""""
+nmap ga <Plug>(UnicodeGA)
+
+""""""""""""""""""""""""deoplete-emoji settings""""""""""""""""""""""""""""
+call deoplete#custom#source('emoji', 'converters', ['converter_emoji'])
+"}}
+
+"{{ text objects
+""""""""""""""""""""""""""""vim-sandwich settings"""""""""""""""""""""""""""""
+" Map s to nop since s in used by vim-sandwich. Use cl instead of s.
+nmap s <Nop>
+omap s <Nop>
+"}}
+
+"{{ LaTeX editting
+""""""""""""""""""""""""""""vimtex settings"""""""""""""""""""""""""""""
+if ( g:is_win || g:is_mac ) && executable('latex')
+ " Set up LaTeX flavor
+ let g:tex_flavor = 'latex'
+
+ " Deoplete configurations for autocompletion to work
+ call deoplete#custom#var('omni', 'input_patterns', {
+ \ 'tex': g:vimtex#re#deoplete
+ \ })
+
+ let g:vimtex_compiler_latexmk = {
+ \ 'build_dir' : 'build',
+ \ }
+
+ " TOC settings
+ let g:vimtex_toc_config = {
+ \ 'name' : 'TOC',
+ \ 'layers' : ['content', 'todo', 'include'],
+ \ 'resize' : 1,
+ \ 'split_width' : 30,
+ \ 'todo_sorted' : 0,
+ \ 'show_help' : 1,
+ \ 'show_numbers' : 1,
+ \ 'mode' : 2,
+ \ }
+
+ " Viewer settings for different platforms
+ if g:is_win
+ let g:vimtex_view_general_viewer = 'SumatraPDF'
+ let g:vimtex_view_general_options_latexmk = '-reuse-instance'
+ let g:vimtex_view_general_options = '-reuse-instance -forward-search @tex @line @pdf'
+ endif
+
+ " The following code is adapted from https://gist.github.com/skulumani/7ea00478c63193a832a6d3f2e661a536.
+ if g:is_mac
+ " let g:vimtex_view_method = "skim"
+ let g:vimtex_view_general_viewer = '/Applications/Skim.app/Contents/SharedSupport/displayline'
+ let g:vimtex_view_general_options = '-r @line @pdf @tex'
+
+ " This adds a callback hook that updates Skim after compilation
+ let g:vimtex_compiler_callback_hooks = ['UpdateSkim']
+
+ function! UpdateSkim(status) abort
+ if !a:status | return | endif
+
+ let l:out = b:vimtex.out()
+ let l:src_file_path = expand('%:p')
+ let l:cmd = [g:vimtex_view_general_viewer, '-r']
+
+ if !empty(system('pgrep Skim'))
+ call extend(l:cmd, ['-g'])
+ endif
+
+ call jobstart(l:cmd + [line('.'), l:out, l:src_file_path])
+ endfunction
+ endif
+endif
+"}}
+
+"{{ UI: Status line, look
+"""""""""""""""""""""""""""vim-airline setting""""""""""""""""""""""""""""""
+" Set airline theme to a random one if it exists
+let s:candidate_airlinetheme = ['ayu_mirage', 'lucius', 'ayu_dark', 'base16_bright',
+ \ 'base16_adwaita', 'jellybeans', 'luna', 'raven', 'term', 'base16_summerfruit']
+let s:idx = utils#RandInt(0, len(s:candidate_airlinetheme)-1)
+let s:theme = s:candidate_airlinetheme[s:idx]
+
+if utils#HasAirlinetheme(s:theme)
+ let g:airline_theme=s:theme
+endif
+
+" Tabline settings
+let g:airline#extensions#tabline#enabled = 1
+let g:airline#extensions#tabline#formatter = 'unique_tail_improved'
+
+" Show buffer number for easier switching between buffer,
+" see https://github.com/vim-airline/vim-airline/issues/1149
+let g:airline#extensions#tabline#buffer_nr_show = 1
+
+" Buffer number display format
+let g:airline#extensions#tabline#buffer_nr_format = '%s. '
+
+" Whether to show function or other tags on status line
+let g:airline#extensions#tagbar#enabled = 1
+let g:airline#extensions#vista#enabled = 1
+
+" Do not show search index in statusline since it is shown on command line
+let g:airline#extensions#anzu#enabled = 0
+
+" Skip empty sections if there are nothing to show,
+" extracted from https://vi.stackexchange.com/a/9637/15292
+let g:airline_skip_empty_sections = 1
+
+" Whether to use powerline symbols, see https://vi.stackexchange.com/q/3359/15292
+let g:airline_powerline_fonts = 0
+
+if !exists('g:airline_symbols')
+ let g:airline_symbols = {}
+endif
+let g:airline_symbols.branch = '⎇'
+let g:airline_symbols.paste = 'ρ'
+let g:airline_symbols.spell = 'Ꞩ'
+
+" Only show git hunks which are non-zero
+let g:airline#extensions#hunks#non_zero_only = 1
+
+" Speed up airline
+let g:airline_highlighting_cache = 1
+"}}
+
+"{{ Misc plugin setting
+""""""""""""""""""""""""""""vim-matchup settings"""""""""""""""""""""""""""""
+" Improve performance
+let g:matchup_matchparen_deferred = 1
+let g:matchup_matchparen_timeout = 100
+let g:matchup_matchparen_insert_timeout = 30
+
+" Enhanced matching with matchup plugin
+let g:matchup_override_vimtex = 1
+
+" Whether to enable matching inside comment or string
+let g:matchup_delim_noskips = 0
+
+" Show offscreen match pair in popup window
+let g:matchup_matchparen_offscreen = {'method': 'popup'}
+
+" Change highlight color of matching bracket for better visual effects
+augroup matchup_matchparen_highlight
+ autocmd!
+ autocmd ColorScheme * highlight MatchParen cterm=underline gui=underline
+augroup END
+
+" Show matching keyword as underlined text to reduce color clutter
+augroup matchup_matchword_highlight
+ autocmd!
+ autocmd ColorScheme * hi MatchWord cterm=underline gui=underline
+augroup END
+
+"""""""""""""""""""""""""" asyncrun.vim settings """"""""""""""""""""""""""
+" Automatically open quickfix window of 6 line tall after asyncrun starts
+let g:asyncrun_open = 6
+if g:is_win
+ " Command output encoding for Windows
+ let g:asyncrun_encs = 'gbk'
+endif
+
+""""""""""""""""""""""""""""""firenvim settings""""""""""""""""""""""""""""""
+if exists('g:started_by_firenvim') && g:started_by_firenvim
+ " general options
+ set laststatus=0 nonumber noruler noshowcmd
+
+ " general config for firenvim
+ let g:firenvim_config = {
+ \ 'globalSettings': {
+ \ 'alt': 'all',
+ \ },
+ \ 'localSettings': {
+ \ '.*': {
+ \ 'cmdline': 'neovim',
+ \ 'priority': 0,
+ \ 'selector': 'textarea',
+ \ 'takeover': 'never',
+ \ },
+ \ }
+ \ }
+
+ augroup firenvim
+ autocmd!
+ autocmd BufEnter *.txt setlocal filetype=markdown
+ augroup END
+endif
+
+""""""""""""""""""""""""""""""nvim-gdb settings""""""""""""""""""""""""""""""
+nnoremap <leader>dp :<C-U>GdbStartPDB python -m pdb %<CR>
+"}}
+"}
diff --git a/core/ui.vim b/core/ui.vim
new file mode 100644
index 0000000..4804bec
--- /dev/null
+++ b/core/ui.vim
@@ -0,0 +1,111 @@
+"{ UI-related settings
+"{{ General settings about colors
+" Enable true colors support. Do not set this option if your terminal does not
+" support true colors! For a comprehensive list of terminals supporting true
+" colors, see https://github.com/termstandard/colors and
+" https://gist.github.com/XVilka/8346728.
+if match($TERM, '^xterm.*') != -1 || exists('g:started_by_firenvim')
+ set termguicolors
+endif
+" Use dark background
+set background=dark
+"}}
+
+"{{ Colorscheme settings
+let s:my_theme_dict = {}
+
+function! s:my_theme_dict.gruvbox8() dict abort
+ " We should check if theme exists before using it, otherwise you will get
+ " error message when starting Nvim
+ if !utils#HasColorscheme('gruvbox8') | return | endif
+
+ " Italic options should be put before colorscheme setting,
+ " see https://github.com/morhetz/gruvbox/wiki/Terminal-specific#1-italics-is-disabled
+ let g:gruvbox_italics=1
+ let g:gruvbox_italicize_strings=1
+ let g:gruvbox_filetype_hi_groups = 0
+ let g:gruvbox_plugin_hi_groups = 0
+ colorscheme gruvbox8_hard
+endfunction
+
+function! s:my_theme_dict.srcery() dict abort
+ if !utils#HasColorscheme('srcery') | return | endif
+
+ colorscheme srcery
+endfunction
+
+function! s:my_theme_dict.deus() dict abort
+ if !utils#HasColorscheme('deus') | return | endif
+
+ colorscheme deus
+endfunction
+
+function! s:my_theme_dict.happy_hacking() dict abort
+ if !utils#HasColorscheme('happy_hacking') | return | endif
+
+ colorscheme happy_hacking
+endfunction
+
+function! s:my_theme_dict.solarized8() dict abort
+ if !utils#HasColorscheme('solarized8') | return | endif
+
+ let g:solarized_term_italics=1
+ let g:solarized_visibility='high'
+ colorscheme solarized8_high
+endfunction
+
+function! s:my_theme_dict.monokai() dict abort
+ if !utils#HasColorscheme('monokai') | return | endif
+ colorscheme monokai
+endfunction
+
+function! s:my_theme_dict.vim_one() dict abort
+ if !utils#HasColorscheme('one') | return | endif
+
+ let g:one_allow_italics = 1
+ colorscheme one
+endfunction
+
+function! s:my_theme_dict.material() dict abort
+ if !utils#HasColorscheme('material') | return | endif
+
+ let g:material_terminal_italics = 1
+ " theme_style can be 'default', 'dark' or 'palenight'
+ let g:material_theme_style = 'default'
+ colorscheme material
+endfunction
+
+function! s:my_theme_dict.onedark() dict abort
+ if !utils#HasColorscheme('onedark') | return | endif
+
+ let g:onedark_terminal_italics = 1
+ colorscheme onedark
+endfunction
+
+function! s:my_theme_dict.neodark() dict abort
+ if !utils#HasColorscheme('neodark') | return | endif
+
+ colorscheme neodark
+endfunction
+
+function! s:my_theme_dict.toast() dict abort
+ if !utils#HasColorscheme('toast') | return | endif
+
+ colorscheme toast
+endfunction
+
+let s:candidate_theme = ['gruvbox8', 'srcery', 'deus', 'happy_hacking', 'solarized8',
+ \ 'monokai', 'vim_one', 'material', 'onedark', 'neodark', 'toast']
+let s:idx = utils#RandInt(0, len(s:candidate_theme)-1)
+let s:theme = s:candidate_theme[s:idx]
+
+let s:colorscheme_func = printf('s:my_theme_dict.%s()', s:theme)
+if has_key(s:my_theme_dict, s:theme)
+ execute 'call ' . s:colorscheme_func
+else
+ echohl WarningMsg
+ echomsg 'Invalid colorscheme function: ' s:colorscheme_func ', using default instead.'
+ echohl None
+endif
+"}}
+"}
diff --git a/core/variables.vim b/core/variables.vim
new file mode 100644
index 0000000..9625609
--- /dev/null
+++ b/core/variables.vim
@@ -0,0 +1,56 @@
+"{ Global Variable
+
+"{{ Custom variables
+let g:is_win = has('win32') || has('win64')
+let g:is_linux = has('unix') && !has('macunix')
+let g:is_mac = has('macunix')
+"}}
+
+"{{ Builtin variables
+" Disable Python2 support
+let g:loaded_python_provider=0
+
+let g:did_install_default_menus = 1 " do not load menu
+
+" Path to Python 3 interpreter (must be an absolute path), make startup
+" faster. See https://neovim.io/doc/user/provider.html.
+if executable('python')
+ if g:is_win
+ let g:python3_host_prog=substitute(exepath('python'), '.exe$', '', 'g')
+ elseif g:is_linux || g:is_mac
+ let g:python3_host_prog=exepath('python')
+ endif
+else
+ echoerr 'Python 3 executable not found! You must install Python 3 and set its PATH correctly!'
+endif
+
+" Custom mapping <leader> (see `:h mapleader` for more info)
+let mapleader = ','
+"}}
+
+"{{ Disable loading certain plugins
+" Whether to load netrw by default, see
+" https://github.com/bling/dotvim/issues/4
+" let g:loaded_netrw = 0
+" let g:loaded_netrwPlugin = 0
+let g:netrw_liststyle = 3
+if g:is_win
+ let g:netrw_http_cmd = 'curl --ssl-no-revoke -Lo'
+endif
+
+" Do not load tohtml.vim
+let g:loaded_2html_plugin = 1
+
+" Do not load zipPlugin.vim, gzip.vim and tarPlugin.vim (all these plugins are
+" related to checking files inside compressed files)
+let g:loaded_zipPlugin = 1
+let loaded_gzip = 1
+let g:loaded_tarPlugin = 1
+
+let g:loaded_tutor_mode_plugin = 1 " do not load the tutor plugin
+
+" Do not use builtin matchit.vim and matchparen.vim since we use vim-matchup
+let g:loaded_matchit = 1
+let g:loaded_matchparen = 1
+"}}
+"}