-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathinit.vim
181 lines (152 loc) · 5.49 KB
/
init.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
" _ ____ __ _ _________ ___ _______ __ _________ ___ _______
" | | / / / / / / |/ / ___/ / / \ \/ / __/ |/ / / ___/ __ \/ _ \/ __/ _ \
" | |/ / /_/ / / / (_ / /_/ / \ / _// / / /__/ /_/ / // / _// , _/
" |___/\____/ /_/|_/\___/\____/ /_/___/_/|_/ \___/\____/____/___/_/|_|
" Vim customized by Vu Nguyen Coder
" (See my detailed tutorial here: https://youtu.be/Tp8i1EHsQ1Q )
"
" http://youtube.com/VuNguyenCoder
" http://facebook.com/VuNguyenCoder
lua print('Neovim started...')
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set mouse=a " Enable mouse
set expandtab " Tab setting
set tabstop=4 " Tab setting
set shiftwidth=4 " Tab setting
set listchars=tab:\¦\ " Tab charactor
set list
set foldmethod=syntax
set foldnestmax=1
set foldlevelstart=3 "
set number " Show line number
set ignorecase " Enable case-sensitive
" Disable backup
set nobackup
set nowb
set noswapfile
" Optimize
set synmaxcol=3000 "Prevent breaking syntax hightlight when string too long. Max = 3000"
set lazyredraw
au! BufNewFile,BufRead *.json set foldmethod=indent " Change foldmethod for specific filetype
syntax on
" Enable copying from vim to clipboard
if has('win32')
set clipboard=unnamed
else
set clipboard=unnamedplus
endif
" Auto reload content changed outside
au CursorHold,CursorHoldI * checktime
au FocusGained,BufEnter * :checktime
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI *
\ if mode() !~ '\v(c|r.?|!|t)' && getcmdwintype() == ''
\ | checktime
\ | endif
autocmd FileChangedShellPost *
\ echohl WarningMsg
\ | echo "File changed on disk. Buffer reloaded."
\ | echohl None
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Key mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Resize pane
nmap <M-Right> :vertical resize +1<CR>
nmap <M-Left> :vertical resize -1<CR>
nmap <M-Down> :resize +1<CR>
nmap <M-Up> :resize -1<CR>
" Search a hightlighted text
vnoremap // y/\V<C-R>=escape(@",'/\')<CR><CR>
nmap /\ :noh<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin list
" (used with Vim-plug - https://github.com/junegunn/vim-plug)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call plug#begin(stdpath('config').'/plugged')
" Theme
Plug 'joshdick/onedark.vim', " Dark theme
Plug 'akinsho/bufferline.nvim', { 'tag': '*' }
" File browser
Plug 'preservim/nerdTree' " File browser
Plug 'Xuyuanp/nerdtree-git-plugin' " Git status
Plug 'ryanoasis/vim-devicons' " Icon
Plug 'unkiwii/vim-nerdtree-sync' " Sync current file
Plug 'jcharum/vim-nerdtree-syntax-highlight',
\ {'branch': 'escape-keys'}
" File search
Plug 'junegunn/fzf',
\ { 'do': { -> fzf#install() } } " Fuzzy finder
Plug 'junegunn/fzf.vim'
" Status bar
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Terminal
Plug 'voldikss/vim-floaterm' " Float terminal
" Code intellisense
Plug 'neoclide/coc.nvim',
\ {'branch': 'release'} " Language server protocol (LSP)
Plug 'jiangmiao/auto-pairs' " Parenthesis auto
Plug 'mattn/emmet-vim'
Plug 'preservim/nerdcommenter' " Comment code
" Plug 'liuchengxu/vista.vim' " Function tag bar
Plug 'alvan/vim-closetag' " Auto close HTML/XML tag
\ {
\ 'do': 'yarn install '
\ .'--frozen-lockfile '
\ .'&& yarn build',
\ 'branch': 'main'
\ }
" Code syntax highlight
" Plug 'yuezk/vim-js' " Javascript
" Plug 'MaxMEllon/vim-jsx-pretty' " JSX/React
" Plug 'jackguo380/vim-lsp-cxx-highlight' " C/C++
" Plug 'uiiaoo/java-syntax.vim' " Java
Plug 'sheerun/vim-polyglot'
" Debugging
Plug 'puremourning/vimspector' " Vimspector
" Source code version control
Plug 'tpope/vim-fugitive' " Git infomation
Plug 'tpope/vim-rhubarb'
Plug 'airblade/vim-gitgutter' " Git show changes
Plug 'samoshkin/vim-mergetool' " Git merge
" Fold
Plug 'tmhedberg/SimpylFold'
call plug#end()
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugin Setting
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set theme
colorscheme onedark
set termguicolors
autocmd VimEnter * call s:setup_lualine()
function! s:setup_lualine() abort
lua<<EOF
require("bufferline").setup{
options = {
indicator = {
style = 'none',
},
diagnostics = "coc",
}
}
EOF
endfunction
" Overwrite some color highlight
if (has("autocmd"))
augroup colorextend
autocmd ColorScheme
\ * call onedark#extend_highlight("Comment",{"fg": {"gui": "#728083"}})
autocmd ColorScheme
\ * call onedark#extend_highlight("LineNr", {"fg": {"gui": "#728083"}})
augroup END
endif
" Disable automatic comment in newline
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
" Close buffer without exitting vim
nnoremap <silent> <leader>bd :bp \| sp \| bn \| bd<CR>
" Other setting
for setting_file in split(glob(stdpath('config').'/settings/*.vim'))
execute 'source' setting_file
endfor