Created
July 19, 2018 06:52
-
-
Save miguelgrinberg/bea208276dbac56a590cd535410bf904 to your computer and use it in GitHub Desktop.
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
" plugins | |
set nocompatible | |
filetype off | |
let need_to_install_plugins=0 | |
if empty(system("grep lazy_load ~/.vim/bundle/vundle/autoload/vundle.vim")) | |
echo "Installing Vundle..." | |
echo "" | |
silent !mkdir -p ~/.vim/bundle | |
silent !rm -rf ~/.vim/bundle/vundle | |
silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle | |
let need_to_install_plugins=1 | |
endif | |
set rtp+=~/.vim/bundle/vundle/ | |
call vundle#begin() | |
Plugin 'gmarik/vundle' | |
Plugin 'ap/vim-buftabline' | |
Plugin 'tpope/vim-fugitive' | |
Plugin 'airblade/vim-gitgutter' | |
Plugin 'zeis/vim-kolor' | |
Plugin 'joshdick/onedark.vim' | |
Plugin 'tpope/vim-surround' | |
Plugin 'ervandew/supertab' | |
Plugin 'tpope/vim-sensible' | |
Plugin 'scrooloose/syntastic' | |
Plugin 'vim-scripts/The-NERD-tree' | |
Plugin 'jistr/vim-nerdtree-tabs' | |
Plugin 'majutsushi/tagbar' | |
Plugin 'lepture/vim-jinja' | |
Plugin 'klen/python-mode' | |
"Plugin 'davidhalter/jedi-vim' | |
Plugin 'vim-scripts/indentpython.vim' | |
Plugin 'craigemery/vim-autotag' | |
call vundle#end() | |
filetype plugin indent on | |
syntax on | |
set modeline | |
set modelines=3 | |
set path+=** | |
if need_to_install_plugins==1 | |
echo "Installing plugins..." | |
silent! PluginInstall | |
echo "Done!" | |
q | |
endif | |
" always show the status bar | |
set laststatus=2 | |
" enable 256 colors | |
set t_Co=256 | |
" turn on line numbering | |
set number | |
" sane text files | |
set fileformat=unix | |
set encoding=utf-8 | |
set fileencoding=utf-8 | |
" sane editing | |
set tabstop=4 | |
set shiftwidth=4 | |
set softtabstop=4 | |
set colorcolumn=80 | |
set viminfo='25,\"50,n~/.viminfo | |
" word movement | |
imap <S-Left> <Esc>bi | |
nmap <S-Left> b | |
imap <S-Right> <Esc><Right>wi | |
nmap <S-Right> w | |
" convert all typed tabs to spaces | |
set expandtab | |
" unindent with shift-tab | |
imap <S-Tab> <Esc><<i | |
nmap <S-tab> << | |
" color scheme | |
syntax on | |
colorscheme onedark | |
filetype on | |
filetype plugin indent on | |
" code folding | |
set foldmethod=indent | |
set foldlevel=99 | |
" wrap toggle | |
setlocal nowrap | |
noremap <silent> <Leader>w :call ToggleWrap()<CR> | |
function ToggleWrap() | |
if &wrap | |
echo "Wrap OFF" | |
setlocal nowrap | |
set virtualedit=all | |
silent! nunmap <buffer> <Up> | |
silent! nunmap <buffer> <Down> | |
silent! nunmap <buffer> <Home> | |
silent! nunmap <buffer> <End> | |
silent! iunmap <buffer> <Up> | |
silent! iunmap <buffer> <Down> | |
silent! iunmap <buffer> <Home> | |
silent! iunmap <buffer> <End> | |
else | |
echo "Wrap ON" | |
setlocal wrap linebreak nolist | |
set virtualedit= | |
setlocal display+=lastline | |
noremap <buffer> <silent> <Up> gk | |
noremap <buffer> <silent> <Down> gj | |
noremap <buffer> <silent> <Home> g<Home> | |
noremap <buffer> <silent> <End> g<End> | |
inoremap <buffer> <silent> <Up> <C-o>gk | |
inoremap <buffer> <silent> <Down> <C-o>gj | |
inoremap <buffer> <silent> <Home> <C-o>g<Home> | |
inoremap <buffer> <silent> <End> <C-o>g<End> | |
endif | |
endfunction | |
" move through split windows | |
nmap <leader><Up> :wincmd k<CR> | |
nmap <leader><Down> :wincmd j<CR> | |
nmap <leader><Left> :wincmd h<CR> | |
nmap <leader><Right> :wincmd l<CR> | |
" move through buffers | |
nmap <leader>[ :bp!<CR> | |
nmap <leader>] :bn!<CR> | |
" close all splits except current one | |
nmap <leader>x :only<CR> | |
" code completion | |
au FileType python set omnifunc=pythoncomplete#Complete | |
let g:SuperTabDefaultCompletionType = "context" | |
let g:SuperTabNoCompleteAfter = ['^', ',', '\s'] | |
set completeopt=menuone,longest,preview | |
" restore place in file from previous session | |
if has("autocmd") | |
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif | |
endif | |
" file browser | |
map <leader>n :NERDTreeTabsToggle<CR> | |
let NERDTreeIgnore=['\.pyc$', '__pycache__', '\.sqlite$', '\.sqlite3$'] | |
" tag list | |
map <leader>t :TagbarToggle<CR> | |
" disable autoindent when pasting text | |
function! WrapForTmux(s) | |
if !exists('$TMUX') | |
return a:s | |
endif | |
let tmux_start = "\<Esc>Ptmux;" | |
let tmux_end = "\<Esc>\\" | |
return tmux_start . substitute(a:s, "\<Esc>", "\<Esc>\<Esc>", 'g') . tmux_end | |
endfunction | |
let &t_SI .= WrapForTmux("\<Esc>[?2004h") | |
let &t_EI .= WrapForTmux("\<Esc>[?2004l") | |
function! XTermPasteBegin() | |
set pastetoggle=<Esc>[201~ | |
set paste | |
return "" | |
endfunction | |
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin() | |
" python 3 mode | |
let g:pymode_python = 'python3' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment