This repository was archived by the owner on Mar 25, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.vim
More file actions
299 lines (234 loc) · 10 KB
/
init.vim
File metadata and controls
299 lines (234 loc) · 10 KB
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
set encoding=utf-8
scriptencoding utf8
" Leader key is ','
let mapleader=','
:lua << HEREDOC
-- bootstrap lazy.nvim if not available
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
-- load all plugins and configuration: see lua/packages.lua
require('lazy').setup(
require('packages').plugins,
{performance={rtp={reset=false}}}
)
HEREDOC
" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set background=dark
" Vim options
set hlsearch " highlight search result
set ignorecase " ignore case
set incsearch " incremental search
set number " print line numbers
set shiftwidth=2 " TAB equals 2 spaces
set tabstop=2 " ...probably the same thing
set expandtab " use spaces, not tabs
set autoindent " auto-indentation
set textwidth=80 " default text width: 80 chars
set colorcolumn=+1,+2,+3 " light up the 80-th column
hi ColorColumn ctermbg=lightgrey guibg=lightgrey
set wrap " Wrap if the line extends...
set shortmess=Aat " short messages: do not prompt warning message if
" the file is already opened, and truncate "open
" file" messages
set autoread " re-read the file if it is modified externally
" set foldcolumn=1 " colonne de gauche pour indiquer les zones
" \"foldables\"
set scrolloff=3 " toujours afficher au moins 3 lignes au dessus et
" en dessous du curseur
set modeline " autoriser les modlines
set foldmethod=indent " Folding base sur l'indentation
set foldlevelstart=100 " deplier tous les folds jusqu'au nv. 100
set diffopt+=iwhite " en mode 'diff', ignorer les espaces
set nojoinspaces " don't add extra whitespace when formatting
set switchbuf=uselast " when opening quickfix item, use the last buffer
" visual autocomplete for command menu
set wildmenu
set wildignore=*/.git/*,*.o,*.obj,*.lib,*.a,*.pyc,*/__pycache__/*
"
" Height of the preview window (24=twice default size)
set previewheight=24
" Default copy/paste from system clipboard
set clipboard=unnamed,unnamedplus
" Enable French and English spelling languages by default
set spelllang=en_us,fr
" Have a gui-like rendering even in terminal
set termguicolors
" always have a status line for each window
set laststatus=2
" set colorscheme once in this variable, and use it for all plugins that require
" it
" let s:colorscheme = 'everforest'
" let s:colorscheme = 'gruvbox'
let s:colorscheme = 'tokyonight'
execute("colorscheme " . s:colorscheme)
" Show tabs, trailing and non-breakable spaces
set list
set listchars=tab:>\ ,trail:-,nbsp:·
" set exrc, so that .exrc files are automatically sourced (see :help exrc)
set exrc
" indent wrapped text when needed
set breakindent
set breakindentopt=list:-1 " pay attention to list prefixes
if has('win32')
" Windows dark magic to make the backspace key work properly...
set backspace=2
set noshellslash
set shell=cmd.exe
endif
"###############################################################################
" SOURCE LOCAL VIMRC FILE COMPLEMENT
"###############################################################################
" this file is not versioned, and is local to the machine
let s:local_vimrc = expand('<sfile>:p:h') . '/localrc.vim'
if filereadable(s:local_vimrc)
execute("source " . s:local_vimrc)
endif
"###############################################################################
" SOURCE LUA FILE
"###############################################################################
let s:init_lua = expand('<sfile>:p:h') . '/lua/init.lua'
execute("luafile " . s:init_lua)
"###############################################################################
" MAPPINGS AND COMMANDS
"###############################################################################
" Move across visual lines inside wrapped long lines
nnoremap k gk
nnoremap j gj
" map 'jj' to escape insert mode
inoremap jj <Esc>
" Build a Ctags file
command! MkTags call utils#MkTags()
" Switch to markdown mode: no 80 chars, linebreak
command! Markdown set ft=markdown tw=0 linebreak
" Change to the directory of the current file
command! Cd cd\ %:p:h
" Toggle auto-format option with <Leader>fo
noremap <Leader>fo <Cmd>call utils#ToggleAutoFormat()<CR>
" Window navigation: map <Alt-[hjkl]> to 'move around' instructions, in normal
" and insertion mode. Also handle the case of terminal emulators that convert
" keystroke <A-l> into l for some reason...
for s:key in ['h', 'j', 'k', 'l']
execute('nnoremap <A-' . s:key . '> :wincmd ' . s:key . '<CR>')
execute('inoremap <A-' . s:key . '> '
\ . '<Esc>:wincmd ' . s:key . '<CR>a')
endfor
" Quickly edit vimrc
nmap <F8> <Cmd>e ~/.vim/init.vim<CR>
" Search for visually selected text
vnoremap // y/<C-R>"<CR>
" Align what remains of the line to the right, according to textwidth. Mapped to
" command :AlignRight, and to <A-Right>
command! AlignRight call utils#AlignRightFrom(getline('.'), getpos('.')[2] - 1,
\ &textwidth)
inoremap <A-Right> <Cmd>AlignRight<CR>
" clear all buffers but the one active
command! ClearBufs call utils#DeleteAllBuffersButCurrent()
" terminal configuration -------------------------------------------------------
if has('win32')
" shorthand command to spawn a terminal with my zsh shell - need to define a
" msys2.cmd command somewhere in the PATH that does what's necessary
command! Terminal execute('terminal msys2')
endif
"###############################################################################
" AUTO-COMMANDS AND FILETYPE-SPECIFIC STUFF
"###############################################################################
augroup vimrc
autocmd!
" file type personal preferences
autocmd FileType markdown setlocal spell
autocmd FileType rst setlocal spell
autocmd FileType vim setlocal tabstop=4 shiftwidth=4
autocmd FileType dashboard setlocal colorcolumn=
autocmd FileType dashboard DisableWhitespace
" auto-resize all windows when GUI or term is resized
autocmd VimResized * wincmd =
" disable trailing whitespaces highlighting in terminal windows
autocmd TermOpen * DisableWhitespace
" enter insertion mode immediately when opening/focusing the terminal
autocmd BufWinEnter,WinEnter term://* startinsert
augroup END
"###############################################################################
" PLUGINS CONFIGURATION
"###############################################################################
" PlantUML #####################################################################
let g:plantuml_executable_script='plantuml -o out/'
" Better Wihtespaces ###########################################################
hi ExtraWhitespace guibg=red ctermbg=red
" Strip trailing whitespaces
nmap <F10> <Cmd>StripWhitespace<CR>
" auto-strip trailing whitespaces on save
let g:strip_whitespace_on_save = 0
let g:strip_whitespace_confirm = 0
" python-syntax ################################################################
" enable Python highlighting plugin
let g:python_highlight_all = 1
" EasyAlign ####################################################################
" 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)
" custom delimiters
let g:easy_align_delimiters = {
\ '\': { 'pattern': '\\' }
\ }
" surround #####################################################################
" use 's' instead of 'S' for surrounding in visual mode (undocumented <Plug>
" stuff: just read the source code)
xmap s <Plug>VSurround
" ALE ##########################################################################
set omnifunc=ale#completion#OmniFunc
let g:ale_c_parse_compile_commands = 1
let g:ale_completion_enabled = 1
let g:ale_c_build_dir_names = ['out/Debug']
let g:ale_linters = {
\ 'cpp' : ['g++'],
\ 'c' : ['gcc'],
\ 'sh': ['shellcheck'],
\ 'haskell': ['hls', 'ghc'],
\ 'python': [],
\ 'rust': [],
\ }
" vim-asterios #################################################################
if has('unix')
let s:core_sdk = expand('~/.local/share/psyko-9.5.1')
let g:ast_psyko_path = s:core_sdk . '/bin/psyko'
let g:ast_kernel_dir = s:core_sdk . '/k2'
let g:ale_json_vscode_ls = expand('/usr/bin/vscode-json-languageserver')
elseif has('win32')
let s:ks_root = expand("$KRONOSAFE_INSTALL_DIR")
let g:ast_psyko_path = s:ks_root . '\psyko-9.5.0\bin\psyko.exe'
let g:ast_kernel_dir = s:ks_root . '\ksim-9.5.0'
endif
" WebDevIcons and NERDTree coloring stuff
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols = {
\ 'psy': 'Ψ',
\ 'bgt': '祥',
\ }
" LSP servers ##################################################################
:lua << EOF
EOF
" pretty signs
" sign define DiagnosticSignError text=🔴 texthl=DiagnosticSignError linehl= numhl=
" sign define DiagnosticSignWarn text=⚠ texthl=DiagnosticSignWarn linehl= numhl=
" sign define DiagnosticSignInfo text=ℹ texthl=DiagnosticSignInfo linehl= numhl=
" sign define DiagnosticSignHint text=👉 texthl=DiagnosticSignHint linehl= numhl=
" vim-vsnip ####################################################################
" the base snippet dir is set in init.lua: go see ther
imap <expr> <Tab> vsnip#available(1) ? '<Plug>(vsnip-expand-or-jump)' : '<Tab>'
smap <expr> <Tab> vsnip#available(1) ? '<Plug>(vsnip-expand-or-jump)' : '<Tab>'
" vim-highlighter
nnoremap <C-CR> <Cmd>Hi><CR>
nnoremap <S-CR> <Cmd>Hi<<CR>
nnoremap [<CR> <Cmd>Hi{<CR>
nnoremap ]<CR> <Cmd>Hi}<CR>
let g:HiSyncMode = 1 " highlight across windows