Created
January 21, 2020 22:57
-
-
Save rcarmo/7d405d18a0f0860ca7c412eccb291712 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
""" Per-Filetype Scripts | |
" NOTE: These define autocmds, so they should come before any other autocmds. | |
" That way, a later autocmd can override the result of one defined here. | |
filetype on " Enable filetype detection, | |
filetype indent on " use filetype-specific indenting where available, | |
filetype plugin on " also allow for filetype-specific plugins, | |
syntax on " and turn on per-filetype syntax highlighting. | |
set numberwidth=1 " using only 1 column (and 1 space) while possible | |
" Terminal and mouse | |
set mouse=a " enable mouse support | |
set ttymouse=xterm2 " use mouse reporting codes | |
set clipboard=unnamedplus " interface with system clipboard | |
""" vim +'PlugInstall --sync' +qa | |
" Install plugin manager if it's not available | |
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 | |
" Specify a directory for plugins | |
call plug#begin('~/.vim/plugged') | |
" Any valid git URL is allowed | |
Plug 'junegunn/vim-github-dashboard' | |
" On-demand loading | |
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } | |
" Navigation | |
Plug 'kien/ctrlp.vim' | |
let g:ctrlp_match_window_bottom = 0 | |
let g:ctrlp_match_window_reversed = 0 | |
let g:ctrlp_custom_ignore = '\v\~$|\.(o|swp|pyc|wav|mp3|ogg|blend)$|(^|[/\\])\.(hg|git|bzr)($|[/\\])|__init__\.py' | |
let g:ctrlp_working_path_mode = 0 | |
let g:ctrlp_dotfiles = 0 | |
let g:ctrlp_switch_buffer = 0 | |
"--- Git --- | |
Plug 'airblade/vim-gitgutter' | |
Plug 'tpope/vim-fugitive' | |
"--- Clojure --- | |
" nREPL support | |
Plug 'tpope/vim-fireplace', { 'for': 'clojure' } | |
" :Console and :make commands for Leiningen and Boot | |
Plug 'tpope/vim-salve', { 'for': 'clojure' } | |
" :find support across JVM projects | |
Plug 'tpope/vim-classpath', { 'for': ['clojure', 'java'] } | |
" Navigate between related files | |
Plug 'tpope/vim-projectionist', { 'for': 'clojure' } | |
" Run :Make build commands in separate windows or tmux panes | |
Plug 'tpope/vim-dispatch' | |
" LISP-specific cosmetics | |
Plug 'vim-scripts/paredit.vim', { 'for': ['clojure', 'scheme', 'hy'], 'on': 'PareditInitBuffer' } | |
"--- Cosmetics --- | |
Plug 'junegunn/rainbow_parentheses.vim', { 'for': ['clojure', 'lisp', 'scheme', 'hy'], 'on': 'RainbowParentheses' } | |
let g:rainbow#blacklist = [233, 234, '#000000', '#ffffff'] | |
Plug 'vim-airline/vim-airline' | |
Plug 'vim-airline/vim-airline-themes' | |
let g:airline_left_sep = '' | |
let g:airline_right_sep='' | |
let g:airline_enable_syntastic=1 | |
Plug 'altercation/vim-colors-solarized' | |
if has('gui_running') | |
set t_Co=256 | |
set guifont=Menlo:h13 | |
set guioptions-=m " remove menu bar | |
set guioptions-=T " remove toolbar | |
set guioptions-=r " remove right-hand scroll bar | |
set transparency=0 | |
endif | |
try | |
set background=dark | |
colorscheme solarized | |
catch /E185:/ | |
colorscheme default | |
endtry | |
"--- Writing --- | |
Plug 'tpope/vim-markdown' | |
" enable fenced code highlighting | |
let g:markdown_fenced_languages = ['html', 'python', 'bash=sh'] | |
"--- Python --- | |
Plug 'davidhalter/jedi-vim', { 'for': 'python' } | |
"let g:jedi#auto_initialization = 0 " disable initialization | |
autocmd BufRead *.html set filetype=htmldjango " treat html files as django templates | |
autocmd FileType python set omnifunc=pythoncomplete#Complete | |
"--- Golang --- | |
Plug 'fatih/vim-go', { 'for': 'go' } | |
" https://github.com/ervandew/supertab.git | |
" https://github.com/ap/vim-css-color.git | |
" https://github.com/docunext/closetag.vim.git | |
" | |
"--- Syntax Highlighting --- | |
Plug 'scrooloose/syntastic' | |
set statusline+=%#warningmsg# | |
set statusline+=%{SyntasticStatuslineFlag()} | |
set statusline+=%* | |
let g:syntastic_always_populate_loc_list = 1 | |
let g:syntastic_auto_loc_list = 1 | |
let g:syntastic_check_on_open = 0 | |
let g:syntastic_check_on_wq = 0 | |
" Initialize plugin system | |
call plug#end() | |
if exists('g:colors_name') && g:colors_name == 'solarized' | |
set t_Co=256 | |
let g:solarized_termcolors = &t_Co | |
let g:solarized_termtrans = 1 " Set to 0 if text is unreadable with background transparency. | |
colorscheme solarized | |
call togglebg#map("<F2>") | |
else | |
silent !mkdir -p ~/.vim/colors | |
silent !cp ~/.vim/plugged/vim-colors-solarized/colors/solarized.vim ~/.vim/colors/ | |
source ~/.vim/colors/solarized.vim | |
colorscheme solarized | |
endif | |
""" Moving Around/Editing | |
set nocompatible " Stop behaving like vi | |
set nostartofline " Avoid moving cursor to BOL when jumping around | |
set virtualedit=block " Let cursor move past the last char in <C-v> mode | |
set scrolloff=3 " Keep 3 context lines above and below the cursor | |
set backspace=indent,eol,start | |
set showmatch " Briefly jump to a paren once it's balanced | |
set matchtime=2 " (for only .2 seconds). | |
set wrap " wrap text | |
set linebreak " don't wrap textin the middle of a word | |
""" Key Mappings | |
map <silent><C-Left> <C-T> | |
map <silent><C-Right> <C-]> | |
nmap <SPACE> <C-F> " use space for paging through files | |
""" Easily move around tabs | |
map <silent><A-Right> :tabnext<CR> | |
map <silent><A-Left> :tabprevious<CR> | |
""" Better search highlights | |
nnoremap <silent> n n:call HLNext(0.1)<cr> | |
nnoremap <silent> N N:call HLNext(0.1)<cr> | |
function! HLNext (blinktime) | |
set invcursorline | |
redraw | |
exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm' | |
set invcursorline | |
redraw | |
endfunction | |
""" Searching and Patterns | |
set ignorecase " Default to using case insensitive searches, | |
set smartcase " unless uppercase letters are used in the regex. | |
set hlsearch " Highlight searches by default. | |
set incsearch " Incrementally search while typing a /regex | |
""" Insert completion | |
" don't select first item, follow typing in autocomplete | |
set completeopt=longest,menuone,preview | |
set pumheight=6 " Keep a small completion window | |
" close preview window automatically | |
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif | |
autocmd InsertLeave * if pumvisible() == 0|pclose|endif | |
""" Folding | |
"set foldmethod=syntax | |
"set foldopen=all | |
"set foldclose=all | |
" show a line at column 79 | |
"if exists("&colorcolumn") | |
" set colorcolumn=79 | |
"endif | |
" displays tabs with :set list & displays when a line runs off-screen | |
" set listchars=tab:>-,eol:$,trail:-,precedes:<,extends:> | |
" set list | |
""" Messages, Info, Status | |
set vb t_vb= " Disable all bells. I hate ringing/flashing. | |
set confirm " Y-N-C prompt if closing with unsaved changes. | |
set showcmd " Show incomplete normal mode commands as I type. | |
set report=0 " : commands always print changed line count. | |
set shortmess+=a " Use [+]/[RO]/[w] for modified/readonly/written. | |
set ruler " Show some info, even without statuslines. | |
set laststatus=2 " Always show statusline, even if only 1 window. | |
""" Tabs/Indent Levels | |
set tabstop=4 " <tab> inserts 4 spaces | |
set expandtab " Use spaces, not tabs, for autoindent/tab key. | |
set shiftwidth=4 " but an indent level is 2 spaces wide. | |
set softtabstop=4 " <BS> over an autoindent deletes both spaces. | |
set shiftround " rounds indent to a multiple of shiftwidth | |
""" Tags | |
" Tags can be in ./tags, ../tags, ..., /home/tags. | |
"set tags+=$HOME/.vim/tags/python.ctags | |
"set tags+=$HOME/.vim/tags/django.ctags | |
set showfulltag " Show more information while completing tags. | |
set cscopetag " When using :tag, <C-]>, or "vim -t", try cscope: | |
set cscopetagorder=0 " try ":cscope find g foo" and then ":tselect foo" | |
""" Reading/Writing | |
set noautowrite " Never write a file unless I request it. | |
set noautowriteall " NEVER. | |
set noautoread " Don't automatically re-read changed files. | |
set modeline " Allow vim options to be embedded in files; | |
set modelines=5 " they must be within the first or last 5 lines. | |
set ffs=unix,dos,mac " Try recognizing dos, unix, and mac line endings. | |
""" Backups/Swap Files | |
" Make sure that the directory where we want to put swap/backup files exists. | |
if has("unix") | |
if ! len(glob("~/.backup/")) | |
echomsg "Backup directory ~/.backup doesn't exist!" | |
endif | |
set backupdir^=~/.backup " Backups are written to ~/.backup/ if possible. | |
set directory^=~/.backup// " Swap files are also written to ~/.backup, too. | |
endif | |
" ^ Here be magic! Quoth the help: | |
" For Unix and Win32, if a directory ends in two path separators "//" or "\\", | |
" the swap file name will be built from the complete path to the file with all | |
" path separators substituted to percent '%' signs. This will ensure file | |
" name uniqueness in the preserve directory. | |
set writebackup " Make a backup of the original file when writing | |
"set backup " and don't delete it after a succesful write. | |
set backupskip= " There are no files that shouldn't be backed up. | |
set updatetime=2000 " Write swap files after 2 seconds of inactivity. | |
set backupext=~ " Backup for "file" is "file~" | |
""" Command Line | |
set history=1000 " Keep a very long command-line history. | |
set wildmenu " Menu completion in command mode on <Tab> | |
set wildmode=full " <Tab> cycles between all matching choices. | |
set wcm=<C-Z> " Ctrl-Z in a mapping acts like <Tab> on cmdline | |
source $VIMRUNTIME/menu.vim " Load menus (this would be done anyway in gvim) | |
" <F4> triggers the menus, even in terminal vim. | |
map <F4> :emenu <C-Z> | |
" execute selected script | |
map <C-h> :py EvaluateCurrentRange()<CR> | |
" Show tasks in current buffer | |
map T :TaskList<CR><C-w><Left> | |
" get rid of hlsearch | |
nmap <silent> <BS> :nohlsearch<CR> | |
" bind K to grep word under cursor | |
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR> | |
let Tlist_GainFocus_On_ToggleOpen=1 | |
let g:skip_loading_mswin=1 | |
""" The Silver Searcher | |
if executable('ag') | |
" Use ag over grep | |
set grepprg=ag\ --nogroup\ --nocolor | |
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore | |
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' | |
" ag is fast enough that CtrlP doesn't need to cache | |
let g:ctrlp_use_caching = 0 | |
endif | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment