aboutsummaryrefslogtreecommitdiff
path: root/nvim/.config/nvim/init.vim
blob: e82f1200f2d297a346811d39d6905443f58ba0da (plain)
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
""""""" Plugin management stuff """""""
set nocompatible
filetype off

set rtp+=~/.config/nvim/bundle/Vundle.vim
call vundle#begin('~/.config/nvim/bundle')

" Plugin manager
Plugin 'VundleVim/Vundle.vim'

" Custom plugins...
" EasyMotion - Allows <leader><leader>(b|e) to jump to (b)eginning or (end)
" of words.
"Plugin 'easymotion/vim-easymotion'
" Ctrl-P - Fuzzy file search
"Plugin 'kien/ctrlp.vim'
" Neomake build tool (mapped below to <c-b>)
"Plugin 'benekastah/neomake'

" Autocomplete for python
Plugin 'davidhalter/jedi-vim'
" Remove extraneous whitespace when edit mode is exited
"Plugin 'thirtythreeforty/lessspace.vim'

" Screen splitter.  Cool, but doesn't work with nvim.
"Plugin 'ervandew/screen'

" LaTeX editing
Plugin 'LaTeX-Box-Team/LaTeX-Box'

" Status bar mods
Plugin 'bling/vim-airline'
Plugin 'airblade/vim-gitgutter'

" Tab completion
Plugin 'ervandew/supertab'

" Syntax for openscad files
Plugin 'sirtaj/vim-openscad'

" NERDtree plugin
Plugin 'scrooloose/nerdtree'

" NERDTree git plugin
Plugin 'Xuyuanp/nerdtree-git-plugin'

" Global Auto Completion
Plugin 'ajh17/VimCompletesMe'

" PHP Auto Completion
Plugin 'shawncplus/phpcomplete.vim'

" Better syntax and highlighting
Plugin 'pangloss/vim-javascript'

" Syntax checker
"Plugin 'scrooloose/syntastic'

" Git command managament from nvim
"Plugin 'tpope/vim-fugitive'
Plugin 'lambdalisue/gina.vim'

" Git plugin of fugitive plugin for view log of git
Plugin 'gregsexton/gitv'

" View tree of the file historic
Plugin 'mbbill/undotree'

" Ack search tool
" Read more here : https://github.com/mileszs/ack.vim#can-i-use-ag-the-silver-searcher-with-this
Plugin 'mileszs/ack.vim'

" matchit
"Plugin 'isa/vim-matchit'

" Unicode completion
 Plugin 'chrisbra/unicode.vim'

" Colorize text for exemple #fff
Plugin 'chrisbra/Colorizer'

" html5 syntax
Plugin 'othree/html5.vim'

" Markdon hightlighting
"Plugin 'gabrielelana/vim-markdown'

" Autoformat
"Plugin 'Chiel92/vim-autoformat'

" Quicly form javascript, html and css tool
Plugin 'maksimr/vim-jsbeautify'

" reStructuredText syntax
Plugin 'marshallward/vim-restructuredtext'

" Java complete tool
Plugin 'artur-shaik/vim-javacomplete2'

" TypeScript syntac
Plugin 'leafgarland/typescript-vim'

" TypeScript IDE
Plugin 'Quramy/tsuquyomi'

" Linter for TypeScript
Plugin 'palantir/tslint'

"Plugin 'FredKSchott/CoVim'

" Collaborative vim tool
Plugin 'makerforceio/CoVim'

" Twig syntax for vim
Plugin 'lumiliet/vim-twig'

" Expanding abbreviations similar to emmet
Plugin 'mattn/emmet-vim'

" Scss syntax for vim
Plugin 'cakebaker/scss-syntax.vim'

" Silver searcher for vim
Plugin 'gabesoft/vim-ags'

" Tool for fix PHP coding standards issues
Plugin 'stephpy/vim-php-cs-fixer'

" French Correction tool
Plugin 'dpelle/vim-Grammalecte'

" Search file in folder
Plugin 'https://github.com/ctrlpvim/ctrlp.vim.git'

" Browse tags of the current file
Plugin 'majutsushi/tagbar'

" CakePHP vim support
Plugin 'ndreynolds/vim-cakephp'

" Auto convert rtf, rtfd, doc or wordml to plain text
Plugin 'vim-scripts/textutil.vim'

" Multiple cursors
Plugin 'terryma/vim-multiple-cursors'

" Syntax for TOML
Plugin 'cespare/vim-toml'

" Some icons for NerdTree or other
Plugin 'ryanoasis/vim-devicons'

" Vim linter
Plugin 'Kuniwak/vint'

" Plugin Asynchronous Lint Engine (linter)
" Check https://github.com/w0rp/ale#supported-languages for more info
Plugin 'w0rp/ale'

" After all plugins...
call vundle#end()
filetype plugin indent on

""""""" Jedi-VIM """""""
" Don't mess up undo history
"let g:jedi#show_call_signatures = "0"


""""""" SuperTab configuration """""""
"let g:SuperTabDefaultCompletionType = "<c-x><c-u>"
function! Completefunc(findstart, base)
    return "\<c-x>\<c-p>"
endfunction

"call SuperTabChain(Completefunc, '<c-n>')

"let g:SuperTabCompletionContexts = ['g:ContextText2']


""""""" General coding stuff """""""
" Highlight 80th column
set colorcolumn=80
" Always show status bar
set laststatus=2
" Let plugins show effects after 500ms, not 4s
set updatetime=500
" Disable mouse click to go to position
set mouse-=a
" Don't let autocomplete affect usual typing habits
set completeopt=menuone,preview,noinsert
" Let vim-gitgutter do its thing on large files
let g:gitgutter_max_signs=10000

