dotfiles

config files and scripts
git clone git://git.hanetzok.net/dotfiles
Log | Files | Refs

init.vim (3568B)


      1 let mapleader =" "
      2 
      3 if ! filereadable(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/plug.vim"'))
      4 	echo "Downloading junegunn/vim-plug to manage plugins..."
      5 	silent !mkdir -p ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/
      6 	silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/plug.vim
      7 	autocmd VimEnter * PlugInstall
      8 endif
      9 
     10 call plug#begin(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/plugged"'))
     11 Plug 'preservim/nerdtree'
     12 Plug 'vimwiki/vimwiki'
     13 Plug 'vim-airline/vim-airline'
     14 Plug 'ap/vim-css-color'
     15 Plug 'dracula/vim', { 'as': 'dracula' }
     16 Plug 'morhetz/gruvbox'
     17 Plug 'scottmckendry/cyberdream.nvim'
     18 call plug#end()
     19 
     20 set title
     21 set bg=dark
     22 set mouse=a
     23 set nohlsearch
     24 set clipboard+=unnamedplus
     25 set noshowmode
     26 set noruler
     27 set laststatus=0
     28 set noshowcmd
     29 colorscheme cyberdream
     30 
     31 " Some basics:
     32 	nnoremap c "_c
     33 	filetype plugin on
     34 	syntax on
     35 	set encoding=utf-8
     36 	set number relativenumber
     37 " Enable autocompletion:
     38 	set wildmode=longest,list,full
     39 " Disables automatic commenting on newline:
     40 	autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
     41 " Perform dot commands over visual blocks:
     42 	vnoremap . :normal .<CR>
     43 " Spell-check set to <leader>o, 'o' for 'orthography':
     44 	map <leader>o :setlocal spell! spelllang=en_us<CR>
     45 " Splits open at the bottom and right:
     46 	set splitbelow splitright
     47 
     48 " Nerd tree
     49 	map <leader>q :NERDTreeToggle<CR>
     50 	autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
     51 	let NERDTreeBookmarksFile = stdpath('data') . '/NERDTreeBookmarks'
     52 
     53 " vim-airline
     54 	if !exists('g:airline_symbols')
     55 		let g:airline_symbols = {}
     56 	endif
     57 	let g:airline_symbols.colnr = ' C:'
     58 	let g:airline_symbols.linenr = ' L:'
     59 	let g:airline_symbols.maxlinenr = ' '
     60 	let g:airline#extensions#whitespace#symbol = '!'
     61 
     62 " Shortcutting split navigation, saving a keypress:
     63 	map <C-h> <C-w>h
     64 	map <C-j> <C-w>j
     65 	map <C-k> <C-w>k
     66 	map <C-l> <C-w>l
     67 
     68 " Replace ex mode with gq
     69 	map Q gq
     70 
     71 " Check file in shellcheck:
     72 	map <leader>s :!clear && shellcheck -x %<CR>
     73 
     74 " Open my bibliography file in split
     75 	map <leader>b :vsp<space>$BIB<CR>
     76 	map <leader>r :vsp<space>$REFER<CR>
     77 
     78 " Replace all is aliased to S.
     79 	nnoremap S :%s//g<Left><Left>
     80 
     81 " Save file as sudo on files that require root permission
     82 	cabbrev w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!
     83 
     84 " Automatically deletes all trailing whitespace and newlines at end of file on save. & reset cursor position
     85  	autocmd BufWritePre * let currPos = getpos(".")
     86 	autocmd BufWritePre * %s/\s\+$//e
     87 	autocmd BufWritePre * %s/\n\+\%$//e
     88   autocmd BufWritePre *.[ch] %s/\%$/\r/e " add trailing newline for ANSI C standard
     89   autocmd BufWritePre *neomutt* %s/^--$/-- /e " dash-dash-space signature delimiter in emails
     90   	autocmd BufWritePre * cal cursor(currPos[1], currPos[2])
     91 
     92 " Turns off highlighting on the bits of code that are changed, so the line that is changed is highlighted but the actual text that has changed stands out on the line and is readable.
     93 if &diff
     94     highlight! link DiffText MatchParen
     95 endif
     96 
     97 " Function for toggling the bottom statusbar:
     98 let s:hidden_all = 0
     99 function! ToggleHiddenAll()
    100     if s:hidden_all  == 0
    101         let s:hidden_all = 1
    102         set noshowmode
    103         set noruler
    104         set laststatus=0
    105         set noshowcmd
    106     else
    107         let s:hidden_all = 0
    108         set showmode
    109         set ruler
    110         set laststatus=2
    111         set showcmd
    112     endif
    113 endfunction
    114 nnoremap <leader>h :call ToggleHiddenAll()<CR>