set encoding=utf-8 "vim-plug installation if empty(glob('~/.vim/autoload/plug.vim')) silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim autocmd VimEnter * PlugInstall --sync | source $MYVIMRC endif set nocompatible " be iMproved, required call plug#begin('~/.vim/bundle') Plug 'airblade/vim-gitgutter' Plug 'artur-shaik/vim-javacomplete2' Plug 'chauncey-garrett/vim-tasklist' Plug 'ctrlpvim/ctrlp.vim' Plug 'davidhalter/jedi-vim' Plug 'dense-analysis/ale' Plug 'ervandew/supertab' Plug 'jiangmiao/auto-pairs' Plug 'junegunn/gv.vim' Plug 'junegunn/vim-peekaboo' Plug 'junegunn/vim-plug' Plug 'keith/swift.vim' Plug 'LaTeX-Box-Team/LaTeX-Box' Plug 'mattn/emmet-vim' Plug 'mattn/webapi-vim' Plug 'posva/vim-vue' Plug 'scrooloose/nerdtree' Plug 'sheerun/vim-polyglot' Plug 'tpope/vim-fugitive' Plug 'tpope/vim-surround' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'Yilin-Yang/vim-markbar' call plug#end() " Leader let mapleader = "," set backspace=2 " Backspace deletes like most programs in insert mode set nobackup set nowritebackup set noswapfile " http://robots.thoughtbot.com/post/18739402579/global-gitignore#comment-458413287 set history=50 set ruler " show the cursor position all the time set showcmd " display incomplete commands set incsearch " do incremental searching set laststatus=2 " Always display the status line set autowrite " Automatically :write before running commands set modelines=0 " Disable modelines as a security precaution set nomodeline set cursorline " Highlight the full line the cursor is in " Switch syntax highlighting on, when the terminal has colors " Also switch on highlighting the last used search pattern. if (&t_Co > 2 || has("gui_running")) && !exists("syntax_on") syntax on endif if filereadable(expand("~/.vimrc.bundles")) source ~/.vimrc.bundles endif " Load matchit.vim, but only if the user hasn't installed a newer version. if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# '' runtime! macros/matchit.vim endif augroup vimrcEx autocmd! " " When editing a file, always jump to the last known cursor position. " " Don't do it for commit messages, when the position is invalid, or when " " inside an event handler (happens when dropping a file on gvim). autocmd BufReadPost * \ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif " Set syntax highlighting for specific file types autocmd BufRead,BufNewFile *.md set filetype=markdown autocmd BufRead,BufNewFile .{jscs,jshint,eslint}rc set filetype=json autocmd BufRead,BufNewFile aliases.local,zshrc.local,*/zsh/configs/* set filetype=sh autocmd BufRead,BufNewFile gitconfig.local set filetype=gitconfig autocmd BufRead,BufNewFile tmux.conf.local set filetype=tmux autocmd BufRead,BufNewFile vimrc.local set filetype=vim augroup END " When the type of shell script is /bin/sh, assume a POSIX-compatible " shell for syntax highlighting purposes. "let g:is_posix = 1 " Softtabs, 4 spaces set tabstop=4 set shiftwidth=4 set shiftround set expandtab " Display extra whitespace set list listchars=tab:»·,trail:·,nbsp:· " Use one space, not two, after punctuation. set nojoinspaces " Use The Silver Searcher https://github.com/ggreer/the_silver_searcher "if executable('ag') " " Use Ag over Grep " set grepprg=ag\ --nogroup\ --nocolor " " Use ag in fzf for listing files. Lightning fast and respects .gitignore " let $FZF_DEFAULT_COMMAND = 'ag --literal --files-with-matches --nocolor --hidden -g ""' " if !exists(":Ag") " command -nargs=+ -complete=file -bar Ag silent! grep! |cwindow|redraw! " nnoremap \ :Ag " endif "endif " Make it obvious where 80 characters is autocmd FileType python setlocal textwidth=80 colorcolumn=+1 " Numbers set number set numberwidth=5 " Autocomplete menu for command mode set wildmenu set wildmode=longest:full,full " Open new split panes to right and bottom, which feels more natural set splitbelow set splitright " Quicker window movement nnoremap j nnoremap k nnoremap h nnoremap l " Autocomplete with dictionary words when spell check is on set complete+=kspell "Autocompletion syntax: set omnifunc=syntaxcomplete#Complete " Local config if filereadable($HOME . "/.vimrc.local") source ~/.vimrc.local endif " Relative line numbers, but real line number for current line set number relativenumber set nu rnu " Keep 8 rows above and below the kk set scrolloff=8 " Jump to wrapped line instead of next real line. nnoremap j gj nnoremap k gk " Do not cut words when breaking lines. set linebreak " Searching with "/": Ignore case if search term is lower case. set ignorecase set smartcase set hlsearch " Strip trailing whitespaces on each save fun! StripTrailingWhitespaces() let l = line(".") let c = col(".") %s/\s\+$//e call cursor(l, c) endfun autocmd BufWritePre * :call StripTrailingWhitespaces() " Indent and unindent with tab. nnoremap >>_ nnoremap <<_ inoremap vnoremap >gv vnoremap --user) "let $PATH.=':' . $HOME . '/Library/Python/3.7/' " Remap buffer navigation: map gn :bn map gN :bp map gp :bp " indent for curly brackets: "inoremap { {} " Toggle through splits: nnoremap w w nnoremap W W " Emmet let g:user_emmet_leader_key=',' let g:user_emmet_settings = webapi#json#decode(join(readfile(expand('~/.vim/customizations/vim-emmet-mysnippets.json')), "\n")) " jedi-vim: let g:jedi#popup_on_dot = 0 " Peekaboo window width let g:peekaboo_window = 'vert bo 65new' " javacomplete2 autocmd FileType java setlocal omnifunc=javacomplete#Complete " tasklist settings let g:tlTokenList = ["FIXME", "TODO", "todo"] let g:tlWindowPosition = 1 "Open window on bottom, 0 would be top let g:tlRememberPosition = 0 map t TaskList " nerdtree settings map :NERDTreeToggle " airline settings let g:airline#extensions#tabline#enabled = 1 " Show buffers as tabs " ale settings let g:ale_linters = {'python': ['flake8', 'mypy', 'pylint', 'prospector']} let g:ale_fixers = {'python': ['isort', 'black'], \'json': ['fixjson'], \'java': ['uncrustify'], \'tex': ['latexindent']} " Install the linter and fixer for a specific language automatically command InstallLinterFixPython python3 import pip; [pip.main(["install", singlepackage, "--user"]) for singlepackage in "flake8 pylint mypy prospector black isort".split(" ")] " colorscheme toggle: function! s:SwitchColorscheme() if g:colors_name == 'darcula' colorscheme default else colorscheme darcula endif endfunction map :call SwitchColorscheme() colorscheme darcula " Highlight whole todo comment, not just the keyword itself: augroup myTodo autocmd! autocmd Syntax * syntax match myTodo /\v\_.<(TODO|FIXME|todo|fixme).*/hs=s+1 containedin=.*Comment augroup END highlight link myTodo Todo " Highlight "self." in different color in python files: augroup python_syntax_extra autocmd! autocmd! Syntax python :syn keyword Keyword self augroup END " Bind ctrl+u to jump list jump (opposite of ctrl+o) nnoremap