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