1 " Copyright 2004, 2005, 2008 Develer S.r.l. (http://www.develer.com/)
2 " Copyright 2009-2022 Bernie Innocenti <bernie@codewiz.org>
4 " Author: Bernie Innocenti <bernie@codewiz.org>
5 " Author: Simone Zinanni <s.zinanni@develer.com>
6 " Author: Stefano Fedrigo <aleph@develer.com>
7 " Author: Daniele Varrazzo <piro@develer.com>
9 " note: to reload this file after a change, use ':so %'
11 set nocompatible " Use Vim defaults (much better!)
12 set bs=indent,eol,start " allow backspacing over everything in insert mode
14 set ruler " show the cursor position all the time
15 set laststatus=2 " Always show the status line at the bottom (neovim)
16 set clipboard+=unnamed,unnamedplus
20 " In text files, always limit the width of text to 78 characters
21 autocmd BufRead *.txt set tw=78
22 " When editing a file, always jump to the last cursor position
24 \ if line("'\"") > 0 && line ("'\"") <= line("$") |
25 \ exe "normal! g'\"" |
27 " don't write swapfile on most commonly used directories for NFS mounts or USB sticks
28 autocmd BufNewFile,BufReadPre /media/*,/run/media/*,/mnt/* set directory=~/tmp,/var/tmp,/tmp
29 " start with spec file template
30 autocmd BufNewFile *.spec 0r /usr/share/vim/vimfiles/template.spec
33 " Switch syntax highlighting on, when the terminal has colors
34 " Also switch on highlighting the last used search pattern.
35 if &t_Co > 2 || has("gui_running")
37 " bernie: hilighting long lines is very slow
43 " bernie: Show matching parenthesis when writing
45 " bernie: add bottom horizontal scroll bar
47 " aleph: remove useless luser toolbar
50 " highlighting for embedded LUA in nvim
51 let g:vimsyn_embed='l'
53 " bernie: highlight cursor line
57 " Limit modern terminal stuff to known-good terminals
58 if has("gui_running") || $KONSOLE_VERSION != '' || $VTE_VERSION != '' || $XTERM_VERSION != '' || $WEZTERM_EXECUTABLE != ''
59 if has('termguicolors')
64 highlight Normal ctermfg=248 ctermbg=NONE guibg=#000818 guifg=#eeeeee
65 highlight Visual guibg=fg guifg=#4040d0 gui=reverse
67 " Make the splits look pretty
68 highlight VertSplit guibg=#001111 guifg=#224422
70 " bernie: blinky cursor!
71 " let &guicursor = &guicursor . ',a:blinkwait175-blinkoff10-blinkon20'
73 " Enable spelling for comments in various languates
74 " bernie: don't enable by default because has too many false positives
75 "autocmd FileType c,cpp,java,python,rust,vim,text set spell
78 " Make the wrap column and cursor line more discrete
79 highlight CursorLine term=NONE cterm=NONE ctermbg=233 guibg=#001133
80 highlight CursorColumn term=NONE cterm=NONE ctermbg=233 guibg=#000820
81 highlight ColorColumn term=NONE cterm=NONE ctermbg=233 guibg=#200818
83 " The autocomplete menu
84 highlight Pmenu ctermfg=250 ctermbg=240 guifg=#ABB2BF guibg=#282C34
85 highlight PmenuSel ctermfg=253 ctermbg=245 guifg=#353B45 guibg=#A3BE8C
86 highlight PmenuSbar ctermbg=248 guibg=#353b45
87 highlight PmenuThumb ctermbg=15 guibg=#81A1C1
89 highlight! CmpItemAbbrDeprecated guibg=NONE gui=strikethrough guifg=#808080
90 highlight! CmpItemAbbrMatch guibg=NONE guifg=#569CD6
91 highlight! CmpItemAbbrMatchFuzzy guibg=NONE guifg=#569CD6
92 highlight! CmpItemKindVariable guibg=NONE guifg=#9CDCFE
93 highlight! CmpItemKindInterface guibg=NONE guifg=#9CDCFE
94 highlight! CmpItemKindText guibg=NONE guifg=#9CDCFE
95 highlight! CmpItemKindFunction guibg=NONE guifg=#C586C0
96 highlight! CmpItemKindMethod guibg=NONE guifg=#C586C0
97 highlight! CmpItemKindKeyword guibg=NONE guifg=#D4D4D4
98 highlight! CmpItemKindProperty guibg=NONE guifg=#D4D4D4
99 highlight! CmpItemKindUnit guibg=NONE guifg=#D4D4D4
101 highlight DiagnosticVirtualTextHint guifg=#444444
102 highlight DiagnosticVirtualTextWarn guifg=#884400
103 highlight DiagnosticVirtualTextError guifg=#880000
104 highlight DiagnosticUnderlineHint gui=NONE
105 highlight DiagnosticUnderlineWarn cterm=undercurl ctermfg=Brown gui=undercurl guisp=#884400
106 highlight DiagnosticUnderlineError cterm=undercurl ctermfg=Red gui=undercurl guisp=#880000
108 sign define DiagnosticSignError text= linehl= texthl=DiagnosticSignError numhl=
109 sign define DiagnosticSignWarn text= linehl= texthl=DiagnosticSignWarn numhl=
110 sign define DiagnosticSignInfo text= linehl= texthl=DiagnosticSignInfo numhl=
111 sign define DiagnosticSignHint text=? linehl= texthl=DiagnosticSignHint numhl=
112 autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {scope = "line", focus = false})
114 " Undercurl speling erors in terminal and gui
115 " let &t_Cs = "\e[4:3m"
116 " let &t_Ce = "\e[4:0m"
117 highlight SpellBad term=NONE cterm=undercurl ctermfg=Red ctermbg=NONE guifg=NONE gui=undercurl guisp=Red
118 highlight SpellCap term=NONE cterm=undercurl ctermfg=Yellow ctermbg=NONE guifg=NONE gui=undercurl guisp=Yellow
119 highlight SpellRare term=NONE cterm=undercurl ctermfg=Blue ctermbg=NONE guifg=NONE gui=undercurl guisp=Blue
120 highlight SpellLocal term=NONE cterm=undercurl ctermfg=Brown ctermbg=NONE guifg=NONE gui=undercurl guisp=Brown
122 " Highlight extra whitespace in various languages
123 autocmd FileType c,cpp,rust highlight ExtraWhitespace ctermbg=DarkRed guibg=DarkRed
126 " bernie: insensitive search
128 " aleph: if pattern contains uppercase chars, the search is case _sensitive_
131 " bernie: horizontal and vertical scrolling
136 set listchars+=extends:»,precedes:«,trail:-,nbsp:_,tab:\|_
137 " set fillchars+=vert:\▏
140 " piro: fix broken Page Up/Down
141 " http://vimrc-dissection.blogspot.com/2009/02/fixing-pageup-and-pagedown.html
142 map <silent> <PageUp> 1000<C-U>
143 map <silent> <PageDown> 1000<C-D>
144 imap <silent> <PageUp> <C-O>1000<C-U>
145 imap <silent> <PageDown> <C-O>1000<C-D>
148 " bernie: enter in directory browser open files in previous window
149 " let g:netrw_browse_split=4
151 " bernie: write on :n, :r, etc.
154 " aleph: dont't break softlinks (edit destination file), but break hardlinks
155 set backupcopy=yes,breakhardlink
157 " bernie: mouse everywhere!
165 " bernie: do not create swap files all over the place
168 " bernie: enable persistent undo
169 "if has('persistent_undo')
170 " let &undodir=&directory
174 " aleph: per non rompere le p*** a chi sta attorno ogni volta che si sbaglia tasto
176 " aleph: riduce al minimo la dimensione dei buffer non attivi
178 " aleph: dopo split e close gli altri buffer non si ridimensionano
180 " show (partial) command in status line
183 " bernie: status line
184 set statusline=%<%f%h%m%r%=%b\ 0x%B\ \ %l,%c%V\ %P
186 " informs sh syntax that /bin/sh is actually bash
189 " bernie: enable loading filetype specific plugins and indendation modes
190 filetype plugin indent on
194 set shiftwidth=0 " 0 means same as ts
196 " bernie: set default indents for various languages
197 autocmd FileType c,cpp set ts=4|set expandtab|let c_space_errors=1
198 autocmd FileType java set ts=4|set expandtab|let java_space_errors=1|let java_highlight_functions=1
199 autocmd FileType rust set ts=4|set expandtab
200 autocmd FileType python set ts=4|set expandtab
201 autocmd FileType go,lua set ts=2|set expandtab
202 autocmd FileType html,css set ts=2|set expandtab
203 autocmd FileType javascript,typescript set ts=2|set expandtab
204 autocmd FileType vim set ts=2|set expandtab
206 " bernie: auxiliary named config files
207 au BufNewFile,BufRead named.conf.*,named-*.conf setf named
209 " piro: treat arduino projects as C++ files.
210 autocmd BufRead *.pde set filetype=cpp
212 " bernie: bind '#' to 'grep word under cursor' -- see: http://vim.wikia.com/wiki/Find_in_files_within_Vim
213 :map # :execute "vimgrep /" . expand("<cword>") . "/j **" <Bar> cw<CR>
215 " bernie: search for highlighted text -- see: http://rayninfo.co.uk/vimtips.html
216 :vmap // y/<C-R>"<CR>
218 " piro: no, I don't want your fucking help!
223 " what's ; for anyway?
226 " w!! if you forget to sudo before saving
227 cmap w!! w !sudo tee % >/dev/null
229 " Repeat last command and put cursor at start of change -- http://vim.wikia.com/wiki/VimTip1142
232 " Go back to previous file
233 map <C-p> <esc>:bp<CR>
235 " bernie: see http://www.vim.org/scripts/script.php?script_id=3896
236 map <F2> :Bufferlist<CR>
238 " bernie: ex mode is useless and annoying
241 " bernie: http://vim.wikia.com/wiki/Edit_gpg_encrypted_files#Comments
244 " Disable swap files, and set binary file format before reading the file
245 autocmd BufReadPre,FileReadPre *.gpg
246 \ setlocal noswapfile bin
247 " Decrypt the contents after reading the file, reset binary file format
248 " and run any BufReadPost autocmds matching the file name without the .gpg
250 autocmd BufReadPost,FileReadPost *.gpg
251 \ execute "'[,']!gpg --decrypt --default-recipient-self" |
253 \ execute "doautocmd BufReadPost " . expand("%:r")
254 " Set binary file format and encrypt the contents before writing the file
255 autocmd BufWritePre,FileWritePre *.gpg
257 \ '[,']!gpg --encrypt --default-recipient-self
258 " After writing the file, do an :undo to revert the encryption in the
259 " buffer, and reset binary file format
260 autocmd BufWritePost,FileWritePost *.gpg
268 if has('persistent_undo')
269 let &undodir=&directory
273 let g:plug_url_format = 'git@github.com:%s.git'
274 call plug#begin('~/.vim/plugged')
275 Plug 'wsdjeg/vim-fetch'
276 "Plug 'editorconfig/editorconfig-vim'
278 Plug 'junegunn/fzf.vim'
279 Plug 'haya14busa/vim-asterisk'
280 Plug 'tikhomirov/vim-glsl'
281 Plug 'tpope/vim-fugitive'
289 let g:asterisk#keeppos = 1
290 map * <Plug>(asterisk-*)
291 map # <Plug>(asterisk-#)
292 map g* <Plug>(asterisk-g*)
293 map g# <Plug>(asterisk-g#)
294 map z* <Plug>(asterisk-z*)
295 map gz* <Plug>(asterisk-gz*)
296 map z# <Plug>(asterisk-z#)
297 map gz# <Plug>(asterisk-gz#)
301 autocmd FileType rust noremap <C-I> gq
302 autocmd FileType rust inoremap <C-K> <C-O>gq
305 set inccommand=nosplit
306 set signcolumn=number
309 " source user's local configuration file if available
310 if filereadable($HOME . "/.vimrc.local")
311 source ~/.vimrc.local