Created
April 30, 2019 11:47
-
-
Save samwdp/30f93dc181702bb52a06156fffe8c9c4 to your computer and use it in GitHub Desktop.
vimrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let mapleader ="," | |
| if ! filereadable(expand('~/AppData/Local/nvim/autoload/plug.vim')) | |
| echo "Downloading junegunn/vim-plug to manage plugins..." | |
| silent !mkdir -p ~/AppData/Local/nvim/autoload/ | |
| silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/AppData/Local/nvim/autoload/plug.vim | |
| endif | |
| call plug#begin('~/AppData/Local/nvim/plugged') | |
| Plug 'tpope/vim-surround' | |
| Plug 'scrooloose/nerdtree' | |
| Plug 'junegunn/goyo.vim' | |
| Plug 'PotatoesMaster/i3-vim-syntax' | |
| Plug 'jreybert/vimagit' | |
| Plug 'LukeSmithxyz/vimling' | |
| Plug 'vimwiki/vimwiki' | |
| Plug 'tpope/vim-commentary' | |
| Plug 'vifm/vifm.vim' | |
| Plug 'OmniSharp/omnisharp-vim' | |
| Plug 'SirVer/ultisnips' | |
| Plug 'honza/vim-snippets' | |
| Plug 'prabirshrestha/asyncomplete.vim' | |
| Plug 'prabirshrestha/async.vim' | |
| Plug 'vim-airline/vim-airline' | |
| Plug 'prabirshrestha/asyncomplete.vim' | |
| Plug 'ctrlpvim/ctrlp.vim' | |
| Plug 'w0rp/ale' | |
| " Track the engine. | |
| Plug 'SirVer/ultisnips' | |
| " Snippets are separated from the engine. Add this if you want them: | |
| Plug 'honza/vim-snippets' | |
| call plug#end() | |
| set bg=light | |
| set go=a | |
| set mouse=a | |
| set nohlsearch | |
| set clipboard=unnamedplus | |
| " Some basics: | |
| nnoremap c "_c | |
| set nocompatible | |
| filetype plugin on | |
| syntax on | |
| set encoding=utf-8 | |
| set number relativenumber | |
| " Enable autocompletion: | |
| set wildmode=longest,list,full | |
| " Disables automatic commenting on newline: | |
| autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o | |
| " Goyo plugin makes text more readable when writing prose: | |
| map <leader>f :Goyo \| set bg=light \| set linebreak<CR> | |
| " Spell-check set to <leader>o, 'o' for 'orthography': | |
| map <leader>o :setlocal spell! spelllang=en_us<CR> | |
| " Splits open at the bottom and right, which is non-retarded, unlike vim defaults. | |
| set splitbelow splitright | |
| " Nerd tree | |
| map <leader>n :NERDTreeToggle<CR> | |
| autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | |
| " vimling: | |
| nm <leader>d :call ToggleDeadKeys()<CR> | |
| imap <leader>d <esc>:call ToggleDeadKeys()<CR>a | |
| nm <leader>i :call ToggleIPA()<CR> | |
| imap <leader>i <esc>:call ToggleIPA()<CR>a | |
| nm <leader>q :call ToggleProse()<CR> | |
| " Shortcutting split navigation, saving a keypress: | |
| map <C-h> <C-w>h | |
| map <C-j> <C-w>j | |
| map <C-k> <C-w>k | |
| map <C-l> <C-w>l | |
| " Check file in shellcheck: | |
| map <leader>s :!clear && shellcheck %<CR> | |
| " Open my bibliography file in split | |
| map <leader>b :vsp<space>$BIB<CR> | |
| map <leader>r :vsp<space>$REFER<CR> | |
| " Replace all is aliased to S. | |
| nnoremap S :%s//g<Left><Left> | |
| " Compile document, be it groff/LaTeX/markdown/etc. | |
| map <leader>c :w! \| !compiler <c-r>%<CR> | |
| " Open corresponding .pdf/.html or preview | |
| map <leader>p :!opout <c-r>%<CR><CR> | |
| " Runs a script that cleans out tex build files whenever I close out of a .tex file. | |
| autocmd VimLeave *.tex !texclear % | |
| " Ensure files are read as what I want: | |
| let g:vimwiki_ext2syntax = {'.Rmd': 'markdown', '.rmd': 'markdown','.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'} | |
| let g:vimwiki_list = [{'path': '~/vimwiki', 'syntax': 'markdown', 'ext': '.md'}] | |
| autocmd BufRead,BufNewFile /tmp/calcurse*,~/.calcurse/notes/* set filetype=markdown | |
| autocmd BufRead,BufNewFile *.ms,*.me,*.mom,*.man set filetype=groff | |
| autocmd BufRead,BufNewFile *.tex set filetype=tex | |
| " Copy selected text to system clipboard (requires gvim/nvim/vim-x11 installed): | |
| vnoremap <C-c> "+y | |
| map <C-p> "+P | |
| " Enable Goyo by default for mutt writting | |
| " Goyo's width will be the line limit in mutt. | |
| autocmd BufRead,BufNewFile /tmp/neomutt* let g:goyo_width=80 | |
| autocmd BufRead,BufNewFile /tmp/neomutt* :Goyo \| set bg=light | |
| " Automatically deletes all trailing whitespace on save. | |
| autocmd BufWritePre * %s/\s\+$//e | |
| " When shortcut files are updated, renew bash and vifm configs with new material: | |
| " Enable Goyo by default for mutt writting | |
| " Goyo's width will be the line limit in mutt. | |
| autocmd BufRead,BufNewFile /tmp/neomutt* let g:goyo_width=80 | |
| autocmd BufRead,BufNewFile /tmp/neomutt* :Goyo \| set bg=light | |
| " Automatically deletes all trailing whitespace on save. | |
| autocmd BufWritePre * %s/\s\+$//e | |
| " When shortcut files are updated, renew bash and vifm configs with new material: | |
| autocmd BufWritePost ~/.config/bmdirs,~/.config/bmfiles !shortcuts | |
| " Run xrdb whenever Xdefaults or Xresources are updated. | |
| autocmd BufWritePost *Xresources,*Xdefaults !xrdb % | |
| " Navigating with guides | |
| inoremap <leader><leader> <Esc>/<++><Enter>"_c4l | |
| vnoremap <leader><leader> <Esc>/<++><Enter>"_c4l | |
| map <leader><leader> <Esc>/<++><Enter>"_c4l | |
| """LATEX | |
| " Word count: | |
| autocmd FileType tex map <leader>w :w !detex \| wc -w<CR> | |
| " Code snippets | |
| autocmd FileType tex inoremap ,fr \begin{frame}<Enter>\frametitle{}<Enter><Enter><++><Enter><Enter>\end{frame}<Enter><Enter><++><Esc>6kf}i | |
| autocmd FileType tex inoremap ,fi \begin{fitch}<Enter><Enter>\end{fitch}<Enter><Enter><++><Esc>3kA | |
| autocmd FileType tex inoremap ,exe \begin{exe}<Enter>\ex<Space><Enter>\end{exe}<Enter><Enter><++><Esc>3kA | |
| autocmd FileType tex inoremap ,em \emph{}<++><Esc>T{i | |
| autocmd FileType tex inoremap ,bf \textbf{}<++><Esc>T{i | |
| autocmd FileType tex vnoremap , <ESC>`<i\{<ESC>`>2la}<ESC>?\\{<Enter>a | |
| autocmd FileType tex inoremap ,it \textit{}<++><Esc>T{i | |
| autocmd FileType tex inoremap ,ct \textcite{}<++><Esc>T{i | |
| autocmd FileType tex inoremap ,cp \parencite{}<++><Esc>T{i | |
| autocmd FileType tex inoremap ,glos {\gll<Space><++><Space>\\<Enter><++><Space>\\<Enter>\trans{``<++>''}}<Esc>2k2bcw | |
| autocmd FileType tex inoremap ,x \begin{xlist}<Enter>\ex<Space><Enter>\end{xlist}<Esc>kA<Space> | |
| autocmd FileType tex inoremap ,ol \begin{enumerate}<Enter><Enter>\end{enumerate}<Enter><Enter><++><Esc>3kA\item<Space> | |
| autocmd FileType tex inoremap ,ul \begin{itemize}<Enter><Enter>\end{itemize}<Enter><Enter><++><Esc>3kA\item<Space> | |
| autocmd FileType tex inoremap ,li <Enter>\item<Space> | |
| autocmd FileType tex inoremap ,ref \ref{}<Space><++><Esc>T{i | |
| autocmd FileType tex inoremap ,tab \begin{tabular}<Enter><++><Enter>\end{tabular}<Enter><Enter><++><Esc>4kA{}<Esc>i | |
| autocmd FileType tex inoremap ,ot \begin{tableau}<Enter>\inp{<++>}<Tab>\const{<++>}<Tab><++><Enter><++><Enter>\end{tableau}<Enter><Enter><++><Esc>5kA{}<Esc>i | |
| autocmd FileType tex inoremap ,can \cand{}<Tab><++><Esc>T{i | |
| autocmd FileType tex inoremap ,con \const{}<Tab><++><Esc>T{i | |
| autocmd FileType tex inoremap ,v \vio{}<Tab><++><Esc>T{i | |
| autocmd FileType tex inoremap ,a \href{}{<++>}<Space><++><Esc>2T{i | |
| autocmd FileType tex inoremap ,sc \textsc{}<Space><++><Esc>T{i | |
| autocmd FileType tex inoremap ,chap \chapter{}<Enter><Enter><++><Esc>2kf}i | |
| autocmd FileType tex inoremap ,sec \section{}<Enter><Enter><++><Esc>2kf}i | |
| autocmd FileType tex inoremap ,ssec \subsection{}<Enter><Enter><++><Esc>2kf}i | |
| autocmd FileType tex inoremap ,sssec \subsubsection{}<Enter><Enter><++><Esc>2kf}i | |
| autocmd FileType tex inoremap ,st <Esc>F{i*<Esc>f}i | |
| autocmd FileType tex inoremap ,beg \begin{DELRN}<Enter><++><Enter>\end{DELRN}<Enter><Enter><++><Esc>4k0fR:MultipleCursorsFind<Space>DELRN<Enter>c | |
| autocmd FileType tex inoremap ,up <Esc>/usepackage<Enter>o\usepackage{}<Esc>i | |
| autocmd FileType tex nnoremap ,up /usepackage<Enter>o\usepackage{}<Esc>i | |
| autocmd FileType tex inoremap ,tt \texttt{}<Space><++><Esc>T{i | |
| autocmd FileType tex inoremap ,bt {\blindtext} | |
| autocmd FileType tex inoremap ,nu $\varnothing$ | |
| autocmd FileType tex inoremap ,col \begin{columns}[T]<Enter>\begin{column}{.5\textwidth}<Enter><Enter>\end{column}<Enter>\begin{column}{.5\textwidth}<Enter><++><Enter>\end{column}<Enter>\end{columns}<Esc>5kA | |
| autocmd FileType tex inoremap ,rn (\ref{})<++><Esc>F}i | |
| """HTML | |
| autocmd FileType html inoremap ,b <b></b><Space><++><Esc>FbT>i | |
| autocmd FileType html inoremap ,it <em></em><Space><++><Esc>FeT>i | |
| autocmd FileType html inoremap ,1 <h1></h1><Enter><Enter><++><Esc>2kf<i | |
| autocmd FileType html inoremap ,2 <h2></h2><Enter><Enter><++><Esc>2kf<i | |
| autocmd FileType html inoremap ,3 <h3></h3><Enter><Enter><++><Esc>2kf<i | |
| autocmd FileType html inoremap ,p <p></p><Enter><Enter><++><Esc>02kf>a | |
| autocmd FileType html inoremap ,a <a<Space>href=""><++></a><Space><++><Esc>14hi | |
| autocmd FileType html inoremap ,e <a<Space>target="_blank"<Space>href=""><++></a><Space><++><Esc>14hi | |
| autocmd FileType html inoremap ,ul <ul><Enter><li></li><Enter></ul><Enter><Enter><++><Esc>03kf<i | |
| autocmd FileType html inoremap ,li <Esc>o<li></li><Esc>F>a | |
| autocmd FileType html inoremap ,ol <ol><Enter><li></li><Enter></ol><Enter><Enter><++><Esc>03kf<i | |
| autocmd FileType html inoremap ,im <img src="" alt="<++>"><++><esc>Fcf"a | |
| autocmd FileType html inoremap ,td <td></td><++><Esc>Fdcit | |
| autocmd FileType html inoremap ,tr <tr></tr><Enter><++><Esc>kf<i | |
| autocmd FileType html inoremap ,th <th></th><++><Esc>Fhcit | |
| autocmd FileType html inoremap ,tab <table><Enter></table><Esc>O | |
| autocmd FileType html inoremap ,gr <font color="green"></font><Esc>F>a | |
| autocmd FileType html inoremap ,rd <font color="red"></font><Esc>F>a | |
| autocmd FileType html inoremap ,yl <font color="yellow"></font><Esc>F>a | |
| autocmd FileType html inoremap ,dt <dt></dt><Enter><dd><++></dd><Enter><++><esc>2kcit | |
| autocmd FileType html inoremap ,dl <dl><Enter><Enter></dl><enter><enter><++><esc>3kcc | |
| autocmd FileType html inoremap &<space> &<space> | |
| autocmd FileType html inoremap á á | |
| autocmd FileType html inoremap é é | |
| autocmd FileType html inoremap í í | |
| autocmd FileType html inoremap ó ó | |
| autocmd FileType html inoremap ú ú | |
| autocmd FileType html inoremap ä ä | |
| autocmd FileType html inoremap ë ë | |
| autocmd FileType html inoremap ï ï | |
| autocmd FileType html inoremap ö ö | |
| autocmd FileType html inoremap ü ü | |
| autocmd FileType html inoremap ã ã | |
| autocmd FileType html inoremap ẽ &etilde; | |
| autocmd FileType html inoremap ĩ ĩ | |
| autocmd FileType html inoremap õ õ | |
| autocmd FileType html inoremap ũ ũ | |
| autocmd FileType html inoremap ñ ñ | |
| autocmd FileType html inoremap à à | |
| autocmd FileType html inoremap è è | |
| autocmd FileType html inoremap ì ì | |
| autocmd FileType html inoremap ò ò | |
| autocmd FileType html inoremap ù ù | |
| """.bib | |
| autocmd FileType bib inoremap ,a @article{<Enter>author<Space>=<Space>{<++>},<Enter>year<Space>=<Space>{<++>},<Enter>title<Space>=<Space>{<++>},<Enter>journal<Space>=<Space>{<++>},<Enter>volume<Space>=<Space>{<++>},<Enter>pages<Space>=<Space>{<++>},<Enter>}<Enter><++><Esc>8kA,<Esc>i | |
| autocmd FileType bib inoremap ,b @book{<Enter>author<Space>=<Space>{<++>},<Enter>year<Space>=<Space>{<++>},<Enter>title<Space>=<Space>{<++>},<Enter>publisher<Space>=<Space>{<++>},<Enter>}<Enter><++><Esc>6kA,<Esc>i | |
| autocmd FileType bib inoremap ,c @incollection{<Enter>author<Space>=<Space>{<++>},<Enter>title<Space>=<Space>{<++>},<Enter>booktitle<Space>=<Space>{<++>},<Enter>editor<Space>=<Space>{<++>},<Enter>year<Space>=<Space>{<++>},<Enter>publisher<Space>=<Space>{<++>},<Enter>}<Enter><++><Esc>8kA,<Esc>i | |
| "MARKDOWN | |
| autocmd Filetype markdown,rmd map <leader>w yiWi[<esc>Ea](<esc>pa) | |
| autocmd Filetype markdown,rmd inoremap ,n ---<Enter><Enter> | |
| autocmd Filetype markdown,rmd inoremap ,b ****<++><Esc>F*hi | |
| autocmd Filetype rmd inoremap ,p ```{python}<CR>```<CR><CR><esc>2kO | |
| autocmd Filetype rmd inoremap ,c ```<cr>```<cr><cr><esc>2kO | |
| """.xml | |
| autocmd FileType xml inoremap ,e <item><Enter><title><++></title><Enter><guid<space>isPermaLink="false"><++></guid><Enter><pubDate><Esc>:put<Space>=strftime('%a, %d %b %Y %H:%M:%S %z')<Enter>kJA</pubDate><Enter><link><++></link><Enter><description><![CDATA[<++>]]></description><Enter></item><Esc>?<title><enter>cit | |
| autocmd FileType xml inoremap ,a <a href="<++>"><++></a><++><Esc>F"ci" | |
| " OmniSharp won't work without this setting | |
| filetype plugin on | |
| " Set the type lookup function to use the preview window instead of echoing it | |
| "let g:OmniSharp_typeLookupInPreview = 1 | |
| " Timeout in seconds to wait for a response from the server | |
| let g:OmniSharp_timeout = 5 | |
| " Don't autoselect first omnicomplete option, show options even if there is only | |
| " one (so the preview documentation is accessible). Remove 'preview' if you | |
| " don't want to see any documentation whatsoever. | |
| set completeopt=longest,menuone,preview | |
| " Fetch full documentation during omnicomplete requests. | |
| " There is a performance penalty with this (especially on Mono). | |
| " By default, only Type/Method signatures are fetched. Full documentation can | |
| " still be fetched when you need it with the :OmniSharpDocumentation command. | |
| "let g:omnicomplete_fetch_full_documentation = 1 | |
| " Set desired preview window height for viewing documentation. | |
| " You might also want to look at the echodoc plugin. | |
| set previewheight=5 | |
| " Tell ALE to use OmniSharp for linting C# files, and no other linters. | |
| let g:ale_linters = { 'cs': ['OmniSharp'] } | |
| " Fetch semantic type/interface/identifier names on BufEnter and highlight them | |
| let g:OmniSharp_highlight_types = 1 | |
| augroup omnisharp_commands | |
| autocmd! | |
| " When Syntastic is available but not ALE, automatic syntax check on events | |
| " (TextChanged requires Vim 7.4) | |
| " autocmd BufEnter,TextChanged,InsertLeave *.cs SyntasticCheck | |
| " Show type information automatically when the cursor stops moving | |
| autocmd CursorHold *.cs call OmniSharp#TypeLookupWithoutDocumentation() | |
| " Update the highlighting whenever leaving insert mode | |
| autocmd InsertLeave *.cs call OmniSharp#HighlightBuffer() | |
| " Alternatively, use a mapping to refresh highlighting for the current buffer | |
| autocmd FileType cs nnoremap <buffer> <Leader>th :OmniSharpHighlightTypes<CR> | |
| " The following commands are contextual, based on the cursor position. | |
| autocmd FileType cs nnoremap <buffer> gd :OmniSharpGotoDefinition<CR> | |
| autocmd FileType cs nnoremap <buffer> <Leader>fi :OmniSharpFindImplementations<CR> | |
| autocmd FileType cs nnoremap <buffer> <Leader>fs :OmniSharpFindSymbol<CR> | |
| autocmd FileType cs nnoremap <buffer> <Leader>fu :OmniSharpFindUsages<CR> | |
| " Finds members in the current buffer | |
| autocmd FileType cs nnoremap <buffer> <Leader>fm :OmniSharpFindMembers<CR> | |
| autocmd FileType cs nnoremap <buffer> <Leader>fx :OmniSharpFixUsings<CR> | |
| autocmd FileType cs nnoremap <buffer> <Leader>tt :OmniSharpTypeLookup<CR> | |
| autocmd FileType cs nnoremap <buffer> <Leader>dc :OmniSharpDocumentation<CR> | |
| autocmd FileType cs nnoremap <buffer> <C-\> :OmniSharpSignatureHelp<CR> | |
| autocmd FileType cs inoremap <buffer> <C-\> <C-o>:OmniSharpSignatureHelp<CR> | |
| " Navigate up and down by method/property/field | |
| autocmd FileType cs nnoremap <buffer> <C-k> :OmniSharpNavigateUp<CR> | |
| autocmd FileType cs nnoremap <buffer> <C-j> :OmniSharpNavigateDown<CR> | |
| augroup END | |
| " Contextual code actions (uses fzf, CtrlP or unite.vim when available) | |
| nnoremap <Leader><Space> :OmniSharpGetCodeActions<CR> | |
| " Run code actions with text selected in visual mode to extract method | |
| xnoremap <Leader><Space> :call OmniSharp#GetCodeActions('visual')<CR> | |
| " Rename with dialog | |
| nnoremap <Leader>nm :OmniSharpRename<CR> | |
| nnoremap <F2> :OmniSharpRename<CR> | |
| " Rename without dialog - with cursor on the symbol to rename: `:Rename newname` | |
| command! -nargs=1 Rename :call OmniSharp#RenameTo("<args>") | |
| nnoremap <Leader>cf :OmniSharpCodeFormat<CR> | |
| " Start the omnisharp server for the current solution | |
| nnoremap <Leader>ss :OmniSharpStartServer<CR> | |
| nnoremap <Leader>sp :OmniSharpStopServer<CR> | |
| " Enable snippet completion | |
| " let g:OmniSharp_want_snippet=1 | |
| " Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe. | |
| let g:UltiSnipsExpandTrigger="<tab>" | |
| let g:UltiSnipsJumpForwardTrigger="<c-b>" | |
| let g:UltiSnipsJumpBackwardTrigger="<c-z>" | |
| " If you want :UltiSnipsEdit to split your window. | |
| let g:UltiSnipsEditSplit="vertical" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment