" Copyright 2004, 2005, 2008 Develer S.r.l. (http://www.develer.com/) " Copyright 2009-2022 Bernie Innocenti " " Author: Bernie Innocenti " Author: Simone Zinanni " Author: Stefano Fedrigo " Author: Daniele Varrazzo " " note: to reload this file after a change, use ':so %' set nocompatible " Use Vim defaults (much better!) set bs=indent,eol,start " allow backspacing over everything in insert mode set history=1000 set ruler " show the cursor position all the time set laststatus=2 " Always show the status line at the bottom (neovim) set clipboard+=unnamed,unnamedplus augroup fedora autocmd! " In text files, always limit the width of text to 78 characters autocmd BufRead *.txt set tw=78 " When editing a file, always jump to the last cursor position autocmd BufReadPost * \ if line("'\"") > 0 && line ("'\"") <= line("$") | \ exe "normal! g'\"" | \ endif " don't write swapfile on most commonly used directories for NFS mounts or USB sticks autocmd BufNewFile,BufReadPre /media/*,/run/media/*,/mnt/* set directory=~/tmp,/var/tmp,/tmp " start with spec file template autocmd BufNewFile *.spec 0r /usr/share/vim/vimfiles/template.spec augroup END " Switch syntax highlighting on, when the terminal has colors " Also switch on highlighting the last used search pattern. if &t_Co > 2 || has("gui_running") syntax on " bernie: hilighting long lines is very slow set synmaxcol=320 set hlsearch set incsearch set background=dark " bernie: Show matching parenthesis when writing set showmatch " bernie: add bottom horizontal scroll bar set guioptions+=b " aleph: remove useless luser toolbar set guioptions-=T " highlighting for embedded LUA in nvim let g:vimsyn_embed='l' " bernie: highlight cursor line set cursorline set colorcolumn=+1 " Limit modern terminal stuff to known-good terminals if has("gui_running") || $KONSOLE_VERSION != '' || $VTE_VERSION != '' || $XTERM_VERSION != '' || $WEZTERM_EXECUTABLE != '' if has('termguicolors') set termguicolors endif colorscheme darkblue highlight Normal ctermfg=248 ctermbg=NONE guibg=#000818 guifg=#eeeeee highlight Visual guibg=fg guifg=#4040d0 gui=reverse " Make the splits look pretty highlight VertSplit guibg=#001111 guifg=#224422 " bernie: blinky cursor! " let &guicursor = &guicursor . ',a:blinkwait175-blinkoff10-blinkon20' " Enable spelling for comments in various languates " bernie: don't enable by default because has too many false positives "autocmd FileType c,cpp,java,python,rust,vim,text set spell endif " Make the wrap column and cursor line more discrete highlight CursorLine term=NONE cterm=NONE ctermbg=233 guibg=#001133 highlight CursorColumn term=NONE cterm=NONE ctermbg=233 guibg=#000820 highlight ColorColumn term=NONE cterm=NONE ctermbg=233 guibg=#200818 " The autocomplete menu highlight Pmenu ctermfg=250 ctermbg=240 guifg=#ABB2BF guibg=#282C34 highlight PmenuSel ctermfg=253 ctermbg=245 guifg=#353B45 guibg=#A3BE8C highlight PmenuSbar ctermbg=248 guibg=#353b45 highlight PmenuThumb ctermbg=15 guibg=#81A1C1 highlight! CmpItemAbbrDeprecated guibg=NONE gui=strikethrough guifg=#808080 highlight! CmpItemAbbrMatch guibg=NONE guifg=#569CD6 highlight! CmpItemAbbrMatchFuzzy guibg=NONE guifg=#569CD6 highlight! CmpItemKindVariable guibg=NONE guifg=#9CDCFE highlight! CmpItemKindInterface guibg=NONE guifg=#9CDCFE highlight! CmpItemKindText guibg=NONE guifg=#9CDCFE highlight! CmpItemKindFunction guibg=NONE guifg=#C586C0 highlight! CmpItemKindMethod guibg=NONE guifg=#C586C0 highlight! CmpItemKindKeyword guibg=NONE guifg=#D4D4D4 highlight! CmpItemKindProperty guibg=NONE guifg=#D4D4D4 highlight! CmpItemKindUnit guibg=NONE guifg=#D4D4D4 highlight DiagnosticVirtualTextHint guifg=#444444 highlight DiagnosticVirtualTextWarn guifg=#884400 highlight DiagnosticVirtualTextError guifg=#880000 highlight DiagnosticUnderlineHint gui=NONE highlight DiagnosticUnderlineWarn cterm=undercurl ctermfg=Brown gui=undercurl guisp=#884400 highlight DiagnosticUnderlineError cterm=undercurl ctermfg=Red gui=undercurl guisp=#880000 sign define DiagnosticSignError text= linehl= texthl=DiagnosticSignError numhl= sign define DiagnosticSignWarn text= linehl= texthl=DiagnosticSignWarn numhl= sign define DiagnosticSignInfo text= linehl= texthl=DiagnosticSignInfo numhl= sign define DiagnosticSignHint text=? linehl= texthl=DiagnosticSignHint numhl= autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {scope = "line", focus = false}) " Undercurl speling erors in terminal and gui " let &t_Cs = "\e[4:3m" " let &t_Ce = "\e[4:0m" highlight SpellBad term=NONE cterm=undercurl ctermfg=Red ctermbg=NONE guifg=NONE gui=undercurl guisp=Red highlight SpellCap term=NONE cterm=undercurl ctermfg=Yellow ctermbg=NONE guifg=NONE gui=undercurl guisp=Yellow highlight SpellRare term=NONE cterm=undercurl ctermfg=Blue ctermbg=NONE guifg=NONE gui=undercurl guisp=Blue highlight SpellLocal term=NONE cterm=undercurl ctermfg=Brown ctermbg=NONE guifg=NONE gui=undercurl guisp=Brown " Highlight extra whitespace in various languages autocmd FileType c,cpp,rust highlight ExtraWhitespace ctermbg=DarkRed guibg=DarkRed endif " bernie: insensitive search set ignorecase " aleph: if pattern contains uppercase chars, the search is case _sensitive_ set smartcase " bernie: horizontal and vertical scrolling set nowrap set sidescroll=1 set sidescrolloff=3 set scrolloff=3 set listchars+=extends:»,precedes:«,trail:-,nbsp:_,tab:\|_ " set fillchars+=vert:\▏ set wildmenu " piro: fix broken Page Up/Down " http://vimrc-dissection.blogspot.com/2009/02/fixing-pageup-and-pagedown.html map 1000 map 1000 imap 1000 imap 1000 set nostartofline " bernie: enter in directory browser open files in previous window " let g:netrw_browse_split=4 " bernie: write on :n, :r, etc. set autowriteall " aleph: dont't break softlinks (edit destination file), but break hardlinks set backupcopy=yes,breakhardlink " bernie: mouse everywhere! if has("mouse") set mouse=a if !has('nvim') set ttymouse=xterm2 endif endif " bernie: do not create swap files all over the place set directory-=. " bernie: enable persistent undo "if has('persistent_undo') " let &undodir=&directory " set undofile "endif " aleph: per non rompere le p*** a chi sta attorno ogni volta che si sbaglia tasto set visualbell " aleph: riduce al minimo la dimensione dei buffer non attivi set winminheight=0 " aleph: dopo split e close gli altri buffer non si ridimensionano set noequalalways " show (partial) command in status line set showcmd " bernie: status line set statusline=%<%f%h%m%r%=%b\ 0x%B\ \ %l,%c%V\ %P " informs sh syntax that /bin/sh is actually bash let is_bash=1 " bernie: enable loading filetype specific plugins and indendation modes filetype plugin indent on set smarttab set matchpairs+=<:> set shiftround set shiftwidth=0 " 0 means same as ts " bernie: set default indents for various languages autocmd FileType c,cpp set ts=4|set expandtab|let c_space_errors=1 autocmd FileType java set ts=4|set expandtab|let java_space_errors=1|let java_highlight_functions=1 autocmd FileType rust set ts=4|set expandtab autocmd FileType python set ts=4|set expandtab autocmd FileType go,lua set ts=2|set expandtab autocmd FileType html,css set ts=2|set expandtab autocmd FileType javascript,typescript set ts=2|set expandtab autocmd FileType vim set ts=2|set expandtab " bernie: auxiliary named config files au BufNewFile,BufRead named.conf.*,named-*.conf setf named " piro: treat arduino projects as C++ files. autocmd BufRead *.pde set filetype=cpp " bernie: bind '#' to 'grep word under cursor' -- see: http://vim.wikia.com/wiki/Find_in_files_within_Vim :map # :execute "vimgrep /" . expand("") . "/j **" cw " bernie: search for highlighted text -- see: http://rayninfo.co.uk/vimtips.html :vmap // y/" " piro: no, I don't want your fucking help! inoremap nnoremap vnoremap " what's ; for anyway? noremap ; : " w!! if you forget to sudo before saving cmap w!! w !sudo tee % >/dev/null " Repeat last command and put cursor at start of change -- http://vim.wikia.com/wiki/VimTip1142 map . .`[ " Go back to previous file map :bp " bernie: see http://www.vim.org/scripts/script.php?script_id=3896 map :Bufferlist " bernie: ex mode is useless and annoying map Q " bernie: http://vim.wikia.com/wiki/Edit_gpg_encrypted_files#Comments augroup encrypted au! " Disable swap files, and set binary file format before reading the file autocmd BufReadPre,FileReadPre *.gpg \ setlocal noswapfile bin " Decrypt the contents after reading the file, reset binary file format " and run any BufReadPost autocmds matching the file name without the .gpg " extension autocmd BufReadPost,FileReadPost *.gpg \ execute "'[,']!gpg --decrypt --default-recipient-self" | \ setlocal nobin | \ execute "doautocmd BufReadPost " . expand("%:r") " Set binary file format and encrypt the contents before writing the file autocmd BufWritePre,FileWritePre *.gpg \ setlocal bin | \ '[,']!gpg --encrypt --default-recipient-self " After writing the file, do an :undo to revert the encryption in the " buffer, and reset binary file format autocmd BufWritePost,FileWritePost *.gpg \ silent u | \ setlocal nobin augroup END set updatetime=1000 set shortmess+=c if has('persistent_undo') let &undodir=&directory set undofile endif let g:plug_url_format = 'git@github.com:%s.git' call plug#begin('~/.vim/plugged') Plug 'wsdjeg/vim-fetch' "Plug 'editorconfig/editorconfig-vim' Plug 'junegunn/fzf' Plug 'junegunn/fzf.vim' Plug 'haya14busa/vim-asterisk' Plug 'tikhomirov/vim-glsl' Plug 'tpope/vim-fugitive' call plug#end() " == FZF == nmap :FZF " == vim-asterisk == let g:asterisk#keeppos = 1 map * (asterisk-*) map # (asterisk-#) map g* (asterisk-g*) map g# (asterisk-g#) map z* (asterisk-z*) map gz* (asterisk-gz*) map z# (asterisk-z#) map gz# (asterisk-gz#) " == rust.vim == autocmd FileType rust noremap gq autocmd FileType rust inoremap gq if has('nvim') set inccommand=nosplit set signcolumn=number endif " nvim " source user's local configuration file if available if filereadable($HOME . "/.vimrc.local") source ~/.vimrc.local endif