Skip to content

Instantly share code, notes, and snippets.

@coffeewasmyidea
Last active July 7, 2017 11:47
Show Gist options
  • Save coffeewasmyidea/250c1ad2aecdfb4ff5a11516cdc771f0 to your computer and use it in GitHub Desktop.
Save coffeewasmyidea/250c1ad2aecdfb4ff5a11516cdc771f0 to your computer and use it in GitHub Desktop.
vim/macvim (solarized dark)
" https://github.com/VundleVim/Vundle.vim
" https://valloric.github.io/YouCompleteMe/
"
let $PATH = '/usr/local/bin:'.$PATH
set nocompatible " be iMproved, required
filetype off " required
if has("multi_byte")
if &termencoding == ""
let &termencoding = &encoding
endif
set encoding=utf-8
setglobal fileencoding=utf-8
"setglobal bomb
set fileencodings=ucs-bom,utf-8,latin1
endif
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'EasyMotion'
Plugin 'scrooloose/syntastic'
Plugin 'flazz/vim-colorschemes'
Plugin 'tpope/vim-fugitive'
Plugin 'nathanaelkane/vim-indent-guides'
Plugin 'Raimondi/delimitMate'
Plugin 'Valloric/YouCompleteMe'
Plugin 'scrooloose/nerdtree'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'elzr/vim-json'
Plugin 'jelera/vim-javascript-syntax'
Plugin 'craigemery/vim-autotag'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'vim-scripts/taglist.vim'
Plugin 'tpope/vim-surround'
" All of your Plugins must be added before the following line
call vundle#end() " required
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
set t_Co=256
syntax on
set backspace=indent,eol,start
set expandtab
set shiftwidth=2
set softtabstop=2
set cursorline
set scrolloff=9
set colorcolumn=80
colorscheme solarized
let g:airline_theme='solarized'
"use alt to move different window
nnoremap ˙ <C-W><C-H>
nnoremap ∆ <C-W><C-J>
nnoremap ˚ <C-W><C-K>
nnoremap ¬ <C-W><C-L>
"allow the window nav to work in insert mode
inoremap ˙ <Esc><C-W><C-H>
inoremap ∆ <Esc><C-W><C-J>
inoremap ˚ <Esc><C-W><C-K>
inoremap ¬ <Esc><C-W><C-L>
"associate the following filetypes
au BufRead,BufNewFile .tern-project setfiletype json
au BufRead,BufNewFile Procfile setfiletype json
au BufRead,BufNewFile Procfile setfiletype json
let g:solarized_hitrail=1
highlight RedundantWhitespace ctermbg=red guibg=red
match RedundantWhitespace /\s\+$\| \+\zs\t/
" if file changes outside of vim, go ahead and update it, like @checkout
set autoread
" stop line wrap/breaks
set nowrap
" change easy motion color so they work better with Solarized
hi link EasyMotionTarget ErrorMsg
hi link EasyMotionShade Comment
set number
" YCM Stuff
" keep logfiles permanently
let g:ycm_server_keep_logfiles = 1
"let g:ycm_server_log_level = 'debug'
let g:ycm_warning_symbol = '..'
let g:ycm_error_symbol = '**'
let g:syntastic_error_symbol = "‡"
let g:syntastic_warning_symbol = "†"
"change error sign color
highlight SyntasticWarningSign ctermfg=yellow guifg=darkyellow
" write YCM error into the console so we can see wtf is going on
let g:ycm_server_use_vim_stdout = 1
let g:ycm_enable_diagnostic_signs = 0
let g:ycm_autoclose_preview_window_after_completion = 1
"Vim color settings for iterm
colorscheme solarized
set background=dark
let g:solarized_visibility = "high"
let g:solarized_contrast = "high"
" Settings for vim-indent-guides
let g:indent_guides_start_level = 5
" let g:indent_guides_guide_size = 1
" let g:indent_guides_auto_colors = 0
" autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=.s:g_blue
" autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=235
let g:indent_guides_color_change_percent = 5
let g:indent_guides_enable_on_vim_startup = 1
"Settings for nerdtree
map <C-n> :NERDTreeToggle<CR>
highlight VertSplit ctermbg=NONE
highlight VertSplit ctermfg=NONE
" let g:nerdtree_tabs_open_on_console_startup=1
" if nerdtree is last buffer, close it
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
let NERDTreeShowBookmarks=0
" resize NERDTree window
let g:NERDTreeWinSize = 28
autocmd vimenter * if !argc() | NERDTree | endif
" Change cursor shape between insert and normal mode in iTerm2.app
if $TERM_PROGRAM =~ "iTerm"
let &t_SI = "\<Esc>]50;CursorShape=1\x7" " Vertical bar in insert mode
let &t_EI = "\<Esc>]50;CursorShape=0\x7" " Block in normal mode
"stop YCM from loading in term because of python crashes during git stuff
" let g:loaded_youcompleteme = 1
endif
" Change the font
set guifont=Ubuntu\ Mono\ derivative\ Powerline:h15
if has("gui_running")
if has("gui_gtk2")
"set guifont=Inconsolata\ 12
elseif has("gui_macvim")
"remove the macvim closefile mapping when hitting cmd w
macmenu &File.Close key=<nop>
set guifont=Ubuntu\ Mono\ derivative\ Powerline:h15
"set guifont=Menlo\ Regular:h12
elseif has("gui_win32")
set guifont=Consolas:h11:cANSI
endif
endif
"some vim-json settings, prevent quotes hiding
"let g:vim_json_syntax_conceal = 0
set backupdir=~/tmp
"fix the fugitive/gitdiff/vimdiff colors
hi! DiffAdd guibg=#003300
hi! DiffChange guibg=#003300
hi! DiffDelete guifg=#330000 guibg=#330000
"hi! DiffText guibg=#990000
" airline options
let g:airline_powerline_fonts = 1
let g:airline_theme = 'solarized'
let g:Powerline_symbols = 'fancy'
set laststatus=2
" unicode symbols
let g:airline#extensions#syntastic#enabled = 0
let g:airline_section_warning = 0
"ex command line mapping for previewMarkdown
command! MarkdownPreview !markdown-preview %:p;
" gutter column color
"highlight SignColumn guibg=Gray ctermbg=Gray
"highlight clear SignColumn
"highlight GitGutterAdd ctermfg=green guifg=darkgreen
"highlight GitGutterChange ctermfg=yellow guifg=darkyellow
"highlight GitGutterDelete ctermfg=red guifg=darkred
"highlight GitGutterChangeDelete ctermfg=yellow guifg=darkyellow
"put swap files in different directory
set backupdir=./.backup,.,~/tmp
set directory=.,./.backup,~/tmp
set swapfile
set dir=./.swp,~/tmp
" vim instant markdown options
" no autostart, manual start via :InstantMarkdownPreview
let g:instant_markdown_autostart = 0
let g:instant_markdown_slow = 1
" general ignore
set wildignore=*.bak,*.jar,*.gif,*.png,*.jpg,*jpeg,*.swf
" eng spelling toggle
nmap <leader>S :set spell!<CR>
set nospell
set timeoutlen=300
" word wrap/ line wrap
set wrap
" hide scroll bars in macvim
set go-=r
set go-=L
" hide toolbar
set go-=T
" hide jsdoc syntax highlighting
" let g:javascript_ignore_javaScriptdoc = 1
" leader s to toggle syntastic jshinter/linter
nmap <leader>c :SyntasticToggleMode<CR>
" remove automatic commenting when moving to next line
au FileType * set fo-=c fo-=r fo-=o
" html 5 tidy
let g:syntastic_html_tidy_exec = 'tidy5'
" :set showbreak=>>>>>>>>>
set breakindent
" need to use bash shell since we are now using zsh
" :set shell=/bin/bash
" vert diff default
set diffopt+=vertical
" keep a longer history
set history=200
" code folding http://unix.stackexchange.com/questions/141097/how-to-enable-and-use-code-folding-in-vim
set foldmethod=manual
set foldnestmax=10
" set nofoldenable
set foldlevel=2
set relativenumber
" relative absolute line number depending on which mode we are in
" set relativenumber
" function to remove "enter to complete" when running vim command
" command! -nargs=1 Silent
" \ | execute ':silent !'.<q-args>
" \ | execute ':redraw!'
" strip whitespaces
function DoStripSpaces()
if !&binary && &filetype != 'diff'
normal mz
normal Hmy
%s/\s\+$//e
normal 'yz<CR>
normal `z
endif
endfunction
" FOR DJANGO
" YouCompleteMe additionals
let g:ycm_use_ultisnips_completer = 1 " Default 1, just ensure
let g:ycm_seed_identifiers_with_syntax = 1 " Completion for programming language's keyword
let g:ycm_complete_in_comments = 1 " Completion in comments
let g:ycm_complete_in_strings = 1 " Completion in string"
" UltiSnips
let g:UltiSnipsExpandTrigger = "<c-j>"
let g:UltiSnipsJumpForwardTrigger = "<c-j>"
let g:UltiSnipsJumpBackwardTrigger = "<c-p>"
let g:UltiSnipsListSnippets = "<c-k>" "List possible snippets based on current file"
" Syntastic
let g:last_relative_dir = ''
nnoremap \1 :call RelatedFile ("models.py")<cr>
nnoremap \2 :call RelatedFile ("views.py")<cr>
nnoremap \3 :call RelatedFile ("urls.py")<cr>
nnoremap \4 :call RelatedFile ("admin.py")<cr>
nnoremap \5 :call RelatedFile ("tests.py")<cr>
nnoremap \6 :call RelatedFile ( "templates/" )<cr>
nnoremap \7 :call RelatedFile ( "templatetags/" )<cr>
nnoremap \8 :call RelatedFile ( "management/" )<cr>
nnoremap \0 :e settings.py<cr>
nnoremap \9 :e urls.py<cr>
fun! RelatedFile(file)
#This is to check that the directory looks djangoish
if filereadable(expand("%:h"). '/models.py') || isdirectory(expand("%:h") . "/templatetags/")
exec "edit %:h/" . a:file
let g:last_relative_dir = expand("%:h") . '/'
return ''
endif
if g:last_relative_dir != ''
exec "edit " . g:last_relative_dir . a:file
return ''
endif
echo "Cant determine where relative file is : " . a:file
return ''
endfun
fun SetAppDir()
if filereadable(expand("%:h"). '/models.py') || isdirectory(expand("%:h") . "/templatetags/")
let g:last_relative_dir = expand("%:h") . '/'
return ''
endif
endfun
autocmd BufEnter *.py call SetAppDir()
map <C-c> "+y<CR>
nnoremap ¬ <C-W><C-L>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment