summaryrefslogtreecommitdiff
path: root/plugin/perso.vim
blob: 198175785eed1bbaf590f8b37ea6e1fe39cdb2f0 (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
set showcmd

set backspace=indent,eol,start

" Why the hell does Vim add \n add the end of a file ?
set nofixendofline


set clipboard=unnamedplus
set ruler
set t_Co=256
"map <leader>j <C-W>j
"map <leader>k <C-W>k
"map <leader>h <C-W>h
"map <leader>l <C-W>l

inoremap <C-N> <C-P>
inoremap <C-P> <C-N>

let mapleader = "!" " map leader to bang

nnoremap <leader>f :call FoldColumnToggle()<cr>

function! FoldColumnToggle()
    try
      if g:colors_name ==? "pink"
        colo badwolf
        hi CursorLine term=bold cterm=bold ctermbg=black
        hi CursorColumn ctermbg=54
      elseif g:colors_name ==? "badwolf"
        colo jellybeans
      else
        colo pink
        hi CursorLine term=bold cterm=bold ctermbg=white
        hi CursorColumn ctermbg=Yellow
      endif
    catch /^Vim:E121/
      colo pink
      hi CursorLine term=bold cterm=bold ctermbg=white
      hi CursorColumn ctermbg=Yellow
    endtry
endfunction

filetype plugin indent on

" Color :
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=darkred guibg=darkred

colo badwolf
hi CursorLine term=bold cterm=bold ctermbg=black
hi CursorColumn ctermbg=54
set cursorline


match ExtraWhitespace /\s\+$/

" Completion related options
" wildcard char = <TAB>
set wildmenu
set wildmode=list:longest:full

nnoremap <silent><A-o> :set paste<CR>m`o<Esc>``:set nopaste<CR>
nnoremap <silent><A-O> :set paste<CR>m`O<Esc>``:set nopaste<CR>

inoremap <c-e> <Esc>A
inoremap <c-a> <Esc>0i

"Perso C définition"
inoremap prt printf
inoremap swf printf
inoremap #in< #include <><left>
inoremap #in" #include ""<left>
inoremap #def #define 
inoremap #un #undef
inoremap #ifn #ifndef 
inoremap #ifd #ifdef 
inoremap #std #include <stdlib.h>
inoremap #io  #include <stdio.h>

inoremap #main int main(void) {<CR>}<Esc><Up>A
inoremap ##main int main(int argc, char* argv[]) {<CR>}<Esc><Up>A

" Personal shortcurts

ca tn tabnew
ca tc tabc

map <F5> :setlocal spell! spelllang=fr<CR>
map <F6> :setlocal spell! spelllang=en_us<CR>
inoremap <F7> <C-r>=strftime('%F')<CR>
inoremap <F8> <C-r>=strftime('%c')<CR>


" Personal compil shortcurts
noremap <Space><F9>  :make<CR>:cw<CR><CR>:!./a.out<CR>
map <F9> :make<CR>:cw<CR><CR>
noremap <silent> [q :copen<CR>
noremap <silent> ]q :cclose<CR>
noremap <silent> [Q :cfirst<CR>
noremap <silent> ]Q :clast<CR>
noremap <silent> [[ :cprev<CR>
noremap <silent> ]] :cnext<CR>




"Allow vim clipboad <-> host clipboard to share data
set clipboard=unnamedplus

" Quick Comment :
autocmd FileType c,cpp,java,go,scala,js   let b:comment_leader = '//'
autocmd FileType sh,ruby,python           let b:comment_leader = '#'
autocmd FileType conf,fstab               let b:comment_leader = '#'
autocmd FileType tex                      let b:comment_leader = '%'
autocmd FileType mail                     let b:comment_leader = '>'
autocmd FileType vim                      let b:comment_leader = '"'
autocmd FileType haskell                  let b:comment_leader = '--'

autocmd FileType c,cpp,java,go,scala  set foldmethod=syntax


noremap <silent> ,cc :<C-B>silent <C-E>s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:nohlsearch<CR>
noremap <silent> ,cu :<C-B>silent <C-E>s/^\V<C-R>=escape(b:comment_leader,'\/')<CR>//e<CR>:nohlsearch<CR>


noremap <silent> <c-c><c-c>  :<C-B>silent <C-E>s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:nohlsearch<CR>
noremap <silent> <c-c>c      :<C-B>silent <C-E>s/^\V<C-R>=escape(b:comment_leader,'\/')<CR>//e<CR>:nohlsearch<CR>

nnoremap cd :cd %:p:h<CR>
nnoremap <silent> // :nohls<CR>




" Compil option
autocmd Filetype c call SetCCompiler()
function SetCCompiler()
    if !(filereadable("makefile") || filereadable("Makefile"))
      set makeprg=gcc\ %
    endif
endfunction

autocmd Filetype python call SetPythonCompiler()
function SetPythonCompiler()
    if executable("flake8")
      set makeprg=flake8\ --ignore=E111,E303,E201,E231,E391,E225,E203,E226,W391\ %
      set textwidth=2000
    endif
endfunction




noremap <silent> zv :!markdown % \| w3m -I utf-8 -T text/html






set colorcolumn=80
set cursorcolumn
set hls
set incsearch

let $VIMHOME=expand('<sfile>:p:h:h')
au BufNewFile *.c 0r $VIMHOME/template/skel.c


" let g:deoplete#enable_at_startup = 1
" imap <C-k>     <Plug>(neosnippet_expand_or_jump)
" smap <C-k>     <Plug>(neosnippet_expand_or_jump)
" xmap <C-k>     <Plug>(neosnippet_expand_target)
" set completeopt-=preview

" call deoplete#custom#option('auto_complete', v:false)
" Plugin key-mappings.
" Note: It must be "imap" and "smap".  It uses <Plug> mappings.
" imap <C-k>     <Plug>(neosnippet_expand_or_jump)
" smap <C-k>     <Plug>(neosnippet_expand_or_jump)
" xmap <C-k>     <Plug>(neosnippet_expand_target)

" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap".  It uses <Plug> mappings.
"imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \    "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
"smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
"\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"

" For conceal markers.

if has('conceal')
   set conceallevel=2 concealcursor=niv
 endif

map <C-l> :exec &conceallevel ? "set conceallevel=0" : "set conceallevel=2"<CR>

" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)

" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)


noremap <silent> =g :GrammalecteCheck<CR>
noremap <silent> =G :GrammalecteClear<CR>

let b:ale_linters = { 'javascript': ['eslint', 'xo', 'jscs', 'jshint', 'standard'], 'typescript': ['eslint', 'tsserver', 'deno'] }

let g:ale_disable_lsp = 1
" Ale message config :
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'

" Ale only on save
let g:ale_lint_on_text_changed = 'never'
let g:ale_lint_on_enter = 0

autocmd BufNewFile,BufRead /tmp/mesms_* set noautoindent filetype=mail wm=0 tw=78 nonumber digraph nolist nopaste

map <Esc>at :ALEToggle<CR>

set omnifunc=syntaxcomplete#Complete

au BufReadPost,BufNewFile *.tmpl,*.tpm,*.svelte set filetype=html