let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin()
" The default plugin directory will be as follows:
" - Vim (Linux/macOS): '~/.vim/plugged'
" - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
" You can specify a custom plugin directory by passing it as the argument
" - e.g. `call plug#begin('~/.vim/plugged')`
" - Avoid using standard Vim directory names like 'plugin'
" vim-go
Plug 'fatih/vim-go'
Plug 'ctrlpvim/ctrlp.vim'
" split struct expression, key: gS, gJ"
Plug 'AndrewRadev/splitjoin.vim'
Plug 'SirVer/ultisnips'
" fugitive"
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'Xuyuanp/nerdtree-git-plugin'
" themes
Plug 'ayu-theme/ayu-vim'
Plug 'sainnhe/everforest'
" parenthesis"
Plug 'LunarWatcher/auto-pairs'
" nerdtree
Plug 'scrooloose/nerdtree'
" indentLine
Plug 'yggdroot/indentline'
call plug#end()
"****************************
"" Basic Setup
"****************************
"" Encoding
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
"" Fix backspace indent
set backspace=indent,eol,start
"" Tabs
set tabstop=4
set softtabstop=0
set shiftwidth=4
set expandtab
"" Map leader to ,
let mapleader=','
"" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
set autowrite
if exists('$SHELL')
set shell=$SHELL
else
set shell=/bin/sh
endif
"*******************************
"" Visual Settings
"*******************************
syntax on
set ruler
set number
set mouse=a
set mousemodel=popup
set t_Co=256
set updatetime=100
" IndentLine
let g:indentLine_enabled = 1
let g:indentLine_concealcursor = ''
let g:indentLine_char = '|'
let g:indentLine_faster = 1
"" Status bar
set laststatus=2
set title
set titleold="Terminal"
set titlestring=%F
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)
if exists("*fugitive#statusline")
set statusline+=%(fugitive#statusline()}
endif
"" NERDTree config
let g:NERDTreeChDirMode=1
nnoremap <silent> <F2> :NERDTreeFind<CR>
nnoremap <silent> <F3> :NERDTreeToggle<CR>
" 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
" Close the tab if NERDTree is the only window remaining in it.
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
"" terminal emulation
nnoremap <silent> <leader>sh :terminal<CR>
let g:NERDTreeGitStatusIndicatorMapCustom = {
\ 'Modified' :'✹',
\ 'Staged' :'✚',
\ 'Untracked' :'✭',
\ 'Renamed' :'➜',
\ 'Unmerged' :'═',
\ 'Deleted' :'✖',
\ 'Dirty' :'✗',
\ 'Ignored' :'☒',
\ 'Clean' :'✔︎',
\ 'Unknown' :'?',
\ }
"**********************************************
"" Mappings
"**********************************************
"
"" Split
noremap <leader>h :<C-u>split<CR>
noremap <leader>v :<C-u>vsplit<CR>
map <C-n> :cnext<CR>
map <C-m> :cprevious<CR>
nnoremap <leader>a :cclose<CR>
" vim-go
let g:go_list_type = "quickfix"
let g:go_fmt_command = "goimports"
let g:go_fmt_fail_silently = 1
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_operators = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_build_constraints = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_generate_tags = 1
let g:go_highlight_space_tab_error = 0
let g:go_highlight_array_whitespace_error = 0
let g:go_highlight_trailing_whitespace_error = 0
let g:go_highlight_extra_types = 1
let g:go_test_timeout = '10s'
" automatically show type info
let g:go_auto_type_info = 1
" exclude comments when using motion(ex: daf, vaf)
let g:go_textobj_include_function_doc = 0
let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck']
let g:go_metalinter_autosave = 1
let g:go_metalinter_autosave_enabled = ['vet', 'golint', 'errcheck']
let g:go_metalinter_deadline = "5s"
autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 softtabstop=4
autocmd FileType go nmap <leader>b <Plug>(go-build)
autocmd FileType go nmap <leader>r <Plug>(go-run)
autocmd FileType go nmap <leader>i <Plug>(go-info)
" to see options, :help completeopt
set completeopt-=preview
set completeopt+=menuone
set completeopt+=noinsert
set completeopt+=popup
au filetype go inoremap <buffer> . .<C-x><C-o>
" theme
if has('termguicolors')
set termguicolors
endif
set background=light
let g:everforest_background = 'medium'
let g:everforest_better_performance = 1
colorscheme everforest
"let ayucolor="light"
"colorscheme ayu
autocmd FileType go set list lcs=tab:\|\ "(last character is a space...)