set autoindent set cinoptions=>4,n-2,^-2,{2,:2,=2,t0,(2 set formatoptions+=12 set hidden set nojoinspaces set confirm set showmatch set nrformats-=octal set showcmd set incsearch set hlsearch set virtualedit=block set display=uhex,lastline set list listchars=trail:-,tab:>-,extends:>,precedes:<,nbsp:~ set showbreak=+ set scrolloff=3 set previewheight=3 set clipboard= set mouse= set breakindent set colorcolumn=+1 set cursorline set guicursor= set number relativenumber numberwidth=5 set laststatus=1 set shortmess+=I set shortmess-=F " Color scheme syntax off highlight SpecialKey ctermfg=red highlight IncSearch cterm=none ctermbg=19 ctermfg=none highlight Search cterm=none ctermbg=20 ctermfg=none highlight SpellBad cterm=none ctermbg=none ctermfg=1 highlight SpellCap cterm=none ctermbg=none ctermfg=24 highlight SpellRare cterm=none ctermbg=none ctermfg=24 highlight MatchParen cterm=none ctermbg=none ctermfg=40 highlight Visual cterm=none ctermbg=18 ctermfg=none highlight CursorLine cterm=none ctermbg=233 ctermfg=none highlight ColorColumn cterm=none ctermbg=233 ctermfg=none highlight WhiteSpace cterm=none ctermbg=none ctermfg=20 highlight LineNr cterm=none ctermbg=none ctermfg=3 highlight CursorLineNr cterm=none ctermbg=233 ctermfg=3 highlight Pmenu cterm=none ctermbg=18 ctermfg=15 " Character encodings set fenc=utf8 fencs=ucs-bom,utf8,latin2 nmap 8 :set fenc=utf-8 nmap 2 :set fenc=latin-2 nmap * :e ++enc=utf-8 nmap @ :e ++enc=latin-2 " Digraphs :dig .. 8226 :dig `` 8222 :dig '' 8220 " Compression of spaces function CompressSpaces() let s:l=getline(".") let s:c=col(".")-1 if strpart(s:l, s:c, 1) !~ "[ \t]" echo "No whitespace under cursor" return endif if search("[^ \t]", "b", line(".")) let s:c=col(".") else let s:c=0 endif let s:e=match(s:l, "[^ \t]", s:c) let s:l=strpart(s:l, 0, s:c) . " " . strpart(s:l, s:e) call setline(".", s:l) call cursor(line("."), s:c+1) endfunction function VCompressSpaces() let s:s=prevnonblank(line(".")) let s:e=nextnonblank(line(".")) if s:e == 0 let s:e=line("$") + 1 endif if s:s == s:e echo "No blanks" return endif if s:s+1 < s:e-1 execute ":" . (s:s+1) . "," . (s:e-2) . "d" endif s/^.*$// endfunction " Signatures nmap su Go:.!~/bin/sig ~/etc/sigbase_ucw nmap sd Go:.!~/bin/sig ~/etc/sigbase nmap sx G:r ~/etc/sig_xmas " (Un)quoting vmap :s/^//:noh vmap > :s/^/>/:noh vmap :s/^.//:noh nmap :,$g/^[]/d:noh " Removing extra spaces vmap $ :s/[ ]\+$//:noh vmap ^ :s/^[ ]\+//:noh nmap :call CompressSpaces() nmap v :call VCompressSpaces() " Varia nmap p :set paste nmap P :set nopaste nmap q gqap nmap / :noh vmap ~ :!vlna -s -f vmap u :!unexpand -a " Compilation nmap c :make nmap C :!make nmap n :cn nmap N :cN nmap e :cl nmap k :setl cinoptions= nmap t :!make tags nmap V :!make view " Spelling checker nmap zc :setl spell spelllang=cs nmap ze :setl spell spelllang=en nmap zz :setl nospell " Worklog let g:changelog_username="Martin Mares " let g:worklog_name=$HOME . "/texts/worklog" function LogOpen() if bufname("%") != g:worklog_name execute "split " . g:worklog_name endif call cursor(line("$"), 1) endfunction function LogStop() call LogOpen() if search('^..-..-.... ', "c", line(".")) || search('^..-..-.... ', "bc") if search('^..-..-.... ..:..-??:??', "c", line(".")) execute 's/-??:??/-' . strftime("%H:%M") . " /" endif endif endfunction function LogStart() call LogStop() call LogOpen() call append('$', strftime("%d-%m-%Y %H:%M-??:?? ")) if getline(1) == "" 1d endif call cursor(line("$"), 1) endfunction nmap l :call LogStart() nmap L :call LogStop() " File types and indentation autocmd BufNewFile,BufRead *.[ch] set cindent autocmd BufNewFile,BufRead *.cc set cindent filetype on filetype plugin on " filetype indent on " Plugin manager packadd plug call plug#begin("~/.config/nvim/plugged") Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } } Plug 'neovim/nvim-lspconfig' call plug#end() " Exceptions for Firenvim if exists('g:started_by_firenvim') set laststatus=0 endif " Language server lua < gd lua vim.lsp.buf.declaration() nnoremap lua vim.lsp.buf.definition() nnoremap K lua vim.lsp.buf.hover() nnoremap gD lua vim.lsp.buf.implementation() nnoremap lua vim.lsp.buf.signature_help() nnoremap 1gD lua vim.lsp.buf.type_definition() nnoremap gr lua vim.lsp.buf.references() nnoremap gR lua vim.lsp.buf.rename() nnoremap g0 lua vim.lsp.buf.document_symbol() nnoremap gW lua vim.lsp.buf.workspace_symbol() nnoremap d lua vim.lsp.diagnostic.show_line_diagnostics()