Created
September 20, 2018 15:20
-
-
Save dustinknopoff/29027d2ac2e5c937d0eb64cface8ef8e to your computer and use it in GitHub Desktop.
My current-is vim config file.
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
filetype plugin indent on | |
:ab #b /************************************************ | |
:ab #e ************************************************/ | |
set nocompatible | |
set modelines=0 | |
set autowrite | |
set backspace=indent,eol,start | |
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 | |
call plug#begin('~/.vim/bundle') | |
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | |
Plug 'junegunn/fzf.vim' | |
Plug 'tmhedberg/SimpylFold' | |
Plug 'jiangmiao/auto-pairs' | |
Plug 'vim-airline/vim-airline' | |
Plug 'scrooloose/nerdtree' | |
Plug 'tiagofumo/vim-nerdtree-syntax-highlight' | |
Plug 'scrooloose/nerdcommenter' | |
Plug 'rust-lang/rust.vim' | |
Plug 'Yggdroot/indentLine' | |
Plug 'tpope/vim-fugitive' | |
Plug 'sheerun/vim-polyglot' | |
Plug 'vim-syntastic/syntastic' | |
Plug 'rizzatti/dash.vim' | |
Plug 'guns/vim-sexp' | |
Plug 'tpope/vim-surround' | |
Plug 'Valloric/YouCompleteMe' | |
call plug#end() | |
let g:AutoPairsFlyMode = 1 | |
syntax on | |
set number | |
set relativenumber | |
set tabstop=4 | |
set shiftwidth=4 | |
set softtabstop=4 | |
set expandtab | |
set encoding=utf-8 | |
" set scrolloff=3 | |
set autoindent | |
set showmode | |
set showcmd | |
set hidden | |
set wildmenu | |
set wildmode=list:longest | |
set visualbell | |
set cursorline | |
set ruler | |
set backspace=indent,eol,start | |
set laststatus=2 | |
set undofile | |
let mapleader = "," | |
" Tame Searching | |
nnoremap / /\v | |
vnoremap / /\v | |
set ignorecase | |
set smartcase | |
set gdefault | |
set incsearch | |
set showmatch | |
set hlsearch | |
set clipboard=unnamed | |
nnoremap <leader><space> :noh<cr> | |
nnoremap <tab> % | |
vnoremap <tab> % | |
map <C-J> <C-W>j<C-W>_ | |
map <C-K> <C-W>k<C-W>_ | |
" Line Handling | |
set wrap | |
set textwidth=79 | |
set formatoptions=qrn1 | |
set colorcolumn=85 | |
set list | |
set ttyfast | |
set hlsearch | |
set showmode | |
set listchars=tab:▸\ ,eol:¬ | |
"Learn Vim | |
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 | |
inoremap <F1> <ESC> | |
nnoremap <F1> <ESC> | |
vnoremap <F1> <ESC> | |
nnoremap ; : | |
au FocusLost * :wa | |
inoremap jj <ESC> | |
nnoremap <leader>w <C-w>v<C-w>l | |
nnoremap <C-h> <C-w>h | |
nnoremap <C-j> <C-w>j | |
nnoremap <C-k> <C-w>k | |
nnoremap <C-l> <C-w>l | |
" Make double-<Esc> clear search highlights | |
nnoremap <silent> <Esc><Esc> <Esc>:nohlsearch<CR><Esc> | |
" --column: Show column number | |
" --line-number: Show line number | |
" --no-heading: Do not show file headings in results | |
" --fixed-strings: Search term as a literal string | |
" --ignore-case: Case insensitive search | |
" --no-ignore: Do not respect .gitignore, etc... | |
" --hidden: Search hidden files and folders | |
" --follow: Follow symlinks | |
" --glob: Additional conditions for search (in this case ignore everything in the .git/ folder) | |
" --color: Search color options | |
command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --glob "!.git/*" --color "always" '.shellescape(<q-args>), 1, <bang>0) | |
set grepprg=rg\ --vimgrep | |
"NERDTree Stuff | |
"autocmd vimenter * NERDTree | |
"autocmd StdinReadPre * let s:std_in=1 | |
"autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif | |
"autocmd StdinReadPre * let s:std_in=1 | |
"autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif | |
map <C-n> :NERDTreeToggle<CR> | |
"autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && "b:NERDTree.isTabTree()) | q | endif | |
function! TeaCodeExpand() | |
" Collect data | |
let trigger = getline( '.' ) | |
let line = line( '.' ) | |
let filetype = &filetype | |
let cursor = getpos('.') | |
execute "normal! dd" | |
" Run expand function and store the results in ob | |
let ob = system( "sh ~/\/expand.sh -e ". filetype ." -t '". trigger ."'" ) | |
" Convert command response to an object by running eval function | |
let object = js_decode( ob ) | |
let s:result = object.text | |
let s:max = object.cursorPosition | |
" report install TeaCode if error. | |
if s:result ==? 'null' | |
echo "Could not run TeaCode. Please make sure it's installed. You can download the app from https://www.apptorium.com/teacode" | |
endif | |
execute "normal! i". s:result | |
python << EOF | |
import vim | |
string = vim.eval("s:result") | |
line = 0 | |
column = 0 | |
vim.command("let l=%d"% line) | |
vim.command("let c=%d"% column) | |
for i in string: | |
if i == vim.eval("s:max"): | |
break | |
if i is '\n': | |
line+=1 | |
column = 0 | |
else: | |
column += 1 | |
EOF | |
" Set the cursor position | |
" [bufnum, lnum, col, off] | |
let newline = line + l | |
if line == 1 | |
let newline = newline + 1 | |
endif | |
let newcol = cursor[2] + c - 1 | |
call setpos( '.', [0, newline, newcol, 0] ) | |
call CIndent() | |
endfunction | |
imap <C-e> <C-O>:call TeaCodeExpand()<CR> | |
autocmd BufWritePre,BufRead *.c :normal gg=G | |
autocmd FocusGained * :call Highlight_cursor() | |
function! CIndent() | |
let cursor_pos = getpos('.') | |
:normal gg=G | |
call setpos('.', cursor_pos) | |
endfunction | |
augroup CTidy | |
autocmd! | |
autocmd InsertLeave *.[chCH],*.cc,*.hh,*.[ch]xx :call CIndent() | |
augroup END | |
nnoremap <C-w>E :SyntasticCheck<CR> :SyntasticToggleMode<CR> | |
nnoremap <silent> <A-Left> :execute 'silent! tabmove ' . (tabpagenr()-2)<CR> | |
nnoremap <silent> <A-Right> :execute 'silent! tabmove ' . (tabpagenr()+1)<CR> | |
nnoremap <leader>o :Files<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment