summaryrefslogtreecommitdiff
path: root/plugin/perso.vim
blob: 75ab21360aac0109b4296866a430b820a6a8c2f7 (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
" Define the leader key, which is used to create a lot of shortcurts
let mapleader = "!" " map leader to bang

" I think it's the little help in the right bottom line
" It shows the current state of the command like "3y" for "3yy"
set showcmd

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

" Show progress of the file (percentage and nunber of line)
set ruler

" Turns on file detection, plugin and indentation
filetype plugin indent on

" Used to move tabs
nmap <C-S-PageUp>   :tabmove -1<cr>
nmap <C-S-PageDown> :tabmove +1<cr>


" Function to quickly change color scheme
nnoremap <leader>c :call ChangeColor()<cr>
let g:colors_name = 'badwolf'
function! ChangeColor()
    try
      if g:colors_name ==? "moonlight"
        colo badwolf
        "hi CursorLine term=bold cterm=bold ctermbg=black
        "hi CursorColumn ctermbg=54
        "hi CursorLine term=bold cterm=bold ctermbg=black
        "hi CursorColumn ctermbg=54
      elseif g:colors_name ==? "badwolf"
        colo jellybeans
      elseif g:colors_name ==? "jellybeans"
        colo moonlight
      else
        colo moonlight
        hi CursorLine term=bold cterm=bold ctermbg=white
        hi CursorColumn ctermbg=Yellow
      endif
    catch /^Vim:E121/
      colo moonlight
      hi CursorLine term=bold cterm=bold ctermbg=white
      hi CursorColumn ctermbg=Yellow
    endtry
endfunction

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

" Hexokinase
" A plugin to color the colorname in the source code by the actual color it's for.
let g:Hexokinase_highlighters = ['background', 'virtual']
set termguicolors " To activate maximum of colors ? Don't know

" Show a line horizontal line on the cursor
set cursorline

" Put a colored column on the 120th characers
set colorcolumn=120
set cursorcolumn

" Activate highlight search.
set hls
set incsearch " Don't remenber

" Set the color of trailing white space in red ! ⛔
match ExtraWhitespace /\s\+$/


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

" Emacs style go to Origin/End in insert mode
inoremap <c-e> <Esc>A
inoremap <c-a> <Esc>0i

" Set usefull shortcurts for command
ca tn tabnew
ca tc tabc

" Grammatical verification
map <F5> :setlocal spell! spelllang=fr<CR>
map <F6> :setlocal spell! spelllang=en_us<CR>

" Quick past the date
inoremap <F7> <C-r>=strftime('%F')<CR>
inoremap <F8> <C-r>=strftime('%c')<CR>


" Personal compil shortcurts
" I'm not sure there are very used
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
" Very much used.
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 = '--'

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


" Fold method based on syntax. For Python, there is a plugin for that.
autocmd FileType c,cpp,java,go,scala,js,rust  set foldmethod=syntax

" Completion baed on language ? I don't know.
set omnifunc=syntaxcomplete#Complete

" Change directory
nnoremap cd :cd %:p:h<CR>
" Type "//" to disable highlight search.
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


" 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.

" Conceal is an option to hide irrelevant characters.
" Maybe disabled
if has('conceal')
   set conceallevel=2 concealcursor=niv
 endif
" C-L to actually toggle conceal feature.
map <C-l> :exec &conceallevel ? "set conceallevel=0" : "set conceallevel=2"<CR>

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

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



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

" LSP is used by nvim
let g:ale_disable_lsp = 1

" ale message config :
let g:ale_echo_msg_error_str = '⛔'
let g:ale_echo_msg_warning_str = '⚠️'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'

" Ale only on save, otherwise, it's called too much and have to many false potitive
let g:ale_lint_on_text_changed = 'never'
let g:ale_lint_on_enter = 0

" nvim.tree.lua
map <C-C>x :NvimTreeToggle<CR>
map <C-C>c :NvimTreeFindFile<CR>


" let g:vimspector_enable_mappings = 'HUMAN'
" nmap <leader>dd :call vimspector#Launch()<CR>
" nmap <leader>dx :VimspectorReset<CR>
" nmap <leader>dr :VimspectorReset<CR>
" nmap <leader>de :VimspectorEval
" nmap <leader>dw :VimspectorWatch
" nmap <leader>do :VimspectorShowOutputlet g:vimspector_install_gadgets = [ 'debugpy', 'delve', 'CodeLLDB' ]
" nmap <Leader>dt :call vimspector#ToggleBreakpoint()<CR>
" nmap <Leader>dT :call vimspector#ClearBreakpoints()<CR>
" 
" nmap <Leader>dp :call vimspector#Pause()<CR>
" nmap <Leader>ds :call vimspector#Stop()<CR>
" nmap <Leader>dac :call vimspector#Continue()<CR>
" nmap <Leader>dar :call vimspector#Restart()<CR>
" nmap <Leader>dag :call vimspector#GoToCurrentLine()<CR>
" nmap <Leader>dao :call vimspector#StepOver()<CR>
" nmap <Leader>da> :call vimspector#StepInto()<CR>
" nmap <Leader>da< :call vimspector#StepOut()<CR>
" nmap <Leader>dap :call vimspector#UpFrame()<CR>
" nmap <Leader>dan :call vimspector#DownFrame()<CR>


let g:python3_host_prog = '/usr/bin/python3'

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

" To disable ALE
map <Esc>at :ALEToggle<CR>
" To move between ALE message (usually errors)
map <leader>> :ALENext<CR>
map <leader>< :ALEPrevious<CR>

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

command! -bang -nargs=* Rg
  \ call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case ".shellescape(<q-args>), 1,
  \   fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}), <bang>0)

" Congure Grammalecte
let g:grammalecte_cli_py='/usr/bin/grammalecte-cli'
function! GrammalecteToggle()
    try
      if exists("g:grammalecte_state") && g:grammalecte_state ==? "on"
        GrammalecteClear
        let g:grammalecte_state = "off"
      else
        let g:grammalecte_state = "on"
        GrammalecteCheck
      endif
    endtry
endfunction


" Congure CopIlot
function! CopilotToggle()
    try
      if exists("g:copilot_enabled_toggle") && g:copilot_enabled_toggle ==? "on"
        Copilot disable
        let g:copilot_enabled_toggle = "off"
      else
        if exists("g:copilot_enabled_toggle")
          Copilot enable
        else
          :packadd copilot.vim
        endif
        let g:copilot_enabled_toggle = "on"
      endif
    endtry
endfunction


" Congure Tabby
function! TabbyToggle()
    try
      if exists("g:tabby_enabled_toggle") && g:tabby_enabled_toggle ==? "on"
        let g:tabby_enabled_toggle = v:false
        let g:tabby_trigger_mode = 'manual'
      else
        if !exists("g:tabby_enabled_toggle")
          :packadd vim-tabby
        endif
        let g:tabby_trigger_mode = 'auto'
      endif
    endtry
endfunction
let g:tabby_trigger_mode = 'manual'

" Configure git blame
nnoremap <leader>b     :ToggleBlame virtual<cr>

" External program call
nnoremap <leader>x     :call TabbyToggle()<cr>
nnoremap <leader><m-x> :call CopilotToggle()<cr>
nnoremap <leader><F5>  :call GrammalecteToggle()<cr>
noremap  <silent> =g   :GrammalecteCheck<CR>
noremap  <silent> =G   :GrammalecteClear<CR>

" Call ripgrep
" To find the current word in the working directory
nnoremap <silent> <Leader>rg :Rg <C-R><C-W><CR>
" To find a file in the current working directory
nnoremap <silent> <Leader>/ :Files<CR>