-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
executable file
·247 lines (213 loc) · 8.07 KB
/
.vimrc
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
set nocompatible " use vim and do not behave like vi
filetype off " Deactivate filetype plugin temporarily
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
" Plugins
call vundle#begin()
Plugin 'VundleVim/Vundle.vim' " let Vundle manage Vundle, required
" Themes
Plugin 'joshdick/onedark.vim'
Plugin 'morhetz/gruvbox'
" Tools integration
Plugin 'tpope/vim-fugitive' " Git status integration
Plugin 'scrooloose/nerdtree' " NERDTree to display project's files tree
" Syntax checking
Plugin 'scrooloose/syntastic'
Plugin 'w0rp/ale'
" UI
Plugin 'vim-airline/vim-airline' " Airline
Plugin 'enricobacis/vim-airline-clock' " Date and time in vim airline
Plugin 'tmux-plugins/vim-tmux-focus-events' " Autoreload
" Language specific
Plugin 'mattn/emmet-vim' " HTML snippets
Plugin 'mxw/vim-jsx' " JSX syntax highlighting
Plugin 'lumiliet/vim-twig' " Twig syntax highlighting
Plugin 'posva/vim-vue' " VueJS
Plugin 'leafgarland/typescript-vim' " Typescript
" Fuzzy finder
Plugin 'junegunn/fzf'
Plugin 'junegunn/fzf.vim'
" ack, ag, grep, ...
Plugin 'mileszs/ack.vim'
" Org-Mode
Plugin 'jceb/vim-orgmode'
" Editor configuration sharing
Plugin 'editorconfig/editorconfig-vim'
" Dev Icons (must be the very last loaded plugin)
Plugin 'ryanoasis/vim-devicons'
" Ansible plugin (also improves yaml support)
Plugin 'pearofducks/ansible-vim'
" Refactoring extension
Plugin 'tpope/vim-abolish'
call vundle#end()
filetype plugin indent on " Enable filetype plugin again
syntax on " Enable syntax highlighting
set laststatus=2 " Always show the statusline
set encoding=utf-8
set number " Display line number
set ts=4 sts=4 sw=4 expandtab " tab = 4 spaces for every file type
" tab = 2 spaces for web programming languages, JSON, YAML and Markdown
autocmd Filetype c,cpp,css,hcl,html,htmldjango.twig,html.twig,javascript,json,nomad,php,pug,scss,tf,twig,ruby,yaml,vim,xml,puml,mmd set ts=2 sts=2 sw=2 expandtab
" use tab for some other file types
autocmd Filetype Makefile,go set noexpandtab
" Display whitespaces with specific characters
set listchars=eol:¬,tab:>·,trail:~,extends:>,precedes:<
set list " Display white space characters
set mouse=a " Enable mouse use (yeah it's bad)
set cursorline " Highlight cursor's current line
set splitbelow
set splitright
set pastetoggle=<F2>
colorscheme gruvbox
set background=dark
" https://swordandsignals.com/2020/12/13/5-lines-in-vimrc.html
set hlsearch " highlight all search results
" set ignorecase " do case insensitive search
set incsearch " show incremental search results as you type
" set number " display line number
" set noswapfile " disable swap file
" Gruvbox
let g:gruvbox_contrast_dark = 'hard'
" Buffer navigation
nnoremap <silent> <F8> :bn<CR>
nnoremap <silent> <F7> :bp<CR>
" NERDTree
nnoremap <C-n> :NERDTreeToggle<CR>
let NERDTreeShowHidden=1
" Ctags
:command MakeTags !ctags -R --exclude=.git --exclude=node_modules --exclude=vendor --exclude=composer.json --exclude=package.json --exclude=package-lock.json --exclude=symfony.lock --exclude=composer.lock .
" Buffers
:command BufOnly %bd|e#<CR>
" Window sizing
:command WLarger vertical resize +10
:command WThinner vertical resize-10
:command WHigher resize +10
:command WShorter resize +10
" emmet-vim (HTML snippets)
let g:user_emmet_install_global = 0
let g:user_emmet_settings = {
\ 'javascript.jsx' : {
\ 'extends' : 'jsx',
\ },
\}
autocmd FileType html,css,js,javascript.jsx,twig,php,markdown,html.twig,htmldjango.twig,htmldjango,xml,vue EmmetInstall
" Code formatters
autocmd Filetype sh set equalprg=shfmt\ -i\ 4
autocmd Filetype python set equalprg=yapf
autocmd Filetype javascript,javascript.jsx set equalprg=prettier\ --parser=babylon
autocmd Filetype json set equalprg=prettier\ --parser=json
autocmd Filetype css,scss,less set equalprg=prettier\ --parser=css
autocmd Filetype yaml set equalprg=prettier\ --parser=yaml
autocmd Filetype markdown set equalprg=tidy-markdown
autocmd Filetype c,cpp set equalprg=clang-format\ --style=Google
autocmd Filetype html set equalprg=html-beautify\ --indent-size=2\ --no-preserve-newlines\ -
autocmd Filetype xml set equalprg=xmllint\ --format\ -
" Syntax checking
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_mode_map = { 'mode': 'passive',
\ 'active_filetypes': [''],
\ 'passive_filetypes': ['*'] }
" let g:syntastic_check_on_open = 0
" let g:syntastic_check_on_wq = 0
let g:syntastic_rst_checkers = ['sphinx']
" Syntax Higlighting for odd files extensions
" autocmd BufNewFile,BufRead *.twig set syntax=htmldjango.twig
autocmd BufRead,BufNewFile *.vue set syntax=html
" File search
set path+=**
set wildmenu
" Autoreload
" set autoread
au FocusGained,BufEnter * :checktime " https://vi.stackexchange.com/questions/444/how-do-i-reload-the-current-file/13092#13092
set backupcopy=yes
" Airline
" let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ''
let g:airline#extensions#tabline#enabled = 1 " Enable the list of buffers
let g:airline#extensions#tabline#fnamemod = ':t' " Show just the filename
let g:airline_theme = 'gruvbox' " Sets the airline theme
" Airline clock
let g:airline#extensions#clock#format = '%a %d %B %H:%M:%S'
let g:airline#extensions#clock#updatetime = 1000 " Update the clock every second
" FZF
nnoremap <C-p> :FZF<CR>
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
" ack.vim
let g:ackprg = 'ag --nogroup --nocolor --column'
nnoremap <C-g> :Ag<CR>
" ALE
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
" Pattern search hilighting
nnoremap <silent> <C-L> :nohlsearch<CR><C-L>
" EditorConfig
" Ensure EditorConfig plugin works well with vim-fugitive plugin and
" avoid loading EditorConfig for any remote files over ssh
let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*']
" Find duplicates
:command FindDuplicates syn clear Repeat | g/^\(.*\)\n\ze\%(.*\n\)*\1$/exe 'syn match Repeat "^' . escape(getline('.'), '".\^$*[]') . '$"' | nohlsearch
" Copy file content to clipboard
:command CopyFileContent normal ggVG"+y''
" Format file content
:command FixFile normal gg=G''
" nnoremap <silent> <C-L> :FixFile<CR>
" Format log stacktrace
:command UntanglePyStacktrace %s/ File "/\r File "/g | :%s/#012/\r/g
" HexEditor Mode
:command HexEditorMode %!xxd
" Make shortcuts
" nnoremap <silent> <M-b> :make<CR>
" Secure gopass files
au BufNewFile,BufRead /dev/shm/gopass.* setlocal noswapfile nobackup noundofile
" Fixing Vim's Background Color Erase for 256-color tmux and GNU screen
" (https://sunaku.github.io/vim-256color-bce.html)
set t_ut=
" Nasty GUI hacks
set guifont=InputMono\ Nerd\ Font\ Mono\ 12
if has("gui_running")
if has("gui_gtk2") || has("gui_gtk3") || has("nvim")
set guifont=InputMono\ Nerd\ Font\ Mono\ 12
elseif has("gui_photon")
set guifont=Courier\ New:s11
elseif has("gui_kde")
set guifont=Courier\ New/11/-1/5/50/0/0/0/1/0
elseif has("x11")
set guifont=-*-courier-medium-r-normal-*-*-180-*-*-m-*-*
else
set guifont=Courier_New:h11:cDEFAULT
endif
set guioptions-=m "remove menu bar
set guioptions-=T "remove toolbar
set guioptions-=r "remove right-hand scroll bar
set guioptions-=L "remove left-hand scroll bar
endif
" urxvt transparency hack
if $TERM == "rxvt-unicode-256color"
hi Normal ctermbg=NONE
endif