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