2017-02-28 10:56:23 -06:00
|
|
|
|
set nocompatible
|
|
|
|
|
|
2017-02-08 13:05:01 -06:00
|
|
|
|
" initial plugin manager installation
|
|
|
|
|
if has('nvim')
|
|
|
|
|
if empty(glob('~/.config/nvim/autoload/plug.vim'))
|
|
|
|
|
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
|
|
|
|
autocmd VimEnter * PlugInstall
|
|
|
|
|
endif
|
|
|
|
|
else
|
|
|
|
|
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
|
|
|
|
|
endif
|
|
|
|
|
end
|
2017-02-08 11:54:30 -06:00
|
|
|
|
|
2017-02-28 10:56:23 -06:00
|
|
|
|
let $vimdir = $HOME.'/.vim'
|
|
|
|
|
if has('nvim')
|
|
|
|
|
let $vimdir = $HOME.'/.config/nvim'
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
" OS detection functions
|
|
|
|
|
silent function! OSX()
|
|
|
|
|
return has('macunix')
|
|
|
|
|
endfunction
|
|
|
|
|
silent function! LINUX()
|
|
|
|
|
return has('unix') && !has('macunix') && !has('win32unix')
|
|
|
|
|
endfunction
|
|
|
|
|
silent function! WINDOWS()
|
|
|
|
|
return (has('win32') || has('win64'))
|
|
|
|
|
endfunction
|
|
|
|
|
|
2017-02-08 11:54:30 -06:00
|
|
|
|
" tell vim to reload the init.vim file when it saves it
|
2017-02-28 10:56:23 -06:00
|
|
|
|
" if has('nvim')
|
|
|
|
|
" autocmd! BufWritePost init.vim source %
|
|
|
|
|
" else
|
|
|
|
|
" autocmd! BufWritePost .vimrc source %
|
|
|
|
|
" end
|
|
|
|
|
|
|
|
|
|
" load a per-environment file if one exists
|
|
|
|
|
if filereadable(expand("$HOME/.env_init.vim"))
|
|
|
|
|
source "$HOME/.env_init.vim"
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
if has('vim_starting')
|
|
|
|
|
set encoding=utf8
|
|
|
|
|
endif
|
2017-02-08 11:54:30 -06:00
|
|
|
|
|
|
|
|
|
" plugin build functions
|
|
|
|
|
function! BuildComposer(info)
|
|
|
|
|
if a:info.status != 'unchanged' || a:info.force
|
|
|
|
|
!cargo build --release
|
|
|
|
|
UpdateRemotePlugins
|
|
|
|
|
endif
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
function! DoRemote(arg)
|
|
|
|
|
UpdateRemotePlugins
|
|
|
|
|
endfunction
|
|
|
|
|
|
2017-02-28 10:56:23 -06:00
|
|
|
|
" initialize plugin manager
|
2017-02-08 13:05:01 -06:00
|
|
|
|
if has('nvim')
|
|
|
|
|
call plug#begin('~/.config/nvim/bundle')
|
|
|
|
|
else
|
|
|
|
|
call plug#begin('~/.vim/bundle')
|
|
|
|
|
endif
|
|
|
|
|
|
2017-02-08 11:54:30 -06:00
|
|
|
|
" let plugin manager manage itself
|
|
|
|
|
Plug 'junegunn/vim-plug'
|
|
|
|
|
|
|
|
|
|
" plugins
|
|
|
|
|
|
|
|
|
|
" if vim is being launched to view man pages, don't do our magical session
|
|
|
|
|
" stuff!
|
|
|
|
|
if exists('asmanviewer')
|
|
|
|
|
let g:prosession_dir = '/dev/null'
|
|
|
|
|
else
|
2017-02-08 13:05:01 -06:00
|
|
|
|
Plug 'tpope/vim-obsession' " session ease-of-use
|
2017-02-08 11:54:30 -06:00
|
|
|
|
Plug 'dhruvasagar/vim-prosession' " more session ease-of-use
|
|
|
|
|
let g:prosession_dir = '~/.config/nvim/session/'
|
|
|
|
|
endif
|
2017-02-28 10:56:23 -06:00
|
|
|
|
|
2017-02-08 11:54:30 -06:00
|
|
|
|
Plug 'vim-airline/vim-airline' " statusline
|
2017-04-14 15:03:39 -05:00
|
|
|
|
let g:airline_powerline_fonts = 1
|
2017-02-08 11:54:30 -06:00
|
|
|
|
let g:airline#extensions#tabline#enabled = 1 " automatically displays all buffers when there's only one tab open
|
|
|
|
|
let g:airline#extensions#tabline#fnamemod = ':t'
|
|
|
|
|
" set laststatus=2 " always show statusline
|
|
|
|
|
" set noshowmode " hides default mode
|
|
|
|
|
let g:airline#extensions#tabline#left_sep = ''
|
|
|
|
|
let g:airline#extensions#tabline#left_alt_sep = ''
|
|
|
|
|
let g:airline_right_alt_sep = ''
|
|
|
|
|
let g:airline_right_sep = ''
|
|
|
|
|
let g:airline_left_alt_sep= ''
|
|
|
|
|
let g:airline_left_sep = ''
|
2017-02-28 10:56:23 -06:00
|
|
|
|
let g:airline#extensions#tabline#buffers_label = ''
|
2017-02-08 11:54:30 -06:00
|
|
|
|
Plug 'vim-airline/vim-airline-themes'
|
2017-04-28 08:31:28 -05:00
|
|
|
|
let g:airline_mode_map = {
|
|
|
|
|
\ '__' : '-',
|
|
|
|
|
\ 'n' : 'N',
|
|
|
|
|
\ 'i' : 'I',
|
|
|
|
|
\ 'R' : 'R',
|
|
|
|
|
\ 'c' : 'C',
|
|
|
|
|
\ 'v' : 'V',
|
|
|
|
|
\ 'V' : 'V',
|
|
|
|
|
\ '' : 'V',
|
|
|
|
|
\ 's' : 'S',
|
|
|
|
|
\ 'S' : 'S',
|
|
|
|
|
\ '' : 'S',
|
|
|
|
|
\ }
|
2017-02-08 11:54:30 -06:00
|
|
|
|
|
|
|
|
|
Plug 'scrooloose/nerdtree', {'on': ['NERDTreeToggle', 'NERDTree']} " nice sidebar for files
|
|
|
|
|
let g:NERDTreeDirArrowExpandable = ' '
|
|
|
|
|
let g:NERDTreeDirArrowCollapsible = ' '
|
|
|
|
|
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif " close vim if last buffer is a NERD buffer
|
|
|
|
|
|
|
|
|
|
Plug 'nathanaelkane/vim-indent-guides' " indentation guides (NOTE: doesn't seem to work with my colorscheme)
|
|
|
|
|
let g:indent_guides_start_level = 0
|
|
|
|
|
let g:indent_guides_auto_color = 1
|
|
|
|
|
|
|
|
|
|
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } " autocomplete
|
|
|
|
|
let g:deoplete#enable_at_startup = 1
|
|
|
|
|
|
|
|
|
|
Plug 'scrooloose/syntastic' " syntax checker
|
|
|
|
|
Plug 'bkad/CamelCaseMotion' " camel case and underscore word movements
|
2017-05-09 13:04:00 -05:00
|
|
|
|
Plug 'vim-scripts/LargeFile' " gracefully handle very large files
|
2017-02-08 11:54:30 -06:00
|
|
|
|
Plug 'tpope/vim-commentary' " toggle comments in code easily
|
2017-03-03 11:08:09 -06:00
|
|
|
|
Plug 'tpope/vim-repeat' " toggle comments in code easily
|
2017-02-08 11:54:30 -06:00
|
|
|
|
Plug 'tmux-plugins/vim-tmux-focus-events' " allow transitions within tmux
|
|
|
|
|
Plug 'christoomey/vim-tmux-navigator' " allow transitions within tmux
|
|
|
|
|
Plug 'godlygeek/tabular' " align text lines together
|
|
|
|
|
Plug 'dhruvasagar/vim-table-mode' " for creating and editing character tables
|
|
|
|
|
Plug 'lytedev/vim-superman' " view man pages with vim
|
|
|
|
|
Plug 'tpope/vim-surround' " quickly modify text surrounding objects
|
|
|
|
|
Plug 'tpope/vim-speeddating' " vim knows about date-like text objects
|
2017-04-28 08:31:28 -05:00
|
|
|
|
Plug 'tpope/vim-fugitive' " vim git commands
|
|
|
|
|
Plug 'airblade/vim-gitgutter' " vim git gutter information
|
|
|
|
|
let g:gitgutter_override_sign_column_highlight = 0
|
|
|
|
|
let g:gitgutter_sign_added = '+'
|
|
|
|
|
let g:gitgutter_sign_modified = '~'
|
|
|
|
|
let g:gitgutter_sign_removed = '-'
|
|
|
|
|
let g:gitgutter_sign_removed_first_line = '-'
|
|
|
|
|
let g:gitgutter_sign_modified_removed = '~'
|
2017-02-08 11:54:30 -06:00
|
|
|
|
Plug 'michaeljsmith/vim-indent-object' " adds an indentation level text object
|
|
|
|
|
Plug 'wellle/targets.vim' " adds some more handy text objects
|
2017-04-02 16:35:39 -05:00
|
|
|
|
Plug 'dbakker/vim-projectroot' " adds helper functions for getting to a project's root directory
|
2017-02-28 10:56:23 -06:00
|
|
|
|
Plug 'ternjs/tern_for_vim', { 'do': 'npm install' } " javascript helpful things
|
|
|
|
|
Plug 'mikewest/vimroom' " distraction-free editing
|
2017-02-08 11:54:30 -06:00
|
|
|
|
Plug 'editorconfig/editorconfig-vim' " loads project-specific editor settings
|
|
|
|
|
let g:vimroom_sidebar_height = 0
|
|
|
|
|
|
|
|
|
|
Plug 'junegunn/fzf', {'dir': '~/.fzf', 'do': './install --all'} " fuzzy file finding
|
|
|
|
|
Plug 'junegunn/fzf.vim' " helpers for using fzf in vim
|
|
|
|
|
let g:fzf_layout = { 'window': 'enew' }
|
|
|
|
|
|
|
|
|
|
" plugins for specific file types
|
2017-02-28 10:56:23 -06:00
|
|
|
|
|
2017-03-09 17:52:47 -06:00
|
|
|
|
Plug 'othree/html5.vim', {'for': ['jade', 'pug', 'html', 'vue']}
|
2017-03-14 20:35:15 -05:00
|
|
|
|
Plug 'mxw/vim-jsx', {'for': ['jsx', 'javascript', 'js', 'javascript.jsx']}
|
|
|
|
|
let g:jsx_ext_required = 0 " allow JSX in normal JS files
|
2017-03-09 17:52:47 -06:00
|
|
|
|
Plug 'hail2u/vim-css3-syntax', {'for': ['styl', 'stylus', 'css', 'vue']}
|
2017-02-08 11:54:30 -06:00
|
|
|
|
Plug 'kchmck/vim-coffee-script', {'for': ['coffee', 'coffeescript', 'vue']}
|
|
|
|
|
Plug 'posva/vim-vue', {'for': ['vue']}
|
|
|
|
|
Plug 'elixir-lang/vim-elixir', {'for': ['elixir']}
|
2017-02-20 18:31:28 -06:00
|
|
|
|
Plug 'mattn/emmet-vim', {'for': ['html']}
|
2017-02-08 11:54:30 -06:00
|
|
|
|
Plug 'wavded/vim-stylus', {'for': ['styl', 'stylus', 'vue']}
|
|
|
|
|
Plug 'rust-lang/rust.vim', {'for': ['rs', 'rust']}
|
2017-04-20 08:16:02 -05:00
|
|
|
|
Plug 'mustache/vim-mustache-handlebars', {'for': ['html.handlebars', 'handlebars', 'hbs']}
|
2017-04-27 15:49:57 -05:00
|
|
|
|
Plug 'plasticboy/vim-markdown', {'for': ['md', 'markdown']}
|
2017-02-08 11:54:30 -06:00
|
|
|
|
" Plug 'euclio/vim-markdown-composer', { 'do': function('BuildComposer'), 'for': ['md', 'markdown'] }
|
|
|
|
|
Plug 'digitaltoad/vim-jade', {'for': ['pug', 'jade', 'vue']}
|
|
|
|
|
Plug 'leafo/moonscript-vim', {'for': ['moon', 'moonscript']}
|
|
|
|
|
Plug 'evidens/vim-twig'
|
|
|
|
|
Plug 'leafgarland/typescript-vim', {'for': ['ts', 'typescript']}
|
|
|
|
|
Plug 'jwalton512/vim-blade', {'for': ['blade', 'blade.php']}
|
|
|
|
|
|
2017-04-25 07:59:41 -05:00
|
|
|
|
Plug 'carlitux/deoplete-ternjs', { 'do': 'sudo npm install -g tern' }
|
|
|
|
|
|
2017-02-08 11:54:30 -06:00
|
|
|
|
call plug#end()
|
|
|
|
|
|
|
|
|
|
filetype on
|
|
|
|
|
filetype indent on
|
|
|
|
|
filetype plugin on
|
|
|
|
|
|
|
|
|
|
" language specific configuration
|
|
|
|
|
|
|
|
|
|
" C
|
|
|
|
|
let c_space_errors = 1
|
|
|
|
|
let c_comment_strings = 0 " dont highlight strings inside C comments
|
|
|
|
|
|
|
|
|
|
" Python
|
|
|
|
|
let python_space_errors = 1
|
|
|
|
|
" autocmd FileType python setl tabstop=4 expandtab shiftwidth=4 softtabstop=4
|
|
|
|
|
" autocmd FileType js setl tabstop=2 expandtab shiftwidth=2 softtabstop=2
|
|
|
|
|
" autocmd FileType vue setl tabstop=2 expandtab shiftwidth=2 softtabstop=2
|
|
|
|
|
autocmd FileType php setl tabstop=4 expandtab shiftwidth=4 softtabstop=4
|
|
|
|
|
|
|
|
|
|
" Markdown
|
2017-02-10 12:06:59 -06:00
|
|
|
|
autocmd BufNewFile,BufReadPost *.md setl filetype=markdown spell
|
2017-02-08 11:54:30 -06:00
|
|
|
|
|
|
|
|
|
" Text
|
|
|
|
|
autocmd BufNewFile,BufReadPost *.txt setl spell textwidth=0 wrapmargin=0
|
|
|
|
|
|
2017-05-20 13:56:34 -05:00
|
|
|
|
" Make any necessary directories in the path when saving a file
|
|
|
|
|
fun! <SID>AutoMakeDirectory()
|
|
|
|
|
let s:directory = expand("<afile>:p:h")
|
|
|
|
|
if !isdirectory(s:directory)
|
|
|
|
|
call mkdir(s:directory, "p")
|
|
|
|
|
endif
|
|
|
|
|
endfun
|
|
|
|
|
autocmd BufWritePre,FileWritePre * :call <SID>AutoMakeDirectory()
|
|
|
|
|
|
|
|
|
|
if !exists("g:make_args")
|
2017-06-20 16:10:23 -05:00
|
|
|
|
let g:make_args="default"
|
2017-05-20 13:56:34 -05:00
|
|
|
|
endif
|
|
|
|
|
fun! RunMake()
|
|
|
|
|
split
|
|
|
|
|
if has('nvim')
|
2017-05-20 22:40:32 -05:00
|
|
|
|
" run from the root of the current git repository
|
|
|
|
|
let path = system("git rev-parse --show-toplevel | tr -d '\\n'")
|
|
|
|
|
" TODO: handle non-git situations
|
|
|
|
|
execute 'terminal cd ' . path . ' && make ' . g:make_args
|
2017-05-20 13:56:34 -05:00
|
|
|
|
else
|
|
|
|
|
execute '!make ' . g:make_args
|
|
|
|
|
endif
|
|
|
|
|
endfun
|
|
|
|
|
|
2017-05-20 22:40:32 -05:00
|
|
|
|
" kill the terminal buffer when the process exits
|
|
|
|
|
" autocmd TermClose * call feedkeys('<cr>')
|
|
|
|
|
|
2017-02-08 11:54:30 -06:00
|
|
|
|
" whitespace
|
2017-02-28 10:56:23 -06:00
|
|
|
|
" use tabs at a two-space width
|
2017-02-08 11:54:30 -06:00
|
|
|
|
set tabstop=2
|
|
|
|
|
set shiftwidth=2
|
|
|
|
|
set softtabstop=2
|
2017-02-08 13:05:01 -06:00
|
|
|
|
set noexpandtab
|
2017-02-28 10:56:23 -06:00
|
|
|
|
|
|
|
|
|
" auto/smart indent
|
2017-02-08 11:54:30 -06:00
|
|
|
|
set autoindent smartindent
|
2017-02-28 10:56:23 -06:00
|
|
|
|
|
|
|
|
|
" show certain whitespace characters
|
2017-02-08 11:54:30 -06:00
|
|
|
|
set list
|
|
|
|
|
set nostartofline
|
2017-02-10 11:23:52 -06:00
|
|
|
|
set listchars=trail:·,tab:\ \ ,trail:~
|
|
|
|
|
" set listchars=eol:\ ,tab:>-,trail:~,extends:>,precedes:<,space:·
|
2017-02-08 11:54:30 -06:00
|
|
|
|
|
|
|
|
|
" look and feel
|
2017-02-28 10:56:23 -06:00
|
|
|
|
"
|
|
|
|
|
" try and keep text (and code) to a width of 80 characters
|
2017-02-08 11:54:30 -06:00
|
|
|
|
set wrap
|
|
|
|
|
set linebreak
|
|
|
|
|
set breakindent
|
|
|
|
|
set textwidth=80
|
|
|
|
|
set formatoptions=crql1j
|
|
|
|
|
" t autowrap to textwidth
|
|
|
|
|
" c autowrap comments to textwidth
|
|
|
|
|
" r autoinsert comment leader with <enter>
|
|
|
|
|
" q allow formatting of comments with gq
|
|
|
|
|
" l lines longer than 'textwidth' on insert do not get formatted
|
|
|
|
|
" 1 don't break a line after a one-letter word - break it before
|
|
|
|
|
" j where it makes sense, remove a comment leader when joining lines
|
|
|
|
|
|
2017-02-28 10:56:23 -06:00
|
|
|
|
" handle window title
|
|
|
|
|
set title
|
|
|
|
|
|
|
|
|
|
" don't do syntax highlighting on lines longer than 2048 characters
|
2017-02-08 11:54:30 -06:00
|
|
|
|
set synmaxcol=2048
|
2017-02-28 10:56:23 -06:00
|
|
|
|
|
2017-02-08 11:54:30 -06:00
|
|
|
|
if exists('asmanviewer')
|
|
|
|
|
set nonumber " no line numbers when viewing a man page
|
|
|
|
|
else
|
|
|
|
|
set number " line numbers
|
|
|
|
|
endif
|
2017-02-28 10:56:23 -06:00
|
|
|
|
|
|
|
|
|
" relative line numbers
|
|
|
|
|
set relativenumber
|
|
|
|
|
|
|
|
|
|
" highlight the current line
|
|
|
|
|
set cursorline
|
|
|
|
|
|
2017-02-08 11:54:30 -06:00
|
|
|
|
" set cursorcolumn " highlight the current column
|
|
|
|
|
" let &colorcolumn=join(range(81,400),",") " colors columns past 80
|
2017-02-28 10:56:23 -06:00
|
|
|
|
|
2017-03-03 11:08:09 -06:00
|
|
|
|
" highlight the 81st character in a line where it exists
|
|
|
|
|
highlight ColorColumn ctermbg=magenta ctermfg=7
|
|
|
|
|
call matchadd('ColorColumn', '\%81v', 100)
|
|
|
|
|
|
2017-02-08 11:54:30 -06:00
|
|
|
|
set showcmd
|
|
|
|
|
set nowildmenu
|
|
|
|
|
set wildmode=longest,list,full
|
|
|
|
|
set cpoptions-=$
|
|
|
|
|
set showmatch
|
|
|
|
|
set mouse=a
|
|
|
|
|
set mousehide
|
|
|
|
|
set backspace=indent,eol,start
|
|
|
|
|
set ruler
|
|
|
|
|
set lazyredraw
|
|
|
|
|
set scrolloff=8
|
|
|
|
|
set sidescrolloff=8
|
|
|
|
|
set splitright
|
|
|
|
|
set splitbelow
|
|
|
|
|
set noerrorbells
|
|
|
|
|
set visualbell
|
|
|
|
|
set nobackup
|
|
|
|
|
set nowritebackup
|
|
|
|
|
set noswapfile
|
|
|
|
|
set timeout
|
|
|
|
|
set ttimeoutlen=200
|
|
|
|
|
set isfname+=32
|
|
|
|
|
|
|
|
|
|
set vb t_vb=
|
|
|
|
|
if has('autocmd')
|
|
|
|
|
autocmd GUIEnter * set visualbell t_vb=
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
let base16colorspace=256
|
|
|
|
|
set background=dark
|
2017-02-08 12:08:10 -06:00
|
|
|
|
colorscheme base16-donokai
|
2017-02-08 11:54:30 -06:00
|
|
|
|
|
2017-04-28 08:31:28 -05:00
|
|
|
|
highlight SignColumn ctermbg=black guibg=black
|
|
|
|
|
highlight GitGutterAdd ctermbg=black guibg=black
|
|
|
|
|
highlight GitGutterDelete ctermbg=black guibg=black
|
|
|
|
|
highlight GitGutterChange ctermbg=black guibg=black
|
|
|
|
|
highlight GitGutterChangeDelete ctermbg=black guibg=black
|
|
|
|
|
|
2017-02-28 10:56:23 -06:00
|
|
|
|
" TODO: need a way to toggle this and maybe make it on by default except in
|
|
|
|
|
" files where space indentation is expected
|
2017-02-08 11:54:30 -06:00
|
|
|
|
fun! ShowSpaceIndentation()
|
2017-02-28 10:56:23 -06:00
|
|
|
|
hi LeadingWhiteSpaces ctermfg=black ctermbg=8
|
|
|
|
|
endfunction
|
|
|
|
|
fun! HideSpaceIndentation()
|
|
|
|
|
hi LeadingWhiteSpaces ctermfg=black ctermbg=black
|
2017-02-08 11:54:30 -06:00
|
|
|
|
endfunction
|
2017-02-28 10:56:23 -06:00
|
|
|
|
hi LeadingWhiteSpaces ctermfg=black ctermbg=black
|
2017-02-08 11:54:30 -06:00
|
|
|
|
|
2017-02-28 10:56:23 -06:00
|
|
|
|
" a toggle-able minimalistic distraction-free text editing mode
|
2017-02-08 11:54:30 -06:00
|
|
|
|
let s:distractionFreeMode = 0
|
|
|
|
|
fun! DistractionFreeModeFunc()
|
2017-02-08 13:05:01 -06:00
|
|
|
|
AirlineToggle
|
2017-02-08 11:54:30 -06:00
|
|
|
|
VimroomToggle
|
|
|
|
|
if s:distractionFreeMode == 0
|
|
|
|
|
let s:distractionFreeMode = 1
|
2017-02-08 13:05:01 -06:00
|
|
|
|
set nocursorline
|
2017-02-08 11:54:30 -06:00
|
|
|
|
set laststatus=0
|
|
|
|
|
set noshowmode
|
|
|
|
|
set noruler
|
|
|
|
|
set noshowcmd
|
|
|
|
|
set nonumber
|
|
|
|
|
hi NonText ctermfg=black guifg=black
|
|
|
|
|
else
|
|
|
|
|
let s:distractionFreeMode = 0
|
2017-02-08 13:05:01 -06:00
|
|
|
|
set cursorline
|
2017-02-08 11:54:30 -06:00
|
|
|
|
set showmode
|
|
|
|
|
set ruler
|
|
|
|
|
set laststatus=2
|
|
|
|
|
set showcmd
|
|
|
|
|
set number
|
|
|
|
|
hi NonText ctermfg=gray guifg=gray
|
2017-02-08 13:05:01 -06:00
|
|
|
|
colorscheme base16-donokai
|
2017-02-08 11:54:30 -06:00
|
|
|
|
endif
|
|
|
|
|
endfunction
|
|
|
|
|
|
2017-02-08 12:08:10 -06:00
|
|
|
|
" prevents normal window navigation and closing while in DistractionFreeMode
|
|
|
|
|
fun! CheckCloseDistractionFreeMode()
|
2017-02-08 13:05:01 -06:00
|
|
|
|
if s:distractionFreeMode == 1
|
|
|
|
|
call DistractionFreeModeFunc()
|
|
|
|
|
endif
|
2017-02-08 12:08:10 -06:00
|
|
|
|
endfunction
|
|
|
|
|
|
2017-02-28 10:56:23 -06:00
|
|
|
|
" run the previous checking function every time we leave a window
|
2017-02-08 12:08:10 -06:00
|
|
|
|
if has('autocmd')
|
|
|
|
|
autocmd WinLeave * call CheckCloseDistractionFreeMode()
|
|
|
|
|
endif
|
|
|
|
|
|
2017-02-08 11:54:30 -06:00
|
|
|
|
nnoremap <silent> <Leader>mz :DistractionFreeMode<CR>
|
|
|
|
|
|
|
|
|
|
:command! SpaceIndents call ShowSpaceIndentation()
|
|
|
|
|
:command! ShowSpaceIndents call ShowSpaceIndentation()
|
2017-02-28 10:56:23 -06:00
|
|
|
|
:command! HideSpaceIndents call HideSpaceIndentation()
|
2017-02-08 11:54:30 -06:00
|
|
|
|
:command! DistractionFreeMode call DistractionFreeModeFunc()
|
|
|
|
|
|
|
|
|
|
set hidden " allows buffer switching without saving
|
2017-04-14 11:52:18 -05:00
|
|
|
|
set shortmess=Ia
|
2017-02-08 11:54:30 -06:00
|
|
|
|
set history=1000
|
2017-02-28 10:56:23 -06:00
|
|
|
|
|
|
|
|
|
" undo files
|
2017-02-08 11:54:30 -06:00
|
|
|
|
set undofile
|
2017-02-08 13:05:01 -06:00
|
|
|
|
set undodir=$vimdir/undo
|
2017-02-08 11:54:30 -06:00
|
|
|
|
set undolevels=1000
|
|
|
|
|
set undoreload=10000
|
|
|
|
|
|
2017-02-28 10:56:23 -06:00
|
|
|
|
" backup files
|
2017-02-08 13:05:01 -06:00
|
|
|
|
set backupdir=$vimdir/backup
|
|
|
|
|
set directory=$vimdir/backup
|
2017-02-28 10:56:23 -06:00
|
|
|
|
|
|
|
|
|
" spell file
|
2017-02-08 13:05:01 -06:00
|
|
|
|
set spellfile=$vimdir/spell/en.utf-8.add
|
2017-02-08 11:54:30 -06:00
|
|
|
|
|
2017-02-28 10:56:23 -06:00
|
|
|
|
" smart case insensitivity by default
|
2017-02-08 11:54:30 -06:00
|
|
|
|
set ignorecase
|
|
|
|
|
set smartcase
|
|
|
|
|
set incsearch
|
|
|
|
|
set hlsearch
|
|
|
|
|
set wrapscan
|
|
|
|
|
|
|
|
|
|
set foldmethod=syntax
|
|
|
|
|
set foldlevel=99
|
|
|
|
|
set foldnestmax=10
|
|
|
|
|
set nofoldenable
|
2017-02-28 10:56:23 -06:00
|
|
|
|
set foldlevelstart=0
|
2017-02-08 11:54:30 -06:00
|
|
|
|
|
|
|
|
|
set autowrite
|
|
|
|
|
set autochdir
|
|
|
|
|
set autoread
|
|
|
|
|
set nomodeline
|
|
|
|
|
|
|
|
|
|
" yank to OS clipboard
|
|
|
|
|
set clipboard+=unnamed
|
|
|
|
|
|
|
|
|
|
" allows for manual and syntax folding... supposedly
|
|
|
|
|
augroup vimrc
|
|
|
|
|
au BufReadPre * setlocal foldmethod=indent
|
|
|
|
|
au BufWinEnter * if &fdm == 'indent' | setlocal foldmethod=manual | endif
|
|
|
|
|
augroup END
|
|
|
|
|
|
2017-03-16 19:56:00 -05:00
|
|
|
|
" jump to last opened position in file except in git commits
|
|
|
|
|
let jump_to_pos_blacklist = ['gitcommit']
|
2017-02-08 11:54:30 -06:00
|
|
|
|
if has("autocmd")
|
2017-03-17 13:59:31 -05:00
|
|
|
|
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") && index(jump_to_pos_blacklist, &ft) | exe "normal! g'\"" | endif
|
2017-02-08 11:54:30 -06:00
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
" no empty buffer on startup
|
|
|
|
|
autocmd VimEnter * nested if bufname('')=='' && line('$') == 1 && col('$')==1 && !&modified | bd % | endif
|
|
|
|
|
|
2017-02-28 10:56:23 -06:00
|
|
|
|
" terminal split in neovim
|
2017-02-08 13:05:01 -06:00
|
|
|
|
if has('nvim')
|
|
|
|
|
function! TerminalSplit()
|
|
|
|
|
let current_file = @%
|
|
|
|
|
echo current_file
|
|
|
|
|
if match(current_file, "term://*") != -1
|
|
|
|
|
split
|
|
|
|
|
terminal
|
|
|
|
|
else
|
|
|
|
|
vsplit
|
|
|
|
|
vertical resize 80
|
|
|
|
|
terminal
|
|
|
|
|
endif
|
|
|
|
|
endfunction
|
|
|
|
|
endif
|
2017-02-08 11:54:30 -06:00
|
|
|
|
|
|
|
|
|
" bindings
|
|
|
|
|
|
|
|
|
|
" common typo fixes
|
|
|
|
|
command! WQ wq
|
|
|
|
|
command! Wq wq
|
|
|
|
|
command! Wqa wqa
|
|
|
|
|
command! W w
|
|
|
|
|
command! Q q
|
|
|
|
|
|
|
|
|
|
" best leader
|
|
|
|
|
let mapleader = "\<Space>"
|
|
|
|
|
|
2017-02-08 13:05:01 -06:00
|
|
|
|
if has('nvim')
|
|
|
|
|
" terminal mappings
|
|
|
|
|
" open a terminal split at 80 columns
|
|
|
|
|
nnoremap <C-t> :call TerminalSplit()<CR>
|
|
|
|
|
tnoremap <C-t> <C-\><C-n>:call TerminalSplit()<CR>
|
2017-02-08 11:54:30 -06:00
|
|
|
|
|
2017-02-08 13:05:01 -06:00
|
|
|
|
" close the terminal
|
|
|
|
|
tnoremap <C-w> <C-\><C-n>:q!<CR>
|
2017-02-08 11:54:30 -06:00
|
|
|
|
|
2017-02-08 13:05:01 -06:00
|
|
|
|
" moving between terminal splits
|
|
|
|
|
tnoremap <C-h> <C-\><C-n><C-w>h
|
|
|
|
|
tnoremap <C-j> <C-\><C-n><C-w>j
|
|
|
|
|
tnoremap <C-k> <C-\><C-n><C-w>k
|
|
|
|
|
tnoremap <C-l> <C-\><C-n><C-w>l
|
|
|
|
|
endif
|
2017-02-08 11:54:30 -06:00
|
|
|
|
|
|
|
|
|
" enter insert mode when entering a terminal buffer
|
|
|
|
|
autocmd BufWinEnter,WinEnter term://* startinsert
|
|
|
|
|
|
2017-05-20 13:56:34 -05:00
|
|
|
|
" run make with leader,m
|
|
|
|
|
nnoremap <leader>m :call RunMake()<CR>
|
|
|
|
|
|
2017-02-08 11:54:30 -06:00
|
|
|
|
" change buffers with leader,tab
|
2017-02-28 10:56:23 -06:00
|
|
|
|
nnoremap <leader><Tab> :bnext<CR>
|
|
|
|
|
nnoremap <leader><S-Tab> :bprevious<CR>
|
2017-02-08 11:54:30 -06:00
|
|
|
|
|
|
|
|
|
" don't kill vim
|
|
|
|
|
nnoremap <leader>K <Nop>
|
|
|
|
|
nnoremap <S-K> <NOP>
|
|
|
|
|
|
|
|
|
|
" nerdtree
|
|
|
|
|
nnoremap <C-n> :NERDTree<CR>
|
|
|
|
|
|
|
|
|
|
" run macro across visually selected lines
|
|
|
|
|
xnoremap @ :<C-u>call ExecuteMacroOverVisualRange()<CR>
|
|
|
|
|
function! ExecuteMacroOverVisualRange()
|
|
|
|
|
echo "@".getcmdline()
|
|
|
|
|
execute ":'<,'>normal @".nr2char(getchar())
|
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|
|
" quick paragraph formatting
|
|
|
|
|
vmap Q gq
|
|
|
|
|
nmap Q gqap
|
|
|
|
|
|
|
|
|
|
" launch fzf for the current git repo
|
|
|
|
|
nnoremap <C-p> :GitFiles<CR>
|
|
|
|
|
|
|
|
|
|
" launch fzf for files in the current directory
|
|
|
|
|
nnoremap <C-o> :Files<CR>
|
|
|
|
|
|
|
|
|
|
" launch fzf for files modified or not in git
|
|
|
|
|
nnoremap <C-u> :GFiles?<CR>
|
|
|
|
|
|
2017-02-28 10:56:23 -06:00
|
|
|
|
" launch fzf for open buffers (files)
|
|
|
|
|
nnoremap <C-b> :Buffers<CR>
|
|
|
|
|
|
2017-02-08 11:54:30 -06:00
|
|
|
|
" launch fzf for open buffers (files)
|
|
|
|
|
nnoremap <leader>l :Buffers<CR>
|
|
|
|
|
|
|
|
|
|
" switch to previous buffer
|
|
|
|
|
nnoremap <leader>h :b#<CR>
|
|
|
|
|
|
|
|
|
|
" use leader j and k to switch buffers as well
|
|
|
|
|
nnoremap <leader>k :bnext<CR>
|
|
|
|
|
nnoremap <leader>j :bprevious<CR>
|
|
|
|
|
nnoremap <C-k> :bnext<CR>
|
|
|
|
|
nnoremap <C-j> :bprevious<CR>
|
|
|
|
|
|
|
|
|
|
" fast word change
|
|
|
|
|
nnoremap <leader>c ciw
|
|
|
|
|
nnoremap <leader>C ciW
|
|
|
|
|
|
|
|
|
|
" bash-like deletion
|
|
|
|
|
inoremap <C-BS> <C-w>
|
|
|
|
|
inoremap <A-BS> <C-w>
|
|
|
|
|
|
|
|
|
|
" clear search higlight
|
|
|
|
|
nnoremap <leader>/ :let @/ = ""<CR>
|
|
|
|
|
|
2017-02-28 10:56:23 -06:00
|
|
|
|
" remap jk/jj and its variants to escape
|
2017-02-08 11:54:30 -06:00
|
|
|
|
inoremap jj <Esc>
|
|
|
|
|
inoremap Jj <Esc>
|
|
|
|
|
inoremap Jj <Esc>
|
|
|
|
|
inoremap JJ <Esc>
|
|
|
|
|
inoremap jk <Esc>
|
|
|
|
|
inoremap Jk <Esc>
|
|
|
|
|
inoremap jK <Esc>
|
|
|
|
|
inoremap JK <Esc>
|
|
|
|
|
|
|
|
|
|
" use hjkl-movement between rows when soft wrapping:
|
|
|
|
|
nnoremap j gj
|
|
|
|
|
nnoremap k gk
|
|
|
|
|
vnoremap j gj
|
|
|
|
|
vnoremap k gk
|
|
|
|
|
|
|
|
|
|
" camel case movements
|
|
|
|
|
map <silent> ,w <Plug>CamelCaseMotion_w
|
|
|
|
|
map <silent> ,b <Plug>CamelCaseMotion_b
|
|
|
|
|
map <silent> ,e <Plug>CamelCaseMotion_e
|
|
|
|
|
map <silent> ,ge <Plug>CamelCaseMotion_ge
|
|
|
|
|
|
|
|
|
|
" inner _ objects
|
|
|
|
|
omap <silent> ib <Plug>CamelCaseMotion_ib
|
|
|
|
|
xmap <silent> ib <Plug>CamelCaseMotion_ib
|
|
|
|
|
omap <silent> ie <Plug>CamelCaseMotion_ie
|
|
|
|
|
xmap <silent> ie <Plug>CamelCaseMotion_ie
|
|
|
|
|
|
|
|
|
|
" a _ objects
|
2017-02-28 10:56:23 -06:00
|
|
|
|
" omap <silent> aw <Plug>CamelCaseMotion_aw
|
|
|
|
|
" xmap <silent> aw <Plug>CamelCaseMotion_aw
|
2017-02-08 11:54:30 -06:00
|
|
|
|
omap <silent> ab <Plug>CamelCaseMotion_ab
|
|
|
|
|
xmap <silent> ab <Plug>CamelCaseMotion_ab
|
|
|
|
|
omap <silent> ae <Plug>CamelCaseMotion_ae
|
|
|
|
|
xmap <silent> ae <Plug>CamelCaseMotion_ae
|
|
|
|
|
|
2017-02-28 10:56:23 -06:00
|
|
|
|
" remove trailing whitespace
|
2017-02-08 11:54:30 -06:00
|
|
|
|
map <F3> mw:%s/\s\+$//<CR>:let @/ = ""<CR>'w
|
|
|
|
|
|
2017-02-28 10:56:23 -06:00
|
|
|
|
" close buffer with leader-w
|
2017-02-08 11:54:30 -06:00
|
|
|
|
nnoremap <silent> <leader>w :bd<CR>
|
|
|
|
|
|
|
|
|
|
" toggle spell checking:
|
|
|
|
|
map <F5> :setlocal spell!<CR>
|
|
|
|
|
|
|
|
|
|
" open urls, files, etc. example: http://google.com:
|
|
|
|
|
noremap <leader>o :!xdg-open <cfile><CR><CR>
|
|
|
|
|
|
2017-04-02 16:35:39 -05:00
|
|
|
|
" run `make run`
|
|
|
|
|
nnoremap <leader>R :ProjectRootExe !make run<cfile><CR><CR>
|
|
|
|
|
|
2017-03-02 19:33:40 -06:00
|
|
|
|
" insert newline
|
2017-03-08 15:06:56 -06:00
|
|
|
|
" doesn't work in terminals?
|
2017-03-02 19:33:40 -06:00
|
|
|
|
noremap <S-Enter> i<Enter><Esc>
|
2017-03-08 15:06:56 -06:00
|
|
|
|
" noremap <C-o> i<Enter><Esc>
|
2017-03-02 19:33:40 -06:00
|
|
|
|
|
2017-02-28 10:56:23 -06:00
|
|
|
|
" keep that dumb window from popping up (wild something or another)
|
2017-02-08 11:54:30 -06:00
|
|
|
|
map q: :q
|
|
|
|
|
noremap qqq: q:
|
|
|
|
|
|
|
|
|
|
" sane n/N behavior
|
|
|
|
|
nnoremap <expr> n 'Nn'[v:searchforward]
|
|
|
|
|
nnoremap <expr> N 'nN'[v:searchforward]
|
|
|
|
|
|
|
|
|
|
" better command history navigation
|
|
|
|
|
cnoremap <c-n> <down>
|
|
|
|
|
cnoremap <c-p> <up>
|
|
|
|
|
|
|
|
|
|
" keep selection after indenting visual selection
|
|
|
|
|
xnoremap < <gv
|
|
|
|
|
xnoremap > >gv
|
|
|
|
|
|
|
|
|
|
" modify higlight colors
|
|
|
|
|
hi Search cterm=NONE ctermbg=blue ctermfg=black
|
2017-02-28 10:56:23 -06:00
|
|
|
|
highlight LineNr ctermbg=none ctermfg=8
|
|
|
|
|
highlight CursorLineNr ctermbg=18 ctermfg=gray
|
2017-03-08 15:06:56 -06:00
|
|
|
|
|
|
|
|
|
fun! VueModifiedFT()
|
|
|
|
|
set ft=vue
|
|
|
|
|
endfunction
|
|
|
|
|
:command! VueModifiedFT call VueModifiedFT()
|
|
|
|
|
autocmd BufRead,BufNewFile *.vue VueModifiedFT
|