dotfiles

.vim/vimrc [raw] [blame]
  1set nocompatible
  2filetype off
  3
  4" Leader
  5
  6let mapleader=" "  " Map <leader> to space
  7
  8" File Navigation / Search
  9nnoremap <Leader>o :lua require'telescope.builtin'.git_files{}<cr>
 10nnoremap <Leader>O :lua require'telescope.builtin'.find_files{}<cr>
 11nnoremap <Leader>g :lua require'telescope.builtin'.live_grep{}<cr>
 12nnoremap <Leader>b :lua require'telescope.builtin'.buffers{}<cr>
 13
 14nnoremap <Leader>f :NERDTreeFind<cr>
 15nnoremap <Leader>ag :Ack <cword><cr>
 16
 17" Testing
 18nnoremap <Leader><CR> :TestNearest<cr>
 19autocmd FileType dockerfile nnoremap <buffer> <Leader><CR> :!podman build -f %<cr>
 20nnoremap <Leader>t :TestFile<cr>
 21nnoremap <Leader>T :TestSuite<cr>
 22
 23nnoremap <C-n> :tabn<cr>
 24nnoremap <C-p> :tabp<cr>
 25nnoremap <C-c> :tabnew<cr>
 26
 27" Git
 28nnoremap <Leader>gs :Git status<cr>
 29nnoremap <Leader>gc :Git commit<cr>
 30nnoremap <Leader>gS :Git commit --amend<cr>
 31nnoremap <Leader>go :GBrowse<cr>
 32
 33set hidden " Handle multiple buffers better
 34
 35" Interface
 36color jellybeans
 37set number " Show line numbers
 38set showmode " Show the mode in use
 39set cursorline " Highlight current line
 40set wrap " Turn on line wrapping
 41"set textwidth=79 " Force wrap at 79 characters
 42set colorcolumn=80 " Show a column at 80
 43set title " Set the terminal title
 44set visualbell " Disable beeping
 45set mouse=a
 46set shortmess=Ia " Disable start up message and abbreviate items
 47
 48" Show indication of newlines and trailing spaces
 49nmap <leader>l :set list!<CR>
 50set listchars=tab:▸\ ,trail:▝
 51set list
 52
 53" Status Bar
 54set laststatus=2 " Always show status bar
 55" Highlight the status bar when in insert mode
 56au InsertEnter * hi StatusLine ctermfg=235 ctermbg=10
 57au InsertLeave * hi StatusLine ctermfg=15 ctermbg=240
 58
 59" Search
 60set hlsearch " Highlight all search matches
 61set incsearch " Highlight matches as you type
 62set ignorecase
 63set smartcase " Be case-sensitive if expression contains a capital letter
 64
 65" Backup
 66set nobackup
 67set nowritebackup
 68set directory=$HOME/.vim/tmp//,. " Keep swap files in one place
 69
 70" Formatting
 71set tabstop=4 " Use 4 spaces to a tab
 72set shiftwidth=4 " As above
 73set expandtab " Expand tabs into spaces
 74set showbreak= 75
 76" Completion
 77set complete=.,w,b,u,t,i
 78set completeopt=menu
 79set wildmenu                                           " Better completion in the CLI
 80set wildmode=longest:full,full                         " Completion settings
 81set wildignore+=*/venv/*
 82
 83" Use templates for new files
 84" from https://twitter.com/petdance/status/1009826710752317440
 85autocmd BufNewFile * silent! 0r ~/.vim/templates/%:e
 86autocmd BufNewFile * silent! 0r ~/.vim/templates/%:t
 87
 88" Files
 89autocmd FileType gitcommit setlocal spell textwidth=72
 90autocmd FileType markdown setlocal spell textwidth=79
 91autocmd FileType apiblueprint setlocal spell textwidth=79
 92autocmd FileType javascript setlocal shiftwidth=2
 93autocmd FileType go setlocal noexpandtab
 94
 95au BufRead,BufNewFile *.dat set filetype=ledger
 96
 97" Yeah... these get typoed
 98command W w
 99command Q q
100command Wq wq
101command WQ wq
102
103" Wordcount
104command! Wc :w !wc
105
106" autocmd BufWritePre * :%s/\s\+$//e
107
108" Syntastic
109let g:syntastic_python_flake8_args="--max-complexity 10"
110
111" ack-vim
112let g:ackprg = 'ag --vimgrep'
113
114" vim-test
115" Override pytest, otherwise it may pick poetry run, which is incompatible
116" with shells like nixos
117let test#python#pytest#executable = 'pytest'
118if &term =~ "^screen"
119  let test#strategy = "vimux"
120  map <Leader>q :call VimuxCloseRunner()<CR>
121else
122  let test#strategy = "neovim"
123endif
124
125if &shell =~# 'fish$'
126  set shell=bash
127endif
128
129" Podspecs ------ {{{
130augroup ft_podspec
131  autocmd!
132  autocmd BufNewFile,BufRead,BufWrite *.podspec setlocal filetype=podspec
133  autocmd BufNewFile,BufRead Podfile setlocal filetype=podfile
134  autocmd FileType podspec,podfile set syntax=ruby
135  autocmd FileType podspec set makeprg=pod\ spec\ lint\ %
136  autocmd FileType podfile set makeprg=pod\ install
137augroup END
138" }}}
139
140" vsnip
141imap <expr> <Tab>   vsnip#jumpable(1)   ? '<Plug>(vsnip-jump-next)'      : '<Tab>'
142smap <expr> <Tab>   vsnip#jumpable(1)   ? '<Plug>(vsnip-jump-next)'      : '<Tab>'
143imap <expr> <S-Tab> vsnip#jumpable(-1)  ? '<Plug>(vsnip-jump-prev)'      : '<S-Tab>'
144smap <expr> <S-Tab> vsnip#jumpable(-1)  ? '<Plug>(vsnip-jump-prev)'      : '<S-Tab>'