" If your terminal's background is white (light theme), uncomment the following
" to make EasyMotion's cues much easier to read.
" hi link EasyMotionTarget String
" hi link EasyMotionShade Comment
" hi link EasyMotionTarget2First String
" hi link EasyMotionTarget2Second Statement


""""""" Python stuff """""""
syntax enable
set number showmatch
set shiftwidth=4 tabstop=4 softtabstop=4 expandtab autoindent
let python_highlight_all = 1
set list
set listchars=eol,tab:>·,trail:~,extends:>,precedes:<


""""""" Keybindings """""""
" Set up leaders
let mapleader=","
let maplocalleader="\\"

" Mac OS X option-left / right
noremap â b
noremap æ e
inoremap â <C-o>b
inoremap æ <C-o>e<right>
" Note - this required binding in preferences (Cmd-,) option+backspace to
" escape+z.
" Why this one is complicated - <C-o> at end of line moves cursor by one
" character, which means a trailing character could be left.
inoremap <expr> ú col('.')>1 ? 'T<Left><C-o>db<Delete>' : '<Backspace>T<Left><c-o>db<Delete>'
" Requires binding option+forward delete to escape
inoremap ø <C-o>dw

" Linux / windows ctrl+backspace ctrl+delete
" Note that ctrl+backspace doesn't work in Linux, so ctrl+\ is also available
imap <C-backspace> ú
imap <C-\> ú
imap <C-delete> ø

" Arrow keys up/down move visually up and down rather than by whole lines.  In
" other words, wrapped lines will take longer to scroll through, but better
" control in long bodies of text.
" NOTE - Disabled since <leader><leader>w|e|b works well with easymotion
"noremap <up> gk
"noremap <down> gj

" Neomake and other build commands (ctrl-b)
nnoremap <C-b> :w<cr>:Neomake<cr>

autocmd BufNewFile,BufRead *.tex,*.bib noremap <buffer> <C-b> :w<cr>:new<bar>r !make<cr>:setlocal buftype=nofile<cr>:setlocal bufhidden=hide<cr>:setlocal noswapfile<cr>
autocmd BufNewFile,BufRead *.tex,*.bib imap <buffer> <C-b> <Esc><C-b>

" NERDTree keybinding
map <C-b> :NERDTreeToggle<CR>
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif

" NERDTress File highlighting
function! NERDTreeHighlightFile(extension, fg, bg, guifg, guibg)
 exec 'autocmd filetype nerdtree highlight ' . a:extension .' ctermbg='. a:bg .' ctermfg='. a:fg .' guibg='. a:guibg .' guifg='. a:guifg
 exec 'autocmd filetype nerdtree syn match ' . a:extension .' #^\s\+.*'. a:extension .'$#'
endfunction

call NERDTreeHighlightFile('jade', 'green', 'none', 'green', '#151515')
call NERDTreeHighlightFile('ini', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('md', 'blue', 'none', '#3366FF', '#151515')
call NERDTreeHighlightFile('yml', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('config', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('conf', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('json', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('html', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('styl', 'cyan', 'none', 'cyan', '#151515')
call NERDTreeHighlightFile('css', 'cyan', 'none', 'cyan', '#151515')
call NERDTreeHighlightFile('coffee', 'Red', 'none', 'red', '#151515')
call NERDTreeHighlightFile('js', 'Red', 'none', '#ffa500', '#151515')
call NERDTreeHighlightFile('php', 'Magenta', 'none', '#ff00ff', '#151515')

" Autoformat conf
noremap <F3> :Autoformat<CR>
let g:autoformat_autoindent = 0
let g:autoformat_retab = 0
let g:autoformat_remove_trailing_spaces = 0

autocmd Filetype java set makeprg=javac\ %
set errorformat=%A%f:%l:\ %m,%-Z%p^,%-C%.%#
map <F9> :make<Return>:copen<Return>
map <F10> :cprevious<Return>
map <F11> :cnext<Return>

map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
    exec "w"
    if &filetype == 'c'
        exec "!gcc % -o %<"
        exec "!time ./%<"
    elseif &filetype == 'cpp'
        exec "!g++ % -o %<"
        exec "!time ./%<"
    elseif &filetype == 'java'
        exec "!time java -cp %:p:h %:t:r"
    elseif &filetype == 'sh'
        exec "!time bash %"
    elseif &filetype == 'python'
        exec "!time python2.7 %"
    elseif &filetype == 'html'
        exec "!firefox % &"
    elseif &filetype == 'go'
        exec "!go build %<"
        exec "!time go run %"
    elseif &filetype == 'mkd'
        exec "!~/.vim/markdown.pl % > %.html &"
        exec "!firefox %.html &"
    endif
endfunc

set textwidth=0 wrapmargin=5

let g:ags_agexe = 'ag'
let g:ags_enable_async = 1
let g:ags_results_per_tab = 0

"php-cs-fixer
let g:php_cs_fixer_rules = "@PSR2"

let g:php_cs_fixer_php_path = "php"               " Path to PHP
let g:php_cs_fixer_enable_default_mapping = 1     " Enable the mapping by default (<leader>pcd)
let g:php_cs_fixer_dry_run = 0                    " Call command with dry-run option
let g:php_cs_fixer_verbose = 0                    " Return the output of command if 1, else an inline information.

let g:grammalecte_cli_py='/usr/share/grammalecte-fr/cli.py'

nmap <F8> :TagbarToggle<CR>

" Controller -> Component
map <leader>t yiw<cr>:tag /^<C-R>"<CR>
" View -> Helper
map <leader>h yiw<cr>:tag /^<C-R>"Helper<CR>



let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'

set encoding=UTF-8

nnoremap <C-c> :UndotreeToggle<cr>

:let g:colorizer_auto_filetype='css,html'