summaryrefslogblamecommitdiffstats
path: root/vim/vimrc
blob: c5237a8034262ece83c4e8bf893cab4f54908792 (plain) (tree)
1
2
3
4
5
6
7
8
9
10




                                                                     




                                                                          

                 
 

                
               
                                                                                                                                           


                     
                                           











                                                                    



                                     







                                                               




                       

                   





















                                                                        









































                                                                             












                                                                                         









                                     












































                                                                            
 













                                                                               






































                                                                     
" New vimrc! Jan 2020
"
" We want to load this first - everything else I include overrides it
runtime! plugin/sensible.vim

" try to speed vim on openbsd
" https://www.reddit.com/r/openbsd/comments/9t3t4q/vim_81_slow_on_openbsd/
let sh_minlines=100
let sh_maxlines=600
set synmaxcol=300
set noshowmatch
set synmaxcol=200

set nocompatible

set cmdheight=1
set re=1 "" Fuck - this does speed up vim a bit https://stackoverflow.com/questions/19030290/syntax-highlighting-causes-terrible-lag-in-vim
set foldmethod=manual
set encoding=utf-8
set modelines=0
" set relativenumber  ! might slow down vim
set autoindent
set showmode
set nocursorline
set ttyfast
"set ttimeout
set notimeout
set nottimeout
set backspace=indent,eol,start
set laststatus=2
set history=1000         " remember more commands and search history
set undolevels=1000      " use many muchos levels of undo
set wildignore=*.swp,*.bak,*.pyc,*.class
set visualbell           " don't beep
set noerrorbells         " don't beep
set number
set fillchars=diff:⣿,vert:\|
set ruler               " show the cursor position all the time
set showcmd             " display incomplete commands
set vb
"set list
set listchars=tab:▸\ ,eol:¬,extends:❯,precedes:❮
set lazyredraw
set matchtime=3
set showbreak=↪
set splitbelow
set splitright
set autowrite
set linebreak
set fileencodings=utf-8
set background=dark
set path+=**

" Searching and movement ...
nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
set incsearch
set showmatch
set hlsearch
set gdefault
set scrolloff=3
set sidescroll=1
set sidescrolloff=10
set virtualedit+=block
nnoremap <leader><space> :noh<cr>:call clearmatches()<cr>
 
" open a Quickfix window for the last search
nnoremap <silent> <leader>/ :execute 'vimgrep /'.@/.'/g %'<CR>:copen<CR>

 
"backups/swap
set noswapfile
set nobackup

" persist the undo tree for each file
set undofile
set undodir^=~/.vim/undo//

" Formatting, like Textmate
nnoremap Q gqip
"
" Django ... 
augroup ft_django
    au!
    au BufNewFile,BufRead urls.py           setlocal nowrap
    au BufNewFile,BufRead urls.py           normal! zR
    au BufNewFile,BufRead dashboard.py      normal! zR
    au BufNewFile,BufRead local_settings.py normal! zR

    au BufNewFile,BufRead admin.py     setlocal filetype=python.django
    au BufNewFile,BufRead urls.py      setlocal filetype=python.django
    au BufNewFile,BufRead models.py    setlocal filetype=python.django
    au BufNewFile,BufRead views.py     setlocal filetype=python.django
    au BufNewFile,BufRead settings.py  setlocal filetype=python.django
    au BufNewFile,BufRead settings.py  setlocal foldmethod=marker
    au BufNewFile,BufRead forms.py     setlocal filetype=python.django
    au BufNewFile,BufRead common_settings.py  setlocal filetype=python.django
    au BufNewFile,BufRead common_settings.py  setlocal foldmethod=marker
augroup END
"
" Mutt ... 
augroup ft_muttrc
    au!

    au BufRead,BufNewFile *.muttrc set ft=muttrc

    au FileType muttrc setlocal foldmethod=marker foldmarker=,}}}
augroup END
"
" General python properness ...
autocmd FileType python set sw=4
autocmd FileType python set ts=4
autocmd FileType python set sts=4

syntax on
filetype indent on
filetype plugin on

set omnifunc=syntaxcomplete#Complete

" Do not scan included files when doing autocomplete
" When doing C-n in default Vim autocomplete, it looks through all
" includes which can take time. We can turn it off... This is referenced
" at https://stackoverflow.com/questions/2169645/vims-autocomplete-is-excruciatingly-slow
" and on p287 of Practical Vim
set complete-=i

" Go stuff 

let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_operators = 1

let g:go_auto_type_info = 1

let test#go#runner = 'gotest'

let g:go_term_mode = "split"
let g:go_term_height = 10
"autocmd FileType go nmap <leader>r :w<CR>:split <bar> terminal go run %<CR>
autocmd FileType go nmap <leader>r :GoRun<CR>
" highlights the variable in the file for you..
"let g:go_auto_sameids = 1
" auto import...
let g:go_fmt_command = "goimports"
" automatic type info on cursor
let g:go_auto_type_info = 1
"let g:go_snippet_engine = "neosnippet"
au Filetype go nmap <leader>ga <Plug>(go-alternate-edit)
au Filetype go nmap <leader>gah <Plug>(go-alternate-split)
au Filetype go nmap <leader>gav <Plug>(go-alternate-vertical)
au FileType go nmap <F10> :GoTest -short<cr>
au FileType go nmap <F9> :DlvToggleBreakpoint<CR>
au FileType go nmap <S-F9> :DlvTest<CR>
au FileType go nmap <F11> :DlvDebug<CR>
au FileType go nmap <S-F5> :GoRename<CR>

" vim-test

" use vim-dispatch to run tests in the quickfix window
" from Modern Vim Ch.4
" the mappings below are from vim-test
" https://github.com/vim-test/vim-test
" dispatch opens send test output to quickfix window
let test#strategy = "vimterminal" 
let test#python#runner = "pytest"
let test#neovim#term_position = "topleft"
let test#python#pytest#options = '-vvv --tb=short'
let test#go#runner = 'gotest'
"let test#go#gotest#options = '-v'

" To run mypy using vim-dispath -with Dispatch
autocmd FileType python let b:dispatch = 'mypy --ignore-missing-imports'

nmap <silent> t<C-n> :TestNearest<CR>
nmap <silent> t<C-f> :TestFile<CR>
nmap <silent> t<C-s> :TestSuite<CR>
"nmap <silent> t<C-l> :TestLast<CR>
nmap <silent> <S-F10> :TestLast<CR>
nmap <silent> t<C-g> :TestVisit<CR>
"
" wildignore
set wildignore=*.swp,*.bak,*.pyc,*.class
set wildignore+=.hg,.git,.svn                    " Version control
set wildignore+=*.aux,*.out,*.toc                " LaTeX intermediate files
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg   " binary images
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
set wildignore+=*.spl                            " compiled spelling word lists
set wildignore+=*.sw?                            " Vim swap files
set wildignore+=*.DS_Store                       " OSX bullshit
set wildignore+=*.luac                           " Lua byte code
set wildignore+=migrations                       " Django migrations
set wildignore+=*.pyc                            " Python byte code
set wildignore+=*.orig                           " Merge resolution files

" make complete popupmenu better
set completeopt=longest,menuone

" leader
let maplocalleader = "\\"
let mapleader = ","

" Ag
if executable("ag")
	set grepprg=ag\ --nogroup\ --nocolor\ --ignore-case\ --column
	set grepformat=%f:%l:%c:%m,%f:%l:%m
endif

" maps
nnoremap <leader>b :b <C-d>
nnoremap <leader>g :grep<space>
nnoremap <leader>q :b#<cr>
nnoremap <leader><space> :noh<cr>:call clearmatches()<cr>
nnoremap <leader>e :e ./**/

" nice search in buffer
" (example use :14 to select from menu)
nnoremap <leader>S :g//#<left><left>

" playing with Python syntax highlighting
highlight pythonString cterm=NONE ctermbg=NONE ctermfg=65
highlight pythonQuotes cterm=NONE ctermbg=NONE ctermfg=65
highlight pythonBuiltin cterm=NONE ctermbg=NONE ctermfg=32

" ghetto linting
autocmd FileType python setlocal makeprg=flake8
" this makes the quickfix window open automatically after
autocmd QuickFixCmdPost [^l]* cwindow


" nice statusline
"set statusline=%-20F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v]
"set statusline+=%{gutentags#statusline()}
set statusline=%<\ %f\ %m%r%y%w%=\ L:\ \%l\/\%L\ C:\ \%c\