Created
December 29, 2014 05:52
-
-
Save xanderdunn/fd58639734b1a69dbc65 to your computer and use it in GitHub Desktop.
My ~/.nvimrc
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
set clipboard=unnamed | |
set nocompatible " Use vim settings | |
set modelines=0 " Prevent security hole | |
" All tabs are 4 spaces | |
set expandtab | |
set tabstop=4 | |
set shiftwidth=4 | |
set softtabstop=4 | |
" General Settings | |
set visualbell " No bell | |
set t_vb= " No bell | |
set encoding=utf-8 | |
set scrolloff=3 " Allow text to scroll to center view when it's at the bottom of the document | |
set autoindent | |
set showmode | |
set showcmd " Show incomplete commands | |
set hidden " Open new file without being forced so save open buffer | |
set wildmenu | |
set wildmode=list:longest | |
set wildignore=*.swp,*.bak,*.pyc,*.class,*.o,*.obj,.DS_Store,*.jpg,*.d,*.dia,*.imageset,*.png,*.ai,*/Pods/*,*.xcworkspace,*.xcodeproj,*/tmp/*,*.lock,*/xcodebuild/* " Ignore file types in autocomplete | |
" set cursorline | |
" set ttyfast | |
set ruler " Show cursor position info in a line at the bottom | |
set backspace=indent,eol,start " Allow backspacing over everything in insert mode | |
"set laststatus=2 " Show a black band at the bottom with ? | |
"set relativenumber " Show relative line numbers rather than absolute | |
set undofile " Preserve undo information between sessions | |
"au FocusLost * :wa " Save the current buffer when the window is no longer in focus | |
let mapleader = "," " Set <leader> to , | |
set textwidth=0 | |
set formatoptions-=tc | |
" Custom Commands | |
" Clean up all trailing whitespace in the file | |
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR> | |
" Open .vimrc in a vertically split window | |
nnoremap <leader>ev <C-w><C-v><C-l>:e $MYVIMRC<cr> | |
" Source the .vimrc file | |
nmap <silent> <leader>sv :so $MYVIMRC<CR> | |
" Open a new vertical split window and switch to it | |
nnoremap <leader>w <C-w>v<C-w>l | |
" Show all yanks with YankRing | |
nnoremap <silent> <F3> :YRShow<cr> | |
inoremap <silent> <F3> <ESC>:YRShow<cr> | |
set pastetoggle=<F2> " Toggle paste mode to disable syntax changes to content that's pasted iv | |
" Easy window navigation | |
map <C-h> <C-w>h | |
map <C-j> <C-w>j | |
map <C-k> <C-w>k | |
map <C-l> <C-w>l | |
" Go backward in jumplist | |
nnoremap <C-0> <C-i> | |
" Save a file that requires sudo privelage after you opened it | |
cmap w!! w !sudo tee % >/dev/null | |
" Search Settings | |
nnoremap / /\v | |
vnoremap / /\v | |
set ignorecase " Ignore case if all character in search string are lowercase | |
set smartcase " Case-sensitive search if at least one character is uppercase | |
set gdefault " By default, replace all occurences of a word on the line | |
" Highlight search results while typing | |
set incsearch | |
set showmatch | |
set hlsearch | |
" Remove search highlights with <leader><space> | |
nnoremap <leader><space> :noh<cr> | |
" Tab key matches bracket pairs | |
nnoremap <tab> % | |
vnoremap <tab> % | |
" Use semi-colon as colon key | |
nnoremap ; : | |
" vim training | |
nnoremap <up> <nop> | |
nnoremap <down> <nop> | |
nnoremap <left> <nop> | |
nnoremap <right> <nop> | |
inoremap <up> <nop> | |
inoremap <down> <nop> | |
inoremap <left> <nop> | |
inoremap <right> <nop> | |
nnoremap j gj | |
nnoremap k gk | |
" Vundle | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
filetype off | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
Plugin 'gmarik/Vundle.vim' " vim package manager | |
Plugin 'tpope/vim-fugitive' " git wrapper | |
Plugin 'kovisoft/slimv' " LISP | |
Plugin 'scrooloose/nerdcommenter' " Commenting shortcuts | |
Plugin 'mileszs/ack.vim' " ack support for searching files | |
Plugin 'MarcWeber/vim-addon-mw-utils' | |
Plugin 'tomtom/tlib_vim' | |
Plugin 'honza/vim-snippets' " default snippets for ultisnips | |
Plugin 'kien/rainbow_parentheses.vim' " parentheses pretty highlighting | |
Plugin 'tpope/vim-unimpaired' " Keyboard shortcut to jump to next git conflict | |
"Plugin 'vim-scripts/vim-auto-save' " Auto save | |
Plugin 'nathanaelkane/vim-indent-guides' " Pretty lines to follow the begnning and end of code blocks | |
Plugin 'altercation/vim-colors-solarized' " Color scheme | |
Plugin 'Raimondi/delimitMate' " Automatically insert closing brackets | |
"Plugin 'jaxbot/semantic-highlight.vim' " Highlight each variable a different color | |
" Plugin 'YankRing.vim' " Yank history | |
" Plugins to consider | |
" NerdTree = File browser | |
" vim-surround = Easily delete and add surroundings like quotes and brackets | |
" vim-repeat = a . function that repeats an entire macro rather than the last | |
" command only | |
" Xcode functionality | |
Plugin 'kien/ctrlp.vim' " quick search bar | |
Plugin 'b4winckler/vim-objc' " Better Obj-C indenting | |
Plugin 'SirVer/ultisnips' " code snippets | |
Plugin 'eraserhd/vim-ios' " .h <-> .m switching and project build | |
Plugin 'Valloric/YouCompleteMe' " code completion | |
Plugin 'kentaroi/cocoa.vim' | |
"Plugin 'zenangst/cocoa.vim' " method list, documentation | |
call vundle#end() | |
filetype plugin indent on | |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" :PluginList - lists configured plugins | |
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate | |
" :PluginSearch foo - searches for foo; append `!` to refresh local cache | |
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal | |
" see :h vundle for more details or wiki for FAQ | |
" fugitive | |
set statusline+=%{fugitive#statusline()} | |
" YouCompleteMe | |
let g:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py' | |
nnoremap <leader>d :YcmCompleter GoToDefinition <cr> | |
nnoremap <leader>s :YcmCompleter GoToDeclaration <cr> | |
:command! Errors :YcmDiag | |
let g:ycm_confirm_extra_conf = 0 | |
"function! SetErrorsAndWarnings() " Only show the errors and warnings gutter if it's a file that I wrote | |
" let currentFilePath = expand('%:p') | |
" if currentFilePath =~ '/Dropbox/dev/' | |
" let g:ycm_enable_diagnostic_signs = 1 | |
" elseif currentFilePath =~ '.' | |
" let g:ycm_enable_diagnostic_signs = 0 | |
" endif | |
"endfunction | |
"autocmd BufEnter * call SetErrorsAndWarnings() | |
" vim-auto-save | |
let g:auto_save = 1 " enable AutoSave on Vim startup | |
let g:auto_save_in_insert_mode = 0 " do not save while in insert mode | |
let g:auto_save_silent = 1 " do not display the auto-save notification | |
" Command-T | |
let g:CommandTWildIgnore=&wildignore . ",*~" | |
" Always load Rainbow Parentheses | |
au VimEnter * RainbowParenthesesToggle | |
au Syntax * RainbowParenthesesLoadRound | |
au Syntax * RainbowParenthesesLoadSquare | |
au Syntax * RainbowParenthesesLoadBraces | |
let g:lisp_rainbow=1 "Lisp rainbow parentheses | |
" Ack | |
:command! -nargs=+ S :Ack! "<args>" | |
:command! -nargs=+ SC :Ack! --cpp "<args>" | |
" UltiSnips | |
"The below key bindings are compatible with YouCompletMe integration | |
let g:UltiSnipsExpandTrigger="<c-j>" | |
let g:UltiSnipsJumpForwardTrigger="<c-j>" | |
let g:UltiSnipsJumpBackwardTrigger="<c-k>" | |
"let g:UltiSnipsExpandTrigger="<tab>" | |
"let g:UltiSnipsJumpForwardTrigger="<c-b>" | |
"let g:UltiSnipsJumpBackwardTrigger="<c-z>" | |
" Auto-reload vimrc | |
augroup reload_vimrc " { | |
autocmd! | |
autocmd BufWritePost $MYVIMRC source $MYVIMRC | |
augroup END " } | |
" History | |
if has("vms") | |
set nobackup " do not keep a backup file, use versions instead | |
else | |
set backup " keep a backup file | |
endif | |
set history=500 " keep 50 lines of command line history | |
set undolevels=500 | |
set incsearch " do incremental searching | |
" Don't use Ex mode, use Q for formatting | |
map Q gq | |
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo, | |
" so that you can undo CTRL-U after inserting a line break. | |
inoremap <C-U> <C-G>u<C-U> | |
" In many terminal emulators the mouse works just fine, thus enable it. | |
if has('mouse') | |
set mouse=a | |
endif | |
syntax enable " Enable syntax highlighting | |
set t_Co=256 " Enable 256 colors in terminal | |
if has ("gui_running") | |
set background=dark | |
colorscheme solarized | |
set guicursor+=n-v-c:blinkon0 " Disable cursor blinking | |
endif | |
" Only do this part when compiled with support for autocommands. | |
if has("autocmd") | |
" Enable file type detection. | |
" Use the default filetype settings, so that mail gets 'tw' set to 72, | |
" 'cindent' is on in C files, etc. | |
" Also load indent files, to automatically do language-dependent indenting. | |
filetype plugin indent on | |
" Put these in an autocmd group, so that we can delete them easily. | |
augroup vimrcEx | |
au! | |
" For all text files set 'textwidth' to 78 characters. | |
" autocmd FileType text setlocal textwidth=78 | |
" When editing a file, always jump to the last known cursor position. | |
" Don't do it when the position is invalid or when inside an event handler | |
" (happens when dropping a file on gvim). | |
" Also don't do it when the mark is in the first line, that is the default | |
" position when opening a file. | |
autocmd BufReadPost * | |
\ if line("'\"") > 1 && line("'\"") <= line("$") | | |
\ exe "normal! g`\"" | | |
\ endif | |
augroup END | |
else | |
endif " has("autocmd") | |
" Convenient command to see the difference between the current buffer and the | |
" file it was loaded from, thus the changes you made. | |
" Only define it when not defined already. | |
if !exists(":DiffOrig") | |
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis | |
\ | wincmd p | diffthis | |
endif | |
" Custom Autocommands | |
" :help autocmd-events | |
" Set the title of the Terminal to the currently open file | |
function! SetTerminalTitle() | |
let titleString = expand('%:t') | |
if len(titleString) > 0 | |
let &titlestring = expand('%:t') | |
set title | |
endif | |
endfunction | |
autocmd BufEnter * call SetTerminalTitle() | |
" Use bash as the the external shell | |
set shell=bash\ --login | |
set shellcmdflag=-ic " :! commands will now occur in interactive shell (bash) | |
" TODO | |
" - How does YouCompleteMe handle using the same code to build for different | |
" architectures? Different OSes. | |
" - Get a better color scheme | |
" - Automate the creation of the -I and -F strings for the YouCompleteMe config file for semantic ObjC completion | |
" ack --cc '\ ((?:\-I|\-F)[0-9a-zA-Z_\/.-^(DerivedData)]+)' --output ''\''$1'\'',' ~/Desktop/build.txt | sort -u | |
" gfind /Users/admin/Dropbox/dev/objc/memories/LearningApp -name *.h -o -name *.m -printf ''\''-I%h'\'',\n' | sort -u | |
" xcodebuild -workspace LearningApp.xcworkspace -scheme Memories-iOS -configuration Debug > ~/Desktop/build.txt | |
" - A command to copy the name of a selector without the type information, | |
" such as initWithController:userInfo: | |
" - A command that automatically starts lldb, attaches to the process, and | |
" sets a breakpoint on the cursor's current file and line. | |
" - Create a command that runs the clang static analyzer on the current | |
" project | |
" - Get your vim to look like this: http://brooks.io/syntax-highlight/v2/ | |
" - indention markers | |
" - semantic highilghting | |
" - light dark color scheme with muted colors | |
" - comment highlight blocks | |
" - Improve cocoa.vim so it doesn't show { at the end of each method in the ListMethods command | |
" - Fix documentation search for cocoa.vim | |
" - When pressing 0, go to the front of the line excluding whitespace. Go to | |
" front of whitespace only after pressing it twice | |
" - Don't show the YouCompleteMe error bar on files that I don't edit | |
" - Paredit | |
" - Jump to next empty line | |
" - Jump whole page up/down | |
" - Search for and jump to the definition of the method under the cursor using | |
" ack. Show results if there is more than one. Jump to first if there is | |
" only one. | |
" - Delete current method | |
" - How does vim decide with :set filetype? is? Why is it set differently for | |
" .m and .h files? objcpp does not seem right for my .h files. | |
" Show/hide line numbers | |
nnoremap <leader>n :set number<cr> | |
nnoremap <leader>nn :set nonumber<cr> | |
nnoremap <leader>m :set relativenumber<cr> | |
nnoremap <leader>mm :set norelativenumber<cr> | |
" Cool ideas to show relative or absolute line numbers depending on current use | |
":au FocusLost * :set number | |
":au FocusGained * :set relativenumber | |
"autocmd InsertEnter * :set number | |
"autocmd InsertLeave * :set relativenumber | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment