Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 1019 lines (835 sloc) 29.2 KB
" vim: set foldmethod=marker foldlevel=0 nomodeline:
" ============================================================================
" .vimrc of grepinsight
" ============================================================================
" Variables {{{
" ============================================================================
let vimrplugin_assign = 0 " Stop annoying vimRplugin reassignment
let s:darwin = has('mac')
" }}}
" ============================================================================
" Basic Settings {{{
" ============================================================================
"
"nnoremap <Leader>dos :e ++ff=dos<CR> | set ff=unix <CR>
" Vim 8 defaults
unlet! skip_defaults_vim
silent! source $VIMRUNTIME/defaults.vim
syntax on
set encoding=UTF-8
filetype plugin indent on
runtime macros/matchit.vim
set pastetoggle=<F6>
set history=1000 " enable longer command mode history
set autoread " automatically read changed file again
set autowrite
set nocompatible " enable modern vim features
set cursorline " highlight current line
set lazyredraw " redraw only when we need to.
set showmatch " highlight matching [{()}]
set foldenable " enable folding
set foldlevelstart=10 " open most folds by default
set foldmethod=indent " fold based on indent level
set splitright " split navigation
set hidden " allow modified/unsaved buffers in the background.
set number " set number
set smartcase " if capital letter is used, then do not ignore case
set ignorecase
set shiftwidth=4 " size of an indent
set softtabstop=4 " Indentation levels very four columns"
"set expandtab " tabs are spaces
set tabstop=4 " size of a hard tabstop number of visual spaces per TAB
set incsearch " search as characters are entered
set hlsearch " highlight matches
set path+=** " provides tab-completion for all file-related tasks
set wildmenu " display all matching files when we tab complete
nnoremap <SPACE> <Nop>
let maplocalleader=" "
"set clipboard=unnamed
" }}}
" ============================================================================
" VIM_PLUGIN BLOCK {{{
" ============================================================================
" ----------------------------------------------------------------------------
" Automatically install Vim Plug {{{
" ----------------------------------------------------------------------------
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/plugged')
" Basic setup
Plug 'tpope/vim-sensible'
" Looks / Status
Plug 'flazz/vim-colorschemes'
Plug 'vim-airline/vim-airline'
Plug 'junegunn/seoul256.vim'
Plug 'ryanoasis/vim-devicons'
"Plug 'yuttie/comfortable-motion.vim'
" Session Management
Plug 'tpope/vim-obsession'
" Buffer Management
Plug 'vim-scripts/BufOnly.vim'
" Files related
Plug 'scrooloose/nerdtree'
Plug 'francoiscabrol/ranger.vim'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'tpope/vim-eunuch'
" Search files
Plug 'ctrlpvim/ctrlp.vim'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'junegunn/vim-peekaboo'
Plug 'mileszs/ack.vim'
Plug 'mhinz/vim-grepper'
let g:grepper = {}
runtime autoload/grepper.vim
let g:grepper.tools = ['rg', 'git', 'ag']
let g:grepper.jump = 1
let g:grepper.stop = 500
noremap <leader>gr :GrepperRg<Space>
nmap gs <plug>(GrepperOperator)
xmap gs <plug>(GrepperOperator)
" Navigation
Plug 'Lokaltog/vim-easymotion'
Plug 'vim-scripts/taglist.vim'
Plug 'majutsushi/tagbar'
Plug 'tpope/vim-projectionist'
Plug 'tpope/vim-unimpaired'
Plug 'christoomey/vim-tmux-navigator'
Plug 'MattesGroeger/vim-bookmarks'
" Editing
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'terryma/vim-multiple-cursors'
Plug 'junegunn/vim-after-object'
Plug 'sjl/gundo.vim'
Plug 'tpope/vim-commentary'
Plug 'tommcdo/vim-exchange'
Plug 'jiangmiao/auto-pairs'
Plug 'Yggdroot/indentLine'
Plug 'bronson/vim-trailing-whitespace'
Plug 'dhruvasagar/vim-table-mode'
Plug 'Konfekt/FastFold'
Plug 'kalekundert/vim-coiled-snake'
" Git
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'junegunn/gv.vim'
" Testing
Plug 'metakirby5/codi.vim'
Plug 'janko-m/vim-test'
Plug 'tpope/vim-dispatch'
" Python/Go
Plug 'davidhalter/jedi-vim'
Plug 'fatih/vim-go'
Plug 'michaeljsmith/vim-indent-object'
" Lint
Plug 'w0rp/ale'
" Completions and snippets
if v:version >= 800
try
Plug 'Valloric/YouCompleteMe'
catch
endtry
endif
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'ervandew/supertab'
Plug 'grepinsight/mysnippets'
" Writing
Plug 'plasticboy/vim-markdown'
Plug 'tpope/vim-abolish'
Plug 'junegunn/goyo.vim'
Plug 'junegunn/limelight.vim'
Plug 'beloglazov/vim-online-thesaurus'
Plug 'vimwiki/vimwiki'
Plug 'lervag/vimtex'
" Interactive coding
Plug 'jpalardy/vim-slime'
" Reading
Plug 'JamshedVesuna/vim-markdown-preview'
Plug 'wikimatze/hammer.vim'
" Misc
Plug 'wincent/terminus' " Make terminal and vim play nicely. Supports auto change
Plug 'szw/vim-g'
Plug 'mattn/emmet-vim'
Plug 'tomtom/tlib_vim'
Plug 'itchyny/calendar.vim'
Plug 'sgur/vim-editorconfig'
" Syntax Highlighting
Plug 'maverickg/stan.vim'
Plug 'ibab/vim-snakemake'
call plug#end()
" }}}
" ============================================================================
" Productivity Aliases {{{
" ============================================================================
" never ring a bell
if exists('&belloff')
set belloff=all
endif
" First line
nnoremap <LocalLeader>q :quit <CR>
nnoremap <LocalLeader>w :write <CR>
nnoremap <LocalLeader>wq :wq <CR>
nnoremap <LocalLeader>e :edit <C-R>=expand('%:p:h') . '/' <CR>
nnoremap <LocalLeader>o :only<CR>
nnoremap <LocalLeader>p :echo expand('%') <CR>
nnoremap <LocalLeader>a :A <CR>
" 3rd line
nnoremap <LocalLeader>c :ccl<CR>
nmap <LocalLeader>b :Buffers<CR>
nnoremap <LocalLeader><LocalLeader> <C-^>
" ----------------------------------------------------------------------------
" R assignment {{{
execute "set <M-->=\033-"
execute "set <M-m>=\033m"
inoremap <M--> <-
inoremap <M-m> %>%
command! MakeTags !ctags -R .
" }}}
" ----------------------------------------------------------------------------
nnoremap <Leader>vv :e $HOME/.dotfiles/vim/vim.cheatsheet.md<CR>
"insert file name : \fn in insert mode
inoremap \fn <C-R>=expand("%:t")<CR>
inoremap <Leader>fn <C-R>=expand("%:t")<CR>
"focus current fold
nnoremap zs zMzvzz
nnoremap <Leader>fmi :set foldmethod=indent<CR>
nnoremap <Leader>fms :set foldmethod=syntax<CR>
" Make movement more visual oriented
nnoremap j gj
nnoremap k gk
xnoremap j gj
xnoremap k gk
" Make movement between windows more intuitive
nmap gh <C-w>h
nmap gj <C-w>j
nmap gk <C-w>k
nmap gl <C-w>l
nmap <leader>l :setlocal number!<CR>
nmap \q :nohlsearch<CR>
nmap <leader>e :NERDTreeToggle<CR>
" Use sane regexes.
nnoremap / /\v
vnoremap / /\v
"Keep search matches in the middle of the window and pulse the line when moving to them
nnoremap n nzzzv
nnoremap N Nzzzv
nnoremap vv ^vg_
" Make execute able
nnoremap <Leader>x :!chmod 750 %<CR>
" space open/closes folds
nnoremap <space> za
" highlight last inserted text
nnoremap gV `[v`]
" Editing source files
nnoremap <Leader>ev :e $HOME/.dotfiles/vim/vimrc<CR>
nnoremap <Leader>sv :source $MYVIMRC<CR>
nnoremap <Leader>es :vsplit ~/.vim/plugged/mysnippets/UltiSnips<CR>
"reselect after indenting
vnoremap < <gv
vnoremap > >gv
"never use Ex mode -- I never *mean* to press it
nnoremap Q <ESC>
"Escape Mode
imap jj <Esc>
"never use F1 -- I'm reaching for escape
noremap <F1> <ESC>
noremap! <F1> <ESC>
lnoremap <F1> <ESC>
nnoremap aa pkj
nnoremap <Leader>c :ccl<CR>
nnoremap <Leader>t :sp ~/vimwiki/diary/<C-R>=strftime("%Y-%m-%d")<CR>.wiki<CR>
" Buffers {{{
" close buffer
nnoremap BB :bd<CR>
nnoremap QQ :q<CR>
nnoremap <F4> :bd<CR>
" reopen the closed buffer
nnoremap <c-s-t> :b#<CR>:e<CR>
" }}}
" line find
nnoremap <Leader>lf :Lines<CR>
" Bash alias shortcut {{{
nnoremap <Leader>bas :tabnew $HOME/.dotfiles/bash/share/bash_aliases_share<CR>
nnoremap <Leader>bcs :tabnew $HOME/.dotfiles/bash/share/bash_colors_share<CR>
nnoremap <Leader>bfs :tabnew $HOME/.dotfiles/bash/share/bash_functions_share<CR>
nnoremap <Leader>bss :tabnew $HOME/.dotfiles/bash/share/bash_settings_share<CR>
nnoremap <Leader>bal :tabnew $HOME/.dotfiles/bash/local/bash_aliases_local<CR>
nnoremap <Leader>bpl :tabnew $HOME/.dotfiles/bash/local/bash_paths_local<CR>
nnoremap <Leader>bsl :tabnew $HOME/.dotfiles/bash/local/bash_settings_local<CR>
" }}}
"Align Text {{{
nnoremap <leader>Al :left<cr>
nnoremap <leader>Ac :center<cr>
nnoremap <leader>Ar :right<cr>
vnoremap <leader>Al :left<cr>
vnoremap <leader>Ac :center<cr>
vnoremap <leader>Ar :right<cr>
"}}}
"
" Run commands
nnoremap <Leader>pl :w<CR> :!perl %<CR>
nnoremap <Leader>cc :w<CR> :!g++ %;./a.exe<CR>
nnoremap <Leader>py :w<CR> :!python %<CR>
" reverse join
nnoremap <Leader>j kJ
" PythonRelated
function! ImportFix()
^cwfrom^[$F.r i import^[^
endfunction
" TODO run it only on python file and only if yapf is available
" setlocal equalprg=yapf
nnoremap <Leader>if ^cwfrom<Esc>$F.r i import<Esc>^
" Notes
" }}}
" ============================================================================
" Advanced Settings --------------------------------------------------{{{
"
" ----------------------------------------------------------------------------
" Undo {{{
"
set undofile " Save undos after file closes
set undodir=$HOME/.vim/undo " where to save undo histories
set undolevels=10000 " How many undos
set undoreload=10000 " number of lines to save for undo
" }}}
" ----------------------------------------------------------------------------
" Spelling related {{{
let g:spell_is_open = 0
function! SpellToggle()
if g:spell_is_open
let g:spell_is_open = 0
:w
:mkspell! $HOME/.dotfiles/vim/spell/en.utf-8.add
:bd
execute g:spell_return_to_window . "wincmd w"
else
let g:spell_return_to_window = winnr()
:vsplit $HOME/.dotfiles/vim/spell/en.utf-8.add
let g:spell_is_open = 1
endif
endfunction
nnoremap <Leader>sp :call SpellToggle()<CR>
nnoremap <Leader>nsp :set nospell<CR>
nnoremap <Leader>ssp :set spell<CR>
inoremap <Leader>sp <Esc>:call SpellToggle()<CR>
" }}}
" ----------------------------------------------------------------------------
" ----------------------------------------------------------------------------
" Notes Related {{{
nnoremap <Leader>nt :e $INSIGHT_NOTEPATH/<C-R>=strftime("%Y-%m-%d")<CR>.md<CR>
nnoremap <Leader>vn :e $INSIGHT_NOTEPATH/<C-R>=strftime("%Y-%m-%d")<CR>.md<CR>
nnoremap <Leader>no :call NoteToggle()<CR>
inoremap <Leader>no <Esc>:call NoteToggle()<CR>
"""
let g:note_is_open = 0
function! NoteToggle()
if g:note_is_open
let g:note_is_open = 0
" TODO close CMD here
:w
:bd
execute g:note_return_to_window . "wincmd w"
else
let g:note_return_to_window = winnr()
:vsplit $HOME/src/notes/scratch.md
let g:note_is_open = 1
endif
endfunction
" }}}
" ----------------------------------------------------------------------------
" ----------------------------------------------------------------------------
" Mouse Related {{{
" Allow mouse for easy resizing
" set mouse=a
" set ttymouse=xterm2
" set mouse+=a
" if &term =~ '^screen'
" " tmux knows the extended mouse mode
" set ttymouse=xterm2
" endif
" set mouse=c
" }}}
" ----------------------------------------------------------------------------
" Ctags Tricks
map <Leader>] :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
map <Leader>v :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
"}}}
" ============================================================================
" Auto settings {{{
" ============================================================================
"save when losing focus
au FocusLost * :silent! wall
au FocusLost * :wa
" Make sure Vim returns to the same line when you reopen a file.
augroup line_return
au!
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ execute 'normal! g`"zvzz' |
\ endif
augroup END
au CursorHold * checktime
function! NumberToggle()
if(&relativenumber == 1)
set norelativenumber
set number
else
set relativenumber
endif
endfunc
nnoremap <Leader>rel :call NumberToggle()<cr>
set relativenumber
"au FocusLost * :set number
"au FocusGained * :set relativenumber
" }}}
" ============================================================================
function! MarkWindowSwap() "{{{
let g:markedWinNum = winnr()
endfunction
function! DoWindowSwap()
"Mark destination
let curNum = winnr()
let curBuf = bufnr( "%" )
exe g:markedWinNum . "wincmd w"
"Switch to source and shuffle dest->source
let markedBuf = bufnr( "%" )
"Hide and open so that we aren't prompted and keep history
exe 'hide buf' curBuf
"Switch to dest and shuffle source->dest
exe curNum . "wincmd w"
"Hide and open so that we aren't prompted and keep history
exe 'hide buf' markedBuf
endfunction
nmap <silent> <leader>mw :call MarkWindowSwap()<CR>
nmap <silent> <leader>pw :call DoWindowSwap()<CR>
"""""""""""""""""
" Ack motions {{{
" Motions to Ack for things. Works with pretty much everything, including:
"
" w, W, e, E, b, B, t*, f*, i*, a*, and custom text objects
"
" Awesome.
"
" Note: If the text covered by a motion contains a newline it won't work. Ack
" searches line-by-line.
nnoremap <silent> <leader>A :set opfunc=<SID>AckMotion<CR>g@
xnoremap <silent> <leader>A :<C-U>call <SID>AckMotion(visualmode())<CR>
xnoremap <silent> <leader>A :<C-U>call <SID>AckMotion(visualmode())<CR>
"nnoremap <bs> :Ack! '\b<c-r><c-w>\b'<cr>
"xnoremap <silent> <bs> :<C-U>call <SID>AckMotion(visualmode())<CR>
nmap <Leader>ack :Ack! "\b<cword>\b" <CR>
function! s:CopyMotionForType(type)
if a:type ==# 'v'
silent execute "normal! `<" . a:type . "`>y"
elseif a:type ==# 'char'
silent execute "normal! `[v`]y"
endif
endfunction
function! s:AckMotion(type) abort
let reg_save = @@
call s:CopyMotionForType(a:type)
execute "normal! :Ack! --literal " . shellescape(@@) . "\<cr>"
let @@ = reg_save
endfunction
" check file change every 4 seconds ('CursorHold') and reload the buffer upon detecting change
au CursorHold * checktime
" Useful hotkeys
nnoremap <Leader>gi :e ./.gitignore<CR>
nnoremap <Leader>btt :bufdo tab split<CR>
nnoremap <Leader>tc :tabclose<CR>
nnoremap <Leader>ls :ls<CR>
" Open markdown
nnoremap <Leader>md :w<CR> :!cygstart %<CR>
" <Leader>f{char} to move to {char}
map <Leader>f <Plug>(easymotion-bd-f)
nmap <Leader>f <Plug>(easymotion-overwin-f)
" s{char}{char} to move to {char}{char}
nmap s <Plug>(easymotion-overwin-f2)
" Move to line
map <Leader>L <Plug>(easymotion-bd-jk)
nmap <Leader>L <Plug>(easymotion-overwin-line)
" Move to word
map <Leader>w <Plug>(easymotion-bd-w)
nmap <Leader>w <Plug>(easymotion-overwin-w)
"airline support
let g:airline#extensions#tabline#enabled = 1
" crontab stuff
if $VIM_CRONTAB == "true"
set nobackup
set nowritebackup
endif
"Golang
let g:go_fmt_command = "goimports"
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" NERDTreee
let NERDTreeIgnore = ['\.pyc$', 'db.sqlite3']
" ----------------------------------------------------------------------------
" Plugin - CtrlP
" ----------------------------------------------------------------------------
let g:ctrlp_use_caching = 0
let g:ctrlp_user_command = 'fd $FD_OPTS -E "*.pdf"'
" Tagbar
nmap <F8> :TagbarToggle<CR>
" ----------------------------------------------------------------------------
" Plugin - Fugitive
" ----------------------------------------------------------------------------
" - blame
nnoremap <leader>b :Gblame<CR>
nnoremap <leader>gcv :Gcommit -v <CR>
nnoremap <leader>gau :Git add -u<CR><CR>
" - diff
command! Greview :Git! diff --staged
nnoremap <leader>r :Greview<cr>
" - status
" Obtained from https://gist.github.com/actionshrimp/6493611
function! ToggleGStatus()
if buflisted(bufname('.git/index'))
bd .git/index
else
Gstatus
endif
endfunction
command! ToggleGStatus :call ToggleGStatus()
nnoremap <leader>s :ToggleGStatus<CR>
nnoremap <leader>ss :ToggleGStatus<CR>
nnoremap <leader><leader>s :ToggleGStatus<CR>
" Copy and Paste : https://vi.stackexchange.com/questions/84/how-can-i-copy-text-to-the-system-clipboard-from-vim
noremap <Leader>y "*y
noremap <Leader>Y "+y
noremap <Leader>p "*p
noremap <Leader>P "+p
" Autopair
let g:AutoPairsShortcutToggle = '<Leader>m'
" Spell file
set spelllang=en
set spellfile=$HOME/.dotfiles/vim/spell/en.utf-8.add
set spell
nnoremap <Leader>sp :e $HOME/.dotfiles/vim/spell/en.utf-8.add<CR>
nnoremap <Leader>ssp :mkspell! $HOME/.dotfiles/vim/spell/en.utf-8.add<CR>
" Tag for R
let g:tagbar_type_r = {
\ 'ctagstype' : 'r',
\ 'kinds' : [
\ 'f:Functions',
\ 'g:GlobalVariables',
\ 'v:FunctionVariables',
\ ]
\ }
" Tag for markdown (https://github.com/majutsushi/tagbar/issues/70)
let g:tagbar_type_markdown = {
\ 'ctagstype': 'markdown',
\ 'ctagsbin' : '~/src/markdown2ctags/markdown2ctags.py',
\ 'ctagsargs' : '-f - --sort=yes',
\ 'kinds' : [
\ 's:sections',
\ 'i:images'
\ ],
\ 'sro' : '|',
\ 'kind2scope' : {
\ 's' : 'section',
\ },
\ 'sort': 0,
\ }
" let g:tagbar_type_markdown = {
" \ 'ctagstype' : 'markdown',
" \ 'kinds' : [
" \ 'h:headings',
" \ 'l:links',
" \ 'i:images'
" \ ],
" \ 'sort' : 0
" \ }
let g:tagbar_type_rmd = {
\ 'ctagstype' : 'markdown',
\ 'kinds' : [
\ 'h:headings',
\ 'l:links',
\ 'i:images'
\ ],
\ "sort" : 0
\ }
"colorscheme Tomorrow-Night
colorscheme seoul256
" Mapping selecting mappings
nmap <leader><tab> <plug>(fzf-maps-n)
xmap <leader><tab> <plug>(fzf-maps-x)
omap <leader><tab> <plug>(fzf-maps-o)
" Insert mode completion
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file-ag)
imap <c-x><c-l> <plug>(fzf-complete-line)
"=================================================================
" Plugin - Vim Test
"=================================================================
let test#python#runner = 'pytest'
"let test#python#pytest#options = '-s -v'
let test#python#pytest#options = ''
" these "Ctrl mappings" work well when Caps Lock is mapped to Ctrl
nmap <silent> t<C-n> :TestNearest<CR> " t Ctrl+n
nmap <silent> t<C-f> :TestFile<CR> " t Ctrl+f
nmap <silent> t<C-s> :TestSuite<CR> " t Ctrl+s
nmap <silent> t<C-l> :TestLast<CR> " t Ctrl+l
nmap <silent> t<C-g> :TestVisit<CR> " t Ctrl+g
let g:test#preserve_screen = 1
let test#strategy = "dispatch"
function! s:goyo_enter()
silent !tmux set status off
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
set noshowmode
set noshowcmd
set scrolloff=999
set nospell
set norelativenumber
Limelight
" ...
endfunction
function! s:goyo_leave()
silent !tmux set status on
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
set showmode
set showcmd
set scrolloff=5
set spell
set relativenumber
Limelight!
" ...
endfunction
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
" Plugin - jedi-vim ----
" to play nicely with YCM
"let g:jedi#completions_enabled = 0
" }}}
" }}}
" ============================================================================
" Plugin Specific Settings {{{
" ============================================================================
" ----------------------------------------------------------------------------
" Plugin - vim-go ----
" ----------------------------------------------------------------------------
let g:go_version_warning = 0
" ----------------------------------------------------------------------------
" Plugin - fzf ----
" ----------------------------------------------------------------------------
nnoremap <F3> :call fzf#run(fzf#wrap({'source': 'fd $FD_OPTS . $HOME', 'sink': 'edit'}))<CR>
inoremap <F3> :call fzf#run(fzf#wrap({'source': 'fd $FD_OPTS . $HOME', 'sink': 'edit'}))<CR>
nnoremap <Leader>pv :call fzf#vim#gitfiles('', fzf#vim#with_preview('right'))<CR>
" ----------------------------------------------------------------------------
" Gundo
" ----------------------------------------------------------------------------
" toggle gundo
nnoremap <leader>u :GundoToggle<CR>
" ----------------------------------------------------------------------------
" vim-after-object
" ----------------------------------------------------------------------------
silent! if has_key(g:plugs, 'vim-after-object')
autocmd VimEnter * silent! call after_object#enable('=', ':', '#', ' ', '|')
endif
" ----------------------------------------------------------------------------
" Plugin - Calendar
" ----------------------------------------------------------------------------
let g:calendar_google_calendar = 1
let g:calendar_google_task = 1
" ----------------------------------------------------------------------------
" Plugin - Taglist
" ----------------------------------------------------------------------------
"Taglist Toggle
nnoremap <silent> <F7> :TlistToggle<CR>
" ----------------------------------------------------------------------------
" Projectionist
" ----------------------------------------------------------------------------
nnoremap <leader>aa :A <CR>
nnoremap <leader><leader>a :A <CR>
nnoremap <leader>a :A <CR>
" ----------------------------------------------------------------------------
" Ale
" ----------------------------------------------------------------------------
nnoremap ]al :ALENext<CR>
nnoremap [al :ALEPrevious<CR>
"let g:ale_set_loclist = 0
"let g:ale_set_quickfix = 1
" let g:ale_open_list = 1
"nnoremap ]al <Plug>(ale_next)
"nnoremap ]al <Plug>(ale_previous)
" ----------------------------------------------------------------------------
" YouCompleteMe
" ----------------------------------------------------------------------------
let g:ycm_key_list_select_completion=[]
let g:ycm_key_list_previous_completion=[]
" ----------------------------------------------------------------------------
" Ultistnip
" ----------------------------------------------------------------------------
"let g:UltiSnipsExpandTrigger="<S-tab>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-k>"
"
" " If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
let g:UltiSnipsNoPythonWarning = 1
let g:UltiSnipsSnippetsDir="~/.vim/plugged/mysnippets/UltiSnips/"
" }}}
" ============================================================================
" Etc {{{
" ============================================================================
"
" If two files are loaded, switch to the alternate file, then back.
" That sets # (the alternate file).
if argc() == 2
n
e #
endif
function! RenameFile() "{{{
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'), 'file')
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
nnoremap <F2> :call RenameFile()<cr>
"}}}
" }}}
" ============================================================================
" Unused/Disabled {{{
"hi Comment guifg=#80a0ff ctermfg=darkred
"
""Buffer navigation
"nnoremap <silent> [b :bprevious<CR>
"nnoremap <silent> ]b :bnext<CR>
"nnoremap <silent> [B :bfirst<CR>
"nnoremap <silent> ]B :blast<CR>
"
"Remapping marking pos
" nnoremap ' `
" nnoremap ` '
" let g:indentguides_state = 0
" function! IndentGuides() " {{{
" if g:indentguides_state
" let g:indentguides_state = 0
" 2match None
" else
" let g:indentguides_state = 1
" execute '2match IndentGuides /\%(\_^\s*\)\@<=\%(\%'.(0*&sw+1).'v\|\%'.(1*&sw+1).'v\|\%'.(2*&sw+1).'v\|\%'.(3*&sw+1).'v\|\%'.(4*&sw+1).'v\|\%'.(5*&sw+1).'v\|\%'.(6*&sw+1).'v\|\%'.(7*&sw+1).'v\)\s/'
" endif
" endfunction " }}}
" hi def IndentGuides guibg=#303030 ctermbg=234
" nnoremap <leader>I :call IndentGuides()<cr>
"
" }}}
" ============================================================================
let g:ale_linters={'python': ['flake8', 'mypy'], 'r': ['lintr']}
let g:ale_fixers = ['yapf']
if exists('+colorcolumn')
" Highlight up to 255 columns (this is the current Vim max) beyond 'textwidth'
let &l:colorcolumn='+' . join(range(0, 254), ',+')
endif
set list " show whitespace
set listchars=nbsp:⦸ " CIRCLED REVERSE SOLIDUS (U+29B8, UTF-8: E2 A6 B8)
set listchars+=tab:▷┅ " WHITE RIGHT-POINTING TRIANGLE (U+25B7, UTF-8: E2 96 B7)
" + BOX DRAWINGS HEAVY TRIPLE DASH HORIZONTAL (U+2505, UTF-8: E2 94 85)
set listchars+=extends:» " RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK (U+00BB, UTF-8: C2 BB)
set listchars+=precedes:« " LEFT-POINTING DOUBLE ANGLE QUOTATION MARK (U+00AB, UTF-8: C2 AB)
set listchars+=trail: " BULLET (U+2022, UTF-8: E2 80 A2)
set nojoinspaces " don't autoinsert two spaces after '.', '?', '!' for join command
nnoremap <Leader>fw :FixWhitespace<CR>
if !empty(glob("/Users/alee/.vim/autoload/wincent"))
if exists('+winhighlight')
autocmd BufEnter,FocusGained,VimEnter,WinEnter * if wincent#autocmds#should_colorcolumn() | set winhighlight= | endif
autocmd FocusLost,WinLeave * if wincent#autocmds#should_colorcolumn() | set winhighlight=CursorLineNr:LineNr,IncSearch:ColorColumn,Normal:ColorColumn,NormalNC:ColorColumn,SignColumn:ColorColumn | endif
if exists('+colorcolumn')
autocmd BufEnter,FocusGained,VimEnter,WinEnter * if wincent#autocmds#should_colorcolumn() | let &l:colorcolumn='+' . join(range(0, 254), ',+') | endif
endif
elseif exists('+colorcolumn')
autocmd BufEnter,FocusGained,VimEnter,WinEnter * if wincent#autocmds#should_colorcolumn() | let &l:colorcolumn='+' . join(range(0, 254), ',+') | endif
autocmd FocusLost,WinLeave * if wincent#autocmds#should_colorcolumn() | let &l:colorcolumn=join(range(1, 255), ',') | endif
endif
autocmd InsertLeave,VimEnter,WinEnter * if wincent#autocmds#should_cursorline() | setlocal cursorline | endif
autocmd InsertEnter,WinLeave * if wincent#autocmds#should_cursorline() | setlocal nocursorline | endif
autocmd BufEnter,FocusGained,VimEnter,WinEnter * call wincent#autocmds#focus_window()
autocmd FocusLost,WinLeave * call wincent#autocmds#blur_window()
endif
inoremap \date <C-R>=strftime("%Y-%m-%d")<CR>
inoremap \time <C-R>=strftime("%Y-%m-%dT%H-%M-%S")<CR>
inoremap \todo [ ]
inoremap \td [ ]
nnoremap \nosym :e <C-R>=resolve(expand("%"))<CR>
" Follow symlinks when opening a file
" Sources:
" - https://github.com/tpope/vim-fugitive/issues/147#issuecomment-7572351
" - http://www.reddit.com/r/vim/comments/yhsn6/is_it_possible_to_work_around_the_symlink_bug/c5w91qw
" Echoing a warning does not appear to work:
" echohl WarningMsg | echo "Resolving symlink." | echohl None |
function! MyFollowSymlink(...)
let fname = a:0 ? a:1 : expand('%')
if getftype(fname) != 'link'
return
endif
let resolvedfile = fnameescape(resolve(fname))
exec 'file ' . resolvedfile
endfunction
command! FollowSymlink call MyFollowSymlink()
autocmd BufReadPost * call MyFollowSymlink(expand('<afile>'))
let g:slime_target = "tmux"
let g:slime_default_config = {"socket_name": split($TMUX, ",")[0], "target_pane": ":.2"}
let vim_markdown_preview_hotkey='<C-m>'
let vim_markdown_preview_github=1
let vim_markdown_preview_browser='Google Chrome'
let g:vim_markdown_conceal = 0 "make markdown sane
nnoremap <Leader>ml :r !make lint <CR>
function! TabToSpace()
:
:mkspell! $HOME/.dotfiles/vim/spell/en.utf-8.add
:bd
execute g:spell_return_to_window . "wincmd w"
else
let g:spell_return_to_window = winnr()
:vsplit $HOME/.dotfiles/vim/spell/en.utf-8.add
let g:spell_is_open = 1
endif
endfunction
" tab to space
nnoremap <Leader>tts :%s/\t/ /g<CR>
nnoremap <Leader>fs :!fs<CR>
" paste FIX
nnoremap <Leader>pf :%s/<F2[23]>//g <CR>
nnoremap <Leader>vf :%s/ / /g <CR>
nnoremap <Leader>h yypVr=
nnoremap <Leader>h1 yypVr=
nnoremap <Leader>h2 yypVr-
nnoremap TT :wall<CR>: !tmux kill-pane<CR>
nnoremap <Leader>def :e $HOME/vimwiki/Definitions.wiki<CR>
nnoremap <Leader>k :VimwikiToggleListItem<CR>
let g:vimwiki_folding='list'
"autocmd FileType python setlocal foldenable foldmethod=syntax
"
" Make python <> vim-slime play well together
let g:slime_python_ipython = 1
" Vimtex
let g:vimtex_view_method = 'skim'
" Vimwiki
nnoremap ]d :VimwikiDiaryNextDay<CR>
nnoremap [d :VimwikiDiaryPrevDay<CR>
nnoremap <Leader>toc :VimwikiTOC<CR>
let g:auto_tags = 1
" ============================================================================ "
nnoremapk
nnoremapj
nnoremapi
nnoremapo
nnoremap ㅒ O
nnoremap ㅇㅇ dd
let g:vimwiki_list = [{'path': '~/Dropbox/vimwiki/',
\ 'syntax': 'markdown', 'ext': '.md'}]
vmap <F9> :call UltiSnips#SaveLastVisualSelection()<CR>gvs
imap <F9> <C-R>=UltiSnips#ExpandSnippet()<CR>