Created
August 1, 2016 22:14
-
-
Save TheDataLeek/e1b6fb09c87a175bbc14e9abf1b90c97 to your computer and use it in GitHub Desktop.
init.vim
This file contains 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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Initialize Vundle | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
set nocompatible | |
filetype off | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.config/nvim/bundle/Vundle.vim | |
call vundle#begin('~/.config/nvim/bundle') | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Setup Plugins | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
Plugin 'VundleVim/Vundle.vim' " Plugin management | |
Plugin 'vim-scripts/spellcheck.vim' " Spellcheck | |
Plugin 'flazz/vim-colorschemes' " Expanded colors | |
Plugin 'godlygeek/tabular' " Formatting and Alignment | |
Plugin 'dhruvasagar/vim-table-mode' " More alignment things | |
Plugin 'gerw/vim-latex-suite' " Latex tools | |
Plugin 'Valloric/YouCompleteMe' " Autocomplete | |
Plugin 'euclio/vim-markdown-composer' " Markdown support | |
Plugin 'itchyny/lightline.vim' " Easy status line | |
Plugin 'tpope/vim-commentary' " Easy commenting stuff out | |
Plugin 'hdima/python-syntax' " Expanded Python syntax | |
Plugin 'majutsushi/tagbar' " Quickly see file object structure | |
Plugin 'tpope/vim-vinegar' " Easy file browsing | |
Plugin 'simnalamburt/vim-mundo' " History | |
Plugin 'jalvesaq/Nvim-R' " Sexy R environment | |
Plugin 'bfredl/nvim-ipy' " Sexy IPython environment | |
Plugin 'xolox/vim-misc' " Misc autoload tools. Needed for easytags | |
Plugin 'xolox/vim-easytags' " Jump to definition | |
Plugin 'mileszs/ack.vim' " Searching | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Finalize Vundle | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
call vundle#end() | |
filetype plugin indent on | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Generic Configuration | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" Leader Keys | |
let mapleader = "," | |
" Line Numbering | |
set relativenumber | |
set number | |
" Textwidth | |
set tw=120 | |
" Set Spelling | |
set spell | |
" Don't wrap text | |
set nowrap | |
" Space at beginning and end | |
" https://www.reddit.com/r/vim/comments/4v07o7/is_there_a_way_to_scroll_intelligently_beyond/ | |
set scrolloff=2 | |
" Set keytimeout | |
" http://www.johnhawthorn.com/2012/09/vi-escape-delays/ | |
set timeoutlen=1000 ttimeoutlen=0 | |
" Set C-d and C-u to move up and down one line at a time | |
" http://vimdoc.sourceforge.net/htmldoc/scroll.html | |
set scroll=1 | |
" Set width of fold column | |
" http://vimdoc.sourceforge.net/htmldoc/fold.html | |
set foldcolumn=1 | |
" Highlight current line | |
set cursorline | |
" Universal Commenting | |
vmap q gc | |
" Prevent python comment unindent | |
" http://stackoverflow.com/questions/2360249/vim-automatically-removes-indentation-on-python-comments | |
:inoremap # X<BS># | |
" Bind semicolon to colon | |
nmap ; : | |
" Align equals signs | |
vmap t :Tabularize /=<Enter> | |
" Set characters for tabs and trailing whitespace | |
set list listchars=tab:▸\ ,trail:⋅,nbsp:⋅ | |
" Easy opening file explorer | |
nmap <leader>m :Lex<Cr> | |
" <F1> Shortcut | |
nmap <leader>1 <F1> | |
" Searching | |
set infercase | |
set hlsearch | |
set incsearch | |
""""""""""""""""""""""""""""""""""""""""" | |
" Shell commands from vim | |
" http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window | |
""""""""""""""""""""""""""""""""""""""""" | |
command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>) | |
function! s:RunShellCommand(cmdline) | |
echo a:cmdline | |
let expanded_cmdline = a:cmdline | |
for part in split(a:cmdline, ' ') | |
if part[0] =~ '\v[%#<]' | |
let expanded_part = fnameescape(expand(part)) | |
let expanded_cmdline = substitute(expanded_cmdline, part, expanded_part, '') | |
endif | |
endfor | |
execute "NeomakeSh ".expanded_cmdline | |
execute "copen" | |
normal <C-w>L | |
1 | |
endfunction | |
""""""""""""""""""""""""""""""""""""""""" | |
" Terminal Config | |
" https://neovim.io/doc/user/nvim_terminal_emulator.html | |
""""""""""""""""""""""""""""""""""""""""" | |
tnoremap <leader><leader> <C-\><C-n> | |
""""""""""""""""""""""""""""""""""""""""" | |
" Coloring Config | |
""""""""""""""""""""""""""""""""""""""""" | |
" Turn on syntax coloring | |
syntax on | |
" Use this colorscheme | |
colorscheme jellybeans | |
" Folded section color | |
hi Folded ctermfg=darkblue ctermbg=gray " Fold colors | |
hi FoldColumn ctermfg=darkblue ctermbg=None " Foldcolumn colors | |
" Setup normal coloring for everything (we want it to be clear) | |
hi Normal guibg=NONE ctermbg=NONE | |
hi NonText ctermbg=None | |
""""""""""""""""""""""""""""""""""""""""" | |
" Arrow Keys | |
""""""""""""""""""""""""""""""""""""""""" | |
nmap <Left> 10<C-w>< | |
nmap <Right> 10<C-w>> | |
vmap <Left> <gv | |
vmap <Right> >gv | |
noremap <Up> 10<C-w>+ | |
noremap <Down> 10<C-w>- | |
""""""""""""""""""""""""""""""""""""""""" | |
" Copy-Paste | |
""""""""""""""""""""""""""""""""""""""""" | |
vmap <C-c> "+y | |
nmap <C-c> "+p | |
""""""""""""""""""""""""""""""""""""""""" | |
" Splits | |
""""""""""""""""""""""""""""""""""""""""" | |
noremap H <C-w>h | |
noremap L <C-w>l | |
noremap J <C-w>j | |
noremap K <C-w>k | |
""""""""""""""""""""""""""""""""""""""""" | |
" Vim Folding | |
""""""""""""""""""""""""""""""""""""""""" | |
au BufWinLeave * silent! mkview | |
au BufWinEnter * silent! loadview | |
noremap <Space> za | |
""""""""""""""""""""""""""""""""""""""""" | |
" Smart tabbing and cases | |
""""""""""""""""""""""""""""""""""""""""" | |
set smartindent | |
set smartcase " capital letters = case sensitive | |
set tabstop=4 | |
set shiftwidth=4 | |
set expandtab | |
""""""""""""""""""""""""""""""""""""""""" | |
" Word Swap | |
" http://stackoverflow.com/questions/3578549/easiest-way-to-swap-occurrences-of-two-strings-in-vim | |
""""""""""""""""""""""""""""""""""""""""" | |
function! Mirror(dict) | |
for [key, value] in items(a:dict) | |
let a:dict[value] = key | |
endfor | |
return a:dict | |
endfunction | |
function! S(number) | |
return submatch(a:number) | |
endfunction | |
function! SwapWords(dict, ...) | |
let words = keys(a:dict) + values(a:dict) | |
let words = map(words, 'escape(v:val, "|")') | |
if(a:0 == 1) | |
let delimiter = a:1 | |
else | |
let delimiter = '/' | |
endif | |
let pattern = '\v(' . join(words, '|') . ')' | |
exe '%s' . delimiter . pattern . delimiter | |
\ . '\=' . string(Mirror(a:dict)) . '[S(0)]' | |
\ . delimiter . 'g' | |
endfunction | |
""""""""""""""""""""""""""""""""""""' | |
" Lightline | |
""""""""""""""""""""""""""""""""""""' | |
let g:lightline = { | |
\ 'colorscheme': 'jellybeans', | |
\ 'active': { | |
\ 'left': [['mode', 'paste'], | |
\ ['filename', 'relativepath', 'modified']], | |
\ 'right': [['lineinfo'], | |
\ ['percent'], | |
\ ['fileformat', 'fileencoding', 'filetype']] | |
\ } | |
\ } | |
" https://github.com/itchyny/lightline.vim/issues/87 | |
function! LLFileName() | |
return expand('%:p:h') | |
endfunction | |
""""""""""""""""""""""""""""""""""""' | |
" Gundo/Mundo | |
""""""""""""""""""""""""""""""""""""' | |
nnoremap <F5> :MundoToggle<CR> | |
set undofile | |
set undodir=~/.config/nvim/undo | |
""""""""""""""""""""""""""""""""""""' | |
" Terminal Configuration | |
""""""""""""""""""""""""""""""""""""' | |
" https://www.reddit.com/r/neovim/comments/32944o/disable_spell_check_in_neovim_terminal/ | |
augroup terminal | |
autocmd TermOpen * setlocal nospell | |
augroup END | |
""""""""""""""""""""""""""""""""""""' | |
" NeoVim R | |
""""""""""""""""""""""""""""""""""""' | |
if has("gui_running") | |
inoremap <C-Space> <C-x><C-o> | |
else | |
inoremap <Nul> <C-x><C-o> | |
endif | |
vmap <Space> <Plug>RDSendSelection | |
nmap <Space> <Plug>RDSendLine | |
""""""""""""""""""""""""""""""""""""' | |
" NeoVim IPython | |
""""""""""""""""""""""""""""""""""""' | |
let g:nvim_ipy_perform_mappings = 0 | |
function Py() | |
exec "IPython" | |
vmap <Space> <Plug>(IPy-Run) | |
nmap <Space> <Plug>(IPy-Run) | |
wincmd H | |
endfunction | |
nmap <F7> :call Py()<cr> | |
nmap <F31> <Plug>(IPy-Interrupt) | |
""""""""""""""""""""""""""""""""""""' | |
" Tagbar - https://github.com/majutsushi/tagbar | |
nmap <F8> :TagbarToggle<CR> | |
""""""""""""""""""""""""""""""""""""' | |
""""""""""""""""""""""""""""""""""""' | |
" Easytags | |
""""""""""""""""""""""""""""""""""""' | |
let g:easytags_async=1 " Async eval | |
let g:easytags_by_filetype='~/.config/nvim/tags' " tags by ft | |
""""""""""""""""""""""""""""""""""""' | |
" Searching... | |
""""""""""""""""""""""""""""""""""""' | |
set grepprg=ag\ --vimgrep\ $* | |
set grepformat=%f:%l:%c:%m | |
if executable('ag') | |
let g:ackprg = 'ag --vimgrep' | |
endif | |
nmap <leader><Space> :Ack |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment