This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/editor/nvim/config/init.vim

443 lines
12 KiB
VimL
Raw Normal View History

2016-02-11 02:20:45 -06:00
" initial plugin manager
2016-01-06 11:55:04 -06:00
if empty(glob('~/.config/nvim/autoload/plug.vim'))
2016-06-23 18:53:46 -05:00
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall
2016-01-06 11:55:04 -06:00
endif
2016-02-11 02:20:45 -06:00
" tell vim to reload the init.vim file when it saves it
autocmd! BufWritePost init.vim source %
2016-11-03 12:34:33 -05: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
2016-01-06 11:55:04 -06:00
" Initialize plugin manager
2016-02-11 02:20:45 -06:00
call plug#begin('~/.config/nvim/bundle')
2016-01-06 11:55:04 -06:00
2016-02-11 02:20:45 -06:00
" let plugin manager manage itself
Plug 'junegunn/vim-plug'
2016-01-06 11:55:04 -06:00
2016-02-11 02:20:45 -06:00
" plugins
2016-01-06 11:55:04 -06:00
Plug 'tpope/vim-obsession' " session ease-of-use
2016-10-06 13:03:17 -05:00
if exists('asmanviewer')
let g:prosession_dir = '/dev/null'
else
Plug 'dhruvasagar/vim-prosession' " more session ease-of-use
let g:prosession_dir = '~/.config/nvim/session/'
endif
2016-03-29 20:16:43 -05:00
Plug 'vim-airline/vim-airline' " statusline
2016-06-23 18:53:46 -05:00
" let g:airline_powerline_fonts = 0
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 = ''
2016-03-29 20:16:43 -05:00
Plug 'vim-airline/vim-airline-themes'
2016-01-06 11:55:04 -06:00
2016-02-11 02:20:45 -06:00
Plug 'scrooloose/nerdtree', {'on': ['NERDTreeToggle', 'NERDTree']} " nice sidebar for files
2016-06-23 18:53:46 -05:00
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
2016-02-11 02:20:45 -06:00
2016-06-23 18:53:46 -05:00
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
2016-02-11 02:20:45 -06:00
2016-08-10 12:13:05 -05:00
Plug 'Shougo/deoplete.nvim', { 'do': function('DoRemote') } " autocomplete
2016-06-23 18:53:46 -05:00
let g:deoplete#enable_at_startup = 1
2016-02-11 02:20:45 -06:00
Plug 'scrooloose/syntastic' " syntax checker
2016-09-24 06:25:35 -05:00
Plug 'freitass/todo.txt-vim' " syntax checker
Plug 'bkad/CamelCaseMotion' " camel case and underscore word movements
2016-02-11 02:20:45 -06:00
Plug 'LargeFile' " gracefully handle very large files
Plug 'tpope/vim-commentary' " toggle comments in code easily
Plug 'tmux-plugins/vim-tmux-focus-events' " allow transitions within tmux
Plug 'christoomey/vim-tmux-navigator' " allow transitions within tmux
Plug 'tasklist.vim' " show tasks with leader,t
Plug 'godlygeek/tabular' " align text lines together
2016-09-14 19:03:33 -05:00
Plug 'dhruvasagar/vim-table-mode' " for creating and editing character tables
2016-07-19 13:25:54 -05:00
Plug 'lytedev/vim-superman' " view man pages with vim
2016-02-11 02:20:45 -06:00
Plug 'tpope/vim-surround' " quickly modify text surrounding objects
Plug 'tpope/vim-speeddating' " vim knows about date-like text objects
2016-03-29 20:12:29 -05:00
Plug 'michaeljsmith/vim-indent-object' " adds an indentation level text object
Plug 'wellle/targets.vim' " adds some more handy text objects
Plug 'ternjs/tern_for_vim', { 'do': 'npm install' }
2016-10-06 13:22:39 -05:00
Plug 'mikewest/vimroom'
2016-12-01 15:13:01 -06:00
Plug 'editorconfig/editorconfig-vim' " loads project-specific editor settings
2016-11-03 12:34:33 -05:00
let g:vimroom_sidebar_height = 0
2016-02-11 02:20:45 -06:00
2016-07-27 04:57:23 -05:00
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' }
2016-02-11 02:20:45 -06:00
" plugins for specific file types
2016-01-06 11:55:04 -06:00
Plug 'kchmck/vim-coffee-script', {'for': ['coffee', 'coffeescript', 'vue']}
Plug 'posva/vim-vue', {'for': ['vue']}
Plug 'elixir-lang/vim-elixir', {'for': ['elixir']}
Plug 'wavded/vim-stylus', {'for': ['styl', 'stylus', 'vue']}
Plug 'rust-lang/rust.vim', {'for': ['rs', 'rust']}
Plug 'plasticboy/vim-markdown', {'for': ['md', 'markdown']}
2016-11-03 12:34:33 -05:00
Plug 'euclio/vim-markdown-composer', { 'do': function('BuildComposer'), 'for': ['md', 'markdown'] }
2016-07-14 15:22:19 -05:00
Plug 'digitaltoad/vim-jade', {'for': ['pug', 'jade', 'vue']}
2016-01-06 11:55:04 -06:00
Plug 'freitass/todo.txt-vim', {'for': ['todo']}
Plug 'leafo/moonscript-vim', {'for': ['moon', 'moonscript']}
Plug 'evidens/vim-twig'
2016-10-06 13:03:17 -05:00
Plug 'leafgarland/typescript-vim', {'for': ['ts', 'typescript']}
2016-01-06 11:55:04 -06:00
call plug#end()
filetype on
filetype indent on
filetype plugin on
2016-02-11 02:20:45 -06:00
" language specific configuration
" C
2016-01-06 11:55:04 -06:00
let c_space_errors = 1
2016-06-07 02:55:31 -05:00
let c_comment_strings = 0 " dont highlight strings inside C comments
2016-01-06 11:55:04 -06:00
2016-02-11 02:20:45 -06:00
" Python
2016-01-06 11:55:04 -06:00
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
2016-01-06 11:55:04 -06:00
2016-02-11 02:20:45 -06:00
" HAMLC
2016-01-06 11:55:04 -06:00
autocmd BufRead,BufNewFile *.hamlc set ft=haml
2016-02-11 02:20:45 -06:00
" Markdown
2016-01-06 11:55:04 -06:00
autocmd BufNewFile,BufReadPost *.md setl filetype=markdown spell textwidth=0 wrapmargin=0
2016-02-11 02:20:45 -06:00
" Text
2016-01-06 11:55:04 -06:00
autocmd BufNewFile,BufReadPost *.txt setl spell textwidth=0 wrapmargin=0
2016-02-11 02:20:45 -06:00
" whitespace
2016-06-12 23:58:16 -05:00
set tabstop=2
2016-01-06 11:55:04 -06:00
set shiftwidth=2
set softtabstop=2
2016-12-01 15:13:01 -06:00
set expandtab
2016-01-06 11:55:04 -06:00
set autoindent smartindent
2016-06-23 18:53:46 -05:00
set list
2016-07-22 01:15:57 -05:00
set nostartofline
2016-06-23 18:53:46 -05:00
set listchars=trail,tab:\ \
2016-01-06 11:55:04 -06:00
2016-02-11 02:20:45 -06:00
" look and feel
2016-01-06 11:55:04 -06:00
set wrap
set linebreak
set breakindent
set textwidth=80
2016-02-11 02:20:45 -06:00
set formatoptions=crql1j
2016-06-23 18:53:46 -05:00
" 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
2016-01-06 11:55:04 -06:00
2016-02-11 02:20:45 -06:00
set title " handle window title
2016-01-06 11:55:04 -06:00
set synmaxcol=2048
2016-07-19 13:25:54 -05:00
if exists('asmanviewer')
set nonumber " no line numbers when viewing a man page
else
set number " line numbers
endif
2016-02-11 02:20:45 -06:00
" set relativenumber
set cursorline " highlight the current line
" set cursorcolumn " highlight the current column
" let &colorcolumn=join(range(81,400),",") " colors columns past 80
2016-01-06 11:55:04 -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
2016-02-11 02:20:45 -06:00
set isfname+=32
set vb t_vb=
if has('autocmd')
2016-06-23 18:53:46 -05:00
autocmd GUIEnter * set visualbell t_vb=
2016-02-11 02:20:45 -06:00
endif
2016-01-06 11:55:04 -06:00
let base16colorspace=256
set background=dark
colorscheme current
fun! ShowSpaceIndentation()
hi WhiteSpaces ctermfg=black ctermbg=8
match WhiteSpaces /^ \+/
endfunction
2016-10-06 13:03:17 -05:00
let s:distractionFreeMode = 0
fun! DistractionFreeModeFunc()
AirlineToggle
2016-10-06 13:22:39 -05:00
VimroomToggle
2016-10-06 13:03:17 -05:00
if s:distractionFreeMode == 0
let s:distractionFreeMode = 1
set laststatus=0
set noshowmode
set noruler
set noshowcmd
set nonumber
2016-10-06 13:22:39 -05:00
hi NonText ctermfg=black guifg=black
2016-10-06 13:03:17 -05:00
else
let s:distractionFreeMode = 0
set showmode
set ruler
set laststatus=2
set showcmd
set number
2016-10-06 13:22:39 -05:00
hi NonText ctermfg=gray guifg=gray
2016-10-06 13:03:17 -05:00
endif
endfunction
2016-10-06 13:22:39 -05:00
nnoremap <silent> <Leader>mz :DistractionFreeMode<CR>
:command! SpaceIndents call ShowSpaceIndentation()
2016-10-06 13:03:17 -05:00
:command! ShowSpaceIndents call ShowSpaceIndentation()
:command! DistractionFreeMode call DistractionFreeModeFunc()
2016-06-23 18:53:46 -05:00
set hidden " allows buffer switching without saving
2016-01-06 11:55:04 -06:00
set shortmess=I
set history=1000
set undofile
set undodir=$HOME/.config/nvim/undo
set undolevels=1000
set undoreload=10000
set backupdir=$HOME/.config/nvim/backup
set directory=$HOME/.config/nvim/backup
set spellfile=$HOME/.config/nvim/spell/en.utf-8.add
set ignorecase
set smartcase
set incsearch
set hlsearch
set wrapscan
2016-02-11 02:20:45 -06:00
set foldmethod=syntax
set foldlevel=99
set foldnestmax=10
set nofoldenable
set foldlevelstart=1
if has('vim_starting')
2016-06-23 18:53:46 -05:00
set encoding=utf8
2016-02-11 02:20:45 -06:00
endif
set autowrite
set autochdir
set autoread
set nomodeline
2016-03-29 20:16:43 -05:00
" yank to OS clipboard
set clipboard+=unnamed
2016-02-11 02:20:45 -06:00
" allows for manual and syntax folding... supposedly
augroup vimrc
2016-06-23 18:53:46 -05:00
au BufReadPre * setlocal foldmethod=indent
au BufWinEnter * if &fdm == 'indent' | setlocal foldmethod=manual | endif
2016-02-11 02:20:45 -06:00
augroup END
" jump to last opened position in file
if has("autocmd")
2016-06-23 18:53:46 -05:00
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
2016-02-11 02:20:45 -06:00
endif
" no empty buffer on startup
autocmd VimEnter * nested if bufname('')=='' && line('$') == 1 && col('$')==1 && !&modified | bd % | endif
2016-07-19 13:25:54 -05:00
function! TerminalSplit()
2016-07-22 01:15:57 -05:00
let current_file = @%
echo current_file
if match(current_file, "term://*") != -1
split
terminal
else
vsplit
vertical resize 80
terminal
endif
2016-07-19 13:25:54 -05:00
endfunction
2016-02-11 02:20:45 -06:00
" bindings
" common typo fixes
2016-01-06 11:55:04 -06:00
command! WQ wq
command! Wq wq
command! Wqa wqa
command! W w
command! Q q
2016-02-11 02:20:45 -06:00
" best leader
2016-01-06 11:55:04 -06:00
let mapleader = "\<Space>"
2016-07-19 13:25:54 -05:00
" terminal mappings
" open a terminal split at 80 columns
nnoremap <C-t> :call TerminalSplit()<CR>
2016-07-22 01:15:57 -05:00
tnoremap <C-t> <C-\><C-n>:call TerminalSplit()<CR>
2016-07-19 13:25:54 -05:00
" close the terminal
tnoremap <C-w> <C-\><C-n>:q!<CR>
" 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
" enter insert mode when entering a terminal buffer
autocmd BufWinEnter,WinEnter term://* startinsert
2016-02-11 02:20:45 -06:00
" change buffers with leader,tab
2016-01-06 11:55:04 -06:00
nnoremap <leader><Tab> :bnext<CR>
nnoremap <leader><S-Tab> :bprevious<CR>
" don't kill vim
nnoremap <leader>K <Nop>
2016-02-11 02:20:45 -06:00
nnoremap <S-K> <NOP>
" nerdtree
nnoremap <C-n> :NERDTree<CR>
" run macro across visually selected lines
xnoremap @ :<C-u>call ExecuteMacroOverVisualRange()<CR>
function! ExecuteMacroOverVisualRange()
2016-06-23 18:53:46 -05:00
echo "@".getcmdline()
execute ":'<,'>normal @".nr2char(getchar())
2016-02-11 02:20:45 -06:00
endfunction
2016-01-06 11:55:04 -06:00
" quick paragraph formatting
vmap Q gq
nmap Q gqap
" launch fzf for the current git repo
2016-12-01 15:13:01 -06:00
nnoremap <C-p> :GitFiles<CR>
2016-01-06 11:55:04 -06:00
2016-12-01 15:13:01 -06:00
" launch fzf for files in the current directory
nnoremap <C-o> :Files<CR>
" launch fzf for files modified or not in git
nnoremap <C-o> :GFiles?<CR>
" launch fzf for open buffers (files)
nnoremap <leader>l :Buffers<CR>
" switch to previous buffer
nnoremap <leader>h :b#<CR>
2016-02-11 02:20:45 -06:00
" use leader j and k to switch buffers as well
2016-01-06 11:55:04 -06:00
nnoremap <leader>k :bnext<CR>
nnoremap <leader>j :bprevious<CR>
2016-02-11 02:20:45 -06:00
nnoremap <C-k> :bnext<CR>
nnoremap <C-j> :bprevious<CR>
2016-01-06 11:55:04 -06:00
" 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>
2016-02-11 02:20:45 -06:00
" remap jk and kj to escape in insert mode
2016-01-06 11:55:04 -06:00
inoremap jj <Esc>
2016-02-11 02:20:45 -06:00
inoremap Jj <Esc>
inoremap Jj <Esc>
inoremap JJ <Esc>
inoremap jk <Esc>
inoremap Jk <Esc>
inoremap jK <Esc>
inoremap JK <Esc>
2016-01-06 11:55:04 -06:00
" 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
omap <silent> aw <Plug>CamelCaseMotion_aw
xmap <silent> aw <Plug>CamelCaseMotion_aw
omap <silent> ab <Plug>CamelCaseMotion_ab
xmap <silent> ab <Plug>CamelCaseMotion_ab
omap <silent> ae <Plug>CamelCaseMotion_ae
xmap <silent> ae <Plug>CamelCaseMotion_ae
2016-01-06 11:55:04 -06:00
" remove trailing whitespace:
2016-02-11 02:20:45 -06:00
map <F3> mw:%s/\s\+$//<CR>:let @/ = ""<CR>'w
2016-01-06 11:55:04 -06:00
" close buffer:
2016-02-11 02:20:45 -06:00
nnoremap <silent> <leader>w :bd<CR>
2016-01-06 11:55:04 -06:00
" toggle spell checking:
map <F5> :setlocal spell!<CR>
" open urls, files, etc. example: http://google.com:
noremap <leader>o :!xdg-open <cfile><CR><CR>
" keep that dumb window from popping up
map q: :q
2016-02-11 02:20:45 -06:00
noremap qqq: q:
2016-01-06 11:55:04 -06:00
2016-01-11 09:22:54 -06:00
" 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>
2016-02-11 02:20:45 -06:00
" keep selection after indenting visual selection
2016-01-11 09:22:54 -06:00
xnoremap < <gv
xnoremap > >gv
" modify higlight colors
hi Search cterm=NONE ctermbg=blue ctermfg=black