at main 376 lines 13 kB view raw
1"" 2" Help: 3" ----------- | Navigation 4" <C-\> | Show/hide tree view 5" g, | - Open init.vim (this file) 6" g' | - Open manfest file (language dependent) 7" gd | - Go to declaration 8" gl | - Jump to line 9" gL | - Jump to line (any pane) 10" <C-s> | - Jump to search (1 character) 11" \w | - Jump to word (down) 12" <Enter> | - Jump to word 13" <F9> | - Open an embedded terminal 14" <C-p> | - Fuzzy finder open file 15" <A-asdf> | - Change windows 16" <A-hjkl> | - Move fast 17" ----------- | Spelling 18" <Space>f | - Fix 19" <Space>s | - Toggle 20" <Space>g | - Mark as ok 21" ----------- | Intellisense 22" H | - Hover 23" <C-Space> | - Autocomplete 24" <F2> | - Refactor (Rename) 25" ----------- | Git 26" gs | - git status 27" ga | - git add -A 28" gc | - git commit 29" gp | - git push 30" + | - git add % 31" - | - git reset % 32" ----------- | Windows 33" <C-k> | Split pane 34" left | - to the left 35" right | - to the right 36" ----------- | Formatting 37" <Space>w | Trim whitespace 38" <Space>a | Easy align 39" ip= | - align in paragraph on = 40" cs | Change surroundings 41" '" | - from ' to " 42" [] | - from [ ([] with spaces) to ] ([] with no spaces) 43" ys | Add surroundings 44" iw' | - ' around word 45" ds | Remove surroundings 46" ' | - ' around 47" <C-l> | Enter Unicode as Latex 48" ----------- | Sessions 49" ss | - Save session 50" sa | - Save session as 51" sl | - Load session 52" so | - Open default session 53"" 54 55set shell=bash 56 57"Install the plugin thing if it isn't installed yet 58"note that it only auto-installs the first time. Later modifications must be 59"run manually with :PlugInstall 60if empty(glob('~/.local/share/nvim/site/autoload/plug.vim')) 61 silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim 62 autocmd VimEnter * PlugInstall --sync | source $MYVIMRC 63endif 64 65"Install the plugins 66call plug#begin('~/.vim/plugged') 67Plug 'joshdick/onedark.vim' " colour scheme 68Plug 'sheerun/vim-polyglot' " language packs 69Plug 'scrooloose/nerdtree' " tree view 70Plug 'scrooloose/nerdcommenter' " ctrl-slash for comment 71Plug 'vim-airline/vim-airline' " bottom bar 72Plug 'vim-airline/vim-airline-themes' " bottom bar colours 73Plug 'ctrlpvim/ctrlp.vim' " CtrlP fuzzy finder 74Plug 'junegunn/fzf' " idk more fuzzy finder or something 75Plug 'junegunn/vim-easy-align' " auto align stuff 76Plug 'junegunn/goyo.vim' " distraction free writing 77Plug 'junegunn/limelight.vim' " spotlighting 78Plug 'jparise/vim-graphql' " GraphQL syntax highlighting 79Plug 'airblade/vim-gitgutter' " git addition/deletions in the left bar 80Plug 'easymotion/vim-easymotion' " jumping around 81Plug 'vim-scripts/sessionman.vim' " sessions 82Plug 'lrvick/Conque-Shell' " terminal inside Vim 83Plug 'tpope/vim-fugitive' " control git from inside Vim 84Plug 'tpope/vim-surround' " surround things in quotes, etc. 85Plug 'kshenoy/vim-signature' " handles and displays the marks 86Plug 'terryma/vim-multiple-cursors' " multiple cursor support 87Plug 'projectfluent/fluent.vim' " fluent syntax highlighting 88Plug 'murarth/ketos', { 'rtp': 'etc/vim' } " ketos syntax highlighting 89Plug 'luochen1990/rainbow' " rainbow parentheses 90Plug 'arthurxavierx/vim-unicoder' " unicode input 91Plug 'SidOfc/mkdx' " markdown improvements 92Plug 'LukeSmithxyz/vimling' " some other accents/IPA input 93Plug 'francoiscabrol/ranger.vim' " integration with ranger 94Plug 'rbgrouleff/bclose.vim' " required for ranger integration 95Plug 'evanleck/vim-svelte' " svelte syntax highlighting 96Plug 'jceb/vim-orgmode' " emacs org-mode for vim 97Plug 'tpope/vim-speeddating' " better date support for increment 98Plug 'idanarye/breeze.vim' " easymotion for HTML 99Plug 'neoclide/coc.nvim', {'branch': 'release'} " coc language client 100call plug#end() 101 102" fix the bugs? 103set nocompatible " fixes for weird keybindings 104set nobackup 105set nowritebackup 106set backupcopy=yes " fixes for file watchers 107 108set cmdheight=2 109set updatetime=300 110set shortmess+=c 111set signcolumn=yes 112 113" some ergonomics things 114let mapleader = " " 115inoremap <A-p> <ESC> 116noremap <A-h> 10h 117noremap <A-j> 10j 118noremap <A-k> 10k 119noremap <A-l> 10l 120noremap zz :w<CR> 121inoremap <A-a> <C-o><C-w>h 122inoremap <A-s> <C-o><C-w>j 123inoremap <A-d> <C-o><C-w>k 124inoremap <A-f> <C-o><C-w>l 125nnoremap <A-a> <C-w>h 126nnoremap <A-s> <C-w>j 127nnoremap <A-d> <C-w>k 128nnoremap <A-f> <C-w>l 129 130let g:multi_cursor_use_default_mapping=0 131 132" Default mapping 133let g:multi_cursor_start_word_key = '<Leader>n' 134let g:multi_cursor_select_all_word_key = '<Leader>N' 135let g:multi_cursor_start_key = '<Leader>gn' 136let g:multi_cursor_select_all_key = '<Leader>gN' 137let g:multi_cursor_next_key = '<Leader><C-n>' 138let g:multi_cursor_prev_key = '<Leader><C-N>' 139let g:multi_cursor_skip_key = '<Leader><A-n>' 140let g:multi_cursor_quit_key = '<Esc>' 141 142" auto indents 143filetype plugin indent on 144set backspace=2 145set expandtab 146set tabstop=2 147set softtabstop=2 148set shiftwidth=2 149set autoindent 150nnoremap <Leader><Tab> :set expandtab!<CR> 151 152" allow mouse controls... 153set mouse=a 154" show line numbers 155set number 156" show invisibles 157set list 158set listchars=tab:»\ ,eol,space159" something something idk 160set cursorline 161 162" enable colour scheme 163set termguicolors 164syntax on 165set encoding=utf-8 166colorscheme onedark 167 168" markdown 169let g:polyglot_disabled = ['markdown'] 170let g:mkdx#settings = { 'highlight': { 'enable': 1 }, 171 \ 'map': { 'prefix': '<leader>', 'enable': 1 }, 172 \ 'tokens': { 'bold': '__', 'italic': '*', 'strike': '~', 'list': '*', 'fence': '`', 'header': '#' }, 173 \ 'links': { 'external': { 'enable': 1 } }, 174 \ 'toc': { 'text': 'Table of Contents', 'update_on_write': 1 } } 175 176nnoremap <leader>mi :call ToggleIPA()<CR> 177 178" rainbow 179let g:rainbow_active = 0 180nnoremap <Leader>mp :RainbowToggle<CR> 181 182" goyo 183nnoremap <Leader>mr :Goyo 100<CR> 184 185" spelling 186set spell spelllang=en_ca 187nnoremap <Leader>f 1z= 188nnoremap <Leader>s :set spell!<CR> 189nnoremap <Leader>g zg 190set nospell 191 192nnoremap zg zz 193 194"Save with sudo 195cmap w!! w !sudo tee > /dev/null % 196 197"Splitting, atom style (ctrl-k [direction]) 198" insert mode 199imap <C-k><left> <C-o>:abo vsp %<CR> 200imap <C-k><h <C-o>:abo vsp %<CR> 201imap <C-k><right> <C-o>:bel vsp %<CR> 202imap <C-k>l <C-o>:bel vsp %<CR> 203imap <C-k><up> <C-o>:abo sp %<CR> 204imap <C-k>k <C-o>:abo sp %<CR> 205imap <C-k><down> <C-o>:bel sp %<CR> 206imap <C-k>j <C-o>:bel sp %<CR> 207" normal mode 208nmap <C-k><left> :abo vsp %<CR> 209nmap <C-k><h :abo vsp %<CR> 210nmap <C-k><right> :bel vsp %<CR> 211nmap <C-k>l :bel vsp %<CR> 212nmap <C-k><up> :abo sp %<CR> 213nmap <C-k>k :abo sp %<CR> 214nmap <C-k><down> :bel sp %<CR> 215nmap <C-k>j :bel sp %<CR> 216 217" tabs navigation 218nnoremap <Leader>t :tabnew<CR> 219nnoremap <Leader><Left> :tabp<CR> 220nnoremap <Leader><Right> :tabn<CR> 221 222" buffers navigation 223nnoremap gb :ls<CR>:b<Space> 224 225"Open this file (g ,) 226nmap g, :n ~/.config/nvim/init.vim<CR> 227 228"Open this file (g ,) 229nmap g, :n ~/.config/nvim/init.vim<CR> 230 231"Trim whitespace from end of lines 232nnoremap <Leader>w :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar><CR> 233 234"Git 235" `git status` (g s) 236nmap <Leader>gs :Gstatus<CR> 237" `git commit` (g c) 238nmap <Leader>gc :Gcommit<CR> 239" `git push` (g p) 240nmap <Leader>gp :Gpush<CR> 241" `git add -A` (g a) 242nmap <Leader>ga :silent !git add -A<CR> 243" `git add` this file (+) 244nmap + :silent !git add %<CR> 245" `git reset` this file (-) 246nmap - :silent !git reset %<CR><C-l> 247" Set the base for gutter markings 248let g:gitgutter_diff_base = 'HEAD' 249 250"Easy motion 251let g:EasyMotion_smartcase = 1 252"Jump somewhere (Enter) 253nmap <Enter> <Plug>(easymotion-bd-w) 254"Go to line (g l) 255nmap gl <Plug>(easymotion-bd-jk) 256"Go to line in any window (g L) 257nmap g<S-l> <Plug>(easymotion-overwin-line) 258"Go to char in any window (Ctrl-s) 259nmap <C-s> <Plug>(easymotion-overwin-f) 260imap <C-s> <C-o><Plug>(easymotion-overwin-f) 261 262" EasyAlign 263xmap <Leader>a <Plug>(EasyAlign) 264nmap <Leader>a <Plug>(EasyAlign) 265 266"Session management. 267"Kind of difficult to get right always, but sometimes it is quick and handy 268let v:this_session = 'default' 269let sessionman_save_on_exit = 1 270"Save current open windows (s s) 271nmap ss :SessionSave<CR> 272"Save current session with name (s a) 273nmap sa :SessionSaveAs<CR> 274"Open some recent session, good for resuming after closing (s o) 275nmap so :SessionOpen default<CR> 276"Open a specific named session (s l) 277nmap sl :SessionList<CR> 278 279"Language server integration 280set hidden 281 282"Tree view (Ctrl-\) 283map <C-\> :NERDTreeToggle<CR> 284 285"Commenting 286"Toggle comment line/selection (Ctrl-/) 287nmap <C-_> <leader>ci 288vmap <C-_> <leader>ci 289imap <C-_> <C-o><leader>ci 290 291"Airline 292"Make sure you install a Powerline version of a font. I suggest Fira Code 293let g:airline#extensions#tabline#enabled = 1 294let g:airline_powerline_fonts = 1 295"Pick a nice colour 296let g:airline_theme = 'bubblegum' 297 298"CtrlP Fuzzy finder 299"Some directories and stuff to skip. Makes it faster if you skip a lot 300let g:ctrlp_custom_ignore = { 301 \ 'dir': '\v[\/](\.(git|hg|svn|build)|node_modules|Pods|elm-stuff|target|dist|vendor)$', 302 \ 'file': '\v\.(exe|so|dll|DS_store|swp)$', 303 \ } 304nnoremap <Leader><C-P> :CtrlPClearAllCaches<CR> 305 306"Conque-Shell 307"Open a terminal inside of vim (F9) 308" nmap <F9> :ConqueTermVSplit bash<CR> 309nmap <F9> <Plug>(coc-terminal-toggle) 310 311"Ranger 312let g:ranger_map_keys = 0 313let g:ranger_replace_netrw = 1 314nnoremap <silent><Leader>\ :Ranger<CR> 315nnoremap <silent><C-\> :RangerWorkingDirectory<CR> 316 317function! InvertMeaning () 318 normal! "iyiw 319 echom @i 320 let mappings = { 321 \ "true": "false", 322 \ "false": "true", 323 \ "1": "0", 324 \ "0": "1", 325 \ "max": "min", 326 \ "min": "max", 327 \ "<": ">", 328 \ ">": "<", 329 \ ">=": "<=", 330 \ "<=": ">=", 331 \ "!=": "==", 332 \ "==": "!=", 333 \ } 334 if has_key(mappings, @i) 335 execute "normal! ciw" . mappings[@i] 336 endif 337endfunction 338 339nnoremap <Leader>i :call InvertMeaning()<CR><Esc> 340 341"coc 342 343" Use tab for trigger completion with characters ahead and navigate. 344" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin. 345inoremap <silent><expr> <right> pumvisible() ? "\<C-n>" : "\<right>" 346inoremap <expr><left> pumvisible() ? "\<C-p>" : "\<left>" 347 348function! s:check_back_space() abort 349 let col = col('.') - 1 350 return !col || getline('.')[col - 1] =~# '\s' 351endfunction 352 353" Use <c-space> to trigger completion. 354inoremap <silent><expr> <c-space> coc#refresh() 355" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position. 356" Coc only does snippet and additional edit on confirm. 357inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" 358 359" Remap keys for gotos 360nmap <silent> gd <Plug>(coc-definition) 361nmap <silent> gy <Plug>(coc-type-definition) 362nmap <silent> gi <Plug>(coc-implementation) 363nmap <silent> <Leader>r <Plug>(coc-references) 364 365" Use K to show documentation in preview window 366nnoremap <silent> K :call <SID>show_documentation()<CR> 367 368function! s:show_documentation() 369 if (index(['vim','help'], &filetype) >= 0) 370 execute 'h '.expand('<cword>') 371 else 372 call CocAction('doHover') 373 endif 374endfunction 375 376set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}