init.vim (4266B)
1 set nocompatible 2 set encoding=utf-8 3 4 call plug#begin() 5 " Colour scheme. 6 Plug 'craftzdog/solarized-osaka.nvim' 7 8 " Formatting. 9 Plug 'rhysd/vim-clang-format' " clang-format. 10 11 " Language support plugins. 12 Plug 'https://gn.googlesource.com/gn', { 'rtp': 'misc/vim' } 13 Plug 'nathangrigg/vim-beancount' 14 Plug 'rust-lang/rust.vim' 15 Plug 'neovim/nvim-lspconfig' 16 17 " Behaviour. 18 Plug 'ibhagwan/fzf-lua' 19 Plug 'tpope/vim-fugitive' 20 Plug 'lewis6991/gitsigns.nvim' 21 call plug#end() 22 23 " Configure plugins that require Lua-based setup. 24 source $HOME/.config/nvim/plugins.lua 25 26 " Bind fancier manpage plugin to Shift-k. 27 runtime ftplugin/man.vim 28 set keywordprg=:Man 29 30 " Disable visual-mode mouse select. 31 set mouse= 32 33 " Set <leader> to comma for convenience. 34 let mapleader=',' 35 36 " Enable middle-mouse paste. 37 map! <S-Insert> <MiddleMouse> 38 map <S-Insert> <MiddleMouse> 39 40 " Kill ex mode. 41 noremap Q <NOP> 42 43 " Kill arrow keys, for great justice. 44 noremap <Up> <NOP> 45 noremap <Down> <NOP> 46 noremap <Left> <NOP> 47 noremap <Right> <NOP> 48 49 " In terminal, ESC returns to normal mode. 50 tnoremap <Esc> <C-\><C-n> 51 52 " Retain selection on <,>. 53 vnoremap < <gv 54 vnoremap > >gv 55 56 " Snippets. 57 nnoremap <leader>sch :0r ~/.config/nvim/snippets/cc.h<CR> 58 nnoremap <leader>sci :0r ~/.config/nvim/snippets/cc.cc<CR> 59 nnoremap <leader>scn :.-1r ~/.config/nvim/snippets/namespace.cc<CR> 60 nnoremap <leader>scs :.-1r ~/.config/nvim/snippets/struct.cc<CR> 61 nnoremap <leader>scc :.-1r ~/.config/nvim/snippets/class.cc<CR> 62 nnoremap <leader>sjn :.-1r ~/.config/nvim/snippets/journal.md<CR> 63 64 " Basic options. 65 set incsearch " Turn on incrememental searching. 66 set hlsearch " Highlight search. 67 set visualbell " Less noise. 68 set number " Use line numbering. 69 set ruler " Show row/col in status. 70 set laststatus=2 " Always show status line. 71 set showmatch " Highlight matching bracket. 72 set history=50 " Keep 50 lines of cmdline history. 73 set wildmenu " Nicer autocomplete. 74 set wildmode=longest,full 75 set wildignore=*.o,*.pyc " Ignore some filetypes during completion. 76 set spelllang=en_ca " Set the spelling language. 77 78 " Omnicomplete. 79 set completeopt+=longest 80 81 " Indentation/tabulation. 82 set autoindent " Copy indent from current line when starting a new line. 83 set smartindent " Attempt to autoindent when starting a new line. 84 set smarttab " Use shiftwidth rather than tabstop at start of line. 85 set tabstop=2 " Number of spaces per tab. 86 set shiftwidth=2 " Number of spaces for each step of autoindent. 87 set softtabstop=2 " Number of spaces per tab when editing. 88 set expandtab " Insert spaces in place of tabs. 89 90 " Fix python's indent overrides. 91 au FileType python setl ts=2 sw=2 sts=2 et 92 93 " Configure tag file locations. 94 set tags+=~/.local/tags/system.tags 95 set tags+=~/.local/tags/cxx.tags 96 97 " Configure fzf-lua. 98 nnoremap <leader>b <cmd>FzfLua buffers<CR> 99 nnoremap <leader>f <cmd>FzfLua files<CR> 100 nnoremap <leader>g <cmd>FzfLua grep<CR> 101 nnoremap <leader>l <cmd>FzfLua live_grep<CR> 102 nnoremap <leader>c <cmd>FzfLua builtin commands<CR> 103 nnoremap <leader>q <cmd>lua vim.diagnostic.setqflist()<CR> 104 105 " Configure colour scheme and syntax highlighting. 106 if &t_Co > 2 107 syntax enable 108 set background=dark 109 colorscheme solarized-osaka 110 111 " Highlight cursor line, max column. 112 set cursorline 113 114 " Cursor line highlighting. 115 au WinLeave * setlocal nocursorline 116 au WinEnter * setlocal cursorline 117 au BufLeave * setlocal nocursorline 118 au BufEnter * setlocal cursorline 119 120 " Highlight over-length lines. 121 au BufEnter,InsertLeave * set colorcolumn=80 122 au BufEnter,InsertLeave *.txt,*.md set colorcolumn=80 123 au BufEnter,InsertLeave *.txt,*.md set textwidth=80 124 au BufEnter,InsertLeave *.java,*.m,*.mm set colorcolumn=100 125 au BufEnter,InsertLeave *.java,*.m,*.mm set textwidth=100 126 endif 127 128 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""" 129 " Functions 130 131 " Toggle absolute/relative numbering. 132 function! ToggleNumbering() 133 if (&number == 0) 134 set number 135 elseif (&relativenumber == 0) 136 set relativenumber 137 else 138 set norelativenumber 139 set nonumber 140 endif 141 endfunc 142 nnoremap <leader>n :call ToggleNumbering()<CR>