Skip to content

Instantly share code, notes, and snippets.

@kjelly
Created January 12, 2018 15:34
Show Gist options
  • Save kjelly/c1b44a144b345fd7b481c8efc7ba6231 to your computer and use it in GitHub Desktop.
Save kjelly/c1b44a144b345fd7b481c8efc7ba6231 to your computer and use it in GitHub Desktop.
~/.config/nvim/init.vim
let mapleader = ","
let maplocalleader = "_"
" Set extra options when running in GUI mode
if has("gui_running")
set guioptions-=T
set guioptions+=e
set t_Co=256
set guitablabel=%M\ %t
endif
" Specify the behavior when switching between buffers
try
set switchbuf=useopen,usetab,newtab
set stal=2
catch
endtry
" Return to last edit position when opening files (You want this!)
autocmd! BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Do :help cope if you are unsure what cope is. It's super useful!
"
" When you search with vimgrep, display your results in cope by doing:
" <leader>cc
"
" To go to the next search result do:
" <leader>n
"
" To go to the previous search results do:
" <leader>p
"nnoremap <leader>gcc :botright cope<cr>
"nnoremap <leader>gco ggVGy:tabnew %<cr>:set syntax=qf<cr>pgg
"nnoremap <leader>gn :cn<cr>
"nnoremap <leader>gp :cp<cr>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Helper functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! CmdLine(str)
exe "menu Foo.Bar :" . a:str
emenu Foo.Bar
unmenu Foo
endfunction
function! VisualSelection(direction) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", '\\/.*$^~[]')
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'b'
execute "normal ?" . l:pattern . "^M"
elseif a:direction == 'gv'
call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.')
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
elseif a:direction == 'f'
execute "normal /" . l:pattern . "^M"
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
" Don't close window, when deleting a buffer
command! Bclose call <SID>BufcloseCloseIt()
function! <SID>BufcloseCloseIt()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
if buflisted(l:alternateBufNum)
buffer #
else
bnext
endif
if bufnr("%") == l:currentBufNum
new
endif
if buflisted(l:currentBufNum)
execute("bdelete! ".l:currentBufNum)
endif
endfunction
function! Num_Toggle()
exe "NumbersToggle"
exe "set number!"
endfunction
function! ToggleMouse()
" check if mouse is enabled
if &mouse == 'a'
" disable mouse
set mouse=
else
" enable mouse everywhere
set mouse=a
endif
endfunc
function! ToggleStatusLine()
if &laststatus==0
set laststatus=2
else
set laststatus=0
endif
endfunc
function! s:DiffWithSaved()
let filetype=&ft
diffthis
vnew | r # | normal! 1Gdd
diffthis
exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
endfunction
if has('gui_running')
set background=light
else
set background=dark
endif
set nocompatible " be iMproved
filetype off " required before plugins
call plug#begin('~/.vim/plugged')
Plug 'hecal3/vim-leader-guide'
Plug 'fcpg/vim-shore'
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
"Plug 'vim-scripts/grep.vim'
"Plug 'ervandew/supertab'
"Plug 'DevWurm/autosession.vim'
"Plug 'ntpeters/vim-better-whitespace'
Plug 'gagoar/stripwhitespaces'
Plug 'terryma/vim-expand-region'
Plug 'bling/vim-airline'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'easymotion/vim-easymotion'
Plug 'itchyny/calendar.vim'
Plug 'vimwiki/vimwiki'
Plug 'haya14busa/incsearch.vim'
Plug 'tpope/vim-vinegar'
Plug 'fidian/hexmode'
Plug 'vim-scripts/fcitx.vim'
Plug 'joshdick/onedark.vim'
"Plug 'osyo-manga/vim-over'
"Plug 'justinmk/vim-gtfo'
"Plug 'Shougo/unite.vim'
"Plug 'JamshedVesuna/vim-markdown-preview' " sudo pip install grip
"Plug 'Yggdroot/indentLine'
" Lang
Plug 'dag/vim-fish'
Plug 'ekalinin/Dockerfile.vim'
Plug 'hashivim/vim-vagrant'
"Plug 'ensime/ensime-vim'
Plug 'artur-shaik/vim-javacomplete2', { 'for': 'java' }
Plug 'fatih/vim-go', { 'for': 'go' }
Plug 'pangloss/vim-javascript', { 'for': 'javascript' }
Plug 'plasticboy/vim-markdown', { 'for': 'markdown' }
Plug 'pearofducks/ansible-vim', { 'for': 'ansible' }
Plug 'Shougo/vimproc.vim', {'do' : 'make'}
Plug 'HerringtonDarkholme/yats.vim', { 'for': 'typescript' } " typescript
"Plug 'derekwyatt/vim-scala'
"Plug 'mxw/vim-jsx'
"Plug 'ya790206/vim-mecury-lang'
"Plug 'rust-lang/rust.vim'
"Plug 'racer-rust/vim-racer'
"Plug 'udalov/kotlin-vim'
"Plug 'dart-lang/dart-vim-plugin'
"Plug 'keith/swift.vim'
"Plug 'gre/play2vim'
"Plug 'vim-scripts/OmniCppComplete'
"Plug 'neomake/neomake'
"Plug 'adimit/prolog.vim'
"Plug 'nathanaelkane/vim-indent-guides'
"Plug 'JesseKPhillips/d.vim'
"Plug 'HerringtonDarkholme/w3m.vim'
"Plug 'mhinz/vim-startify'
"Plug 'suan/vim-instant-markdown'
"Plug 'MattesGroeger/vim-bookmarks'
"Plug 'thinca/vim-quickrun'
"Plug 'mkitt/tabline.vim'
"Plug 'mru.vim'
"Plug 'rhysd/vim-clang-format'
"Plug 'justmao945/vim-clang' "for autocomplete
Plug 'tpope/vim-fugitive'
Plug 'cohama/agit.vim'
"Plug 'lambdalisue/gina.vim'
Plug 'godlygeek/tabular'
Plug 'majutsushi/tagbar'
Plug 'mattn/emmet-vim'
Plug 'w0rp/ale'
Plug 'scrooloose/nerdcommenter'
Plug 'tpope/vim-surround'
"Plug 'Shougo/denite.nvim'
"Plug 'Shougo/neosnippet'
"Plug 'Shougo/neosnippet-snippets'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'kjelly/vim-multiterm'
"Plug 'myusuf3/numbers.vim'
Plug 'mbbill/undotree'
" Plugin to toggle, display and navigate marks
Plug 'kshenoy/vim-signature'
"Plug 'Shougo/vimproc.vim'
"Plug 'Shougo/vimshell.vim'
Plug 'Chiel92/vim-autoformat'
Plug 'rhysd/devdocs.vim'
"Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'autozimu/LanguageClient-neovim', { 'do': 'install.sh', 'branch': 'next' }
"Plug 'autozimu/LanguageClient-neovim', { 'do': ':UpdateRemotePlugins', 'commit': '2760b3f340dad4b373658d00153511e0adce6b9b' }
Plug 'roxma/nvim-completion-manager' "this is like deoplete
" it's needed because lsp doesn't work for go
"Plug 'zchee/deoplete-go', { 'do': 'make'}
"Plug 'zchee/deoplete-jedi'
"Plug 'mhartington/nvim-typescript'
"Plug 'ternjs/tern_for_vim'
"Plug 'carlitux/deoplete-ternjs'
Plug 'Shougo/neco-vim'
Plug 'Shougo/neco-syntax'
Plug 'eugen0329/vim-esearch'
" colorscheme
"Plug 'morhetz/gruvbox'
"Plug 'iCyMind/NeoSolarized'
Plug 'mhinz/neovim-remote'
"Plug 'kassio/neoterm', { 'commit': '9e33da0a' }
" For neovim-qt or go-nvim
Plug 'equalsraf/neovim-gui-shim'
call plug#end()
syntax enable
filetype plugin indent on " required!
set nu
set keywordprg=sdcvh.sh
"set whichwrap+=h,l
set whichwrap+=<,>,[,],s,b
set cursorline
set showcmd
set mouse=
" Show tab line if there are more than one tab
set showtabline=1
" Set utf8 as standard encoding and en_US as the standard language
if !has('nvim')
set encoding=utf8
endif
" Use Unix as the standard file type
set ffs=unix,dos,mac
" Remember info about register, marks. And no highlight when started
set viminfo=<800,'10,h
" Show tab line if there are more than one tab
set showtabline=1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => VIM user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Set 7 lines to the cursor - when moving vertically using j/k
set so=7
" Turn on the WiLd menu
set wildmenu
" Ignore compiled files
set wildignore=*.o,*~,*.pyc
"Always show current position
set ruler
" Height of the command bar
set cmdheight=1
" A buffer becomes hidden when it is abandoned
set hid
" Configure backspace so it acts as it should act
set backspace=eol,start,indent
set whichwrap+=<,>,h,l
" Ignore case when searching
set ignorecase
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" Makes search act like search in modern browsers
set incsearch
" Don't redraw while executing macros (good performance config)
set lazyredraw
" For regular expressions turn magic on
set magic
" Show matching brackets when text indicator is over them
set showmatch
" How many tenths of a second to blink when matching brackets
set mat=2
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" Sets how many lines of history VIM has to remember
set history=700
" Set to auto read when a file is changed from the outside
set autoread
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text, tab and indent related
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs ;)
set smarttab
" 1 tab == 4 spaces
set shiftwidth=2
set tabstop=2
" Linebreak on 500 characters
set lbr
set tw=500
set ai "Auto indent
set si "Smart indent
set wrap "Wrap lines
" Always show the status line
set laststatus=2
" The time in milliseconds that is waited for
" a mapped sequence to complete.
set timeoutlen=500
set completeopt="menu,preview,noinsert,noselect"
set listchars=tab:>-,trail:~,extends:>,precedes:<
set list
set guicursor=
if !empty(glob("/usr/local/bin/fish"))
set shell=/usr/local/bin/fish
endif
if !empty(glob("/usr/bin/fish"))
set shell=/usr/bin/fish
endif
let g:jedi#completions_command = "<C-n>"
let popup_select_first = 0
let @/ = ""
let g:vim_markdown_folding_disabled=1
let NERDTreeMapOpenInTab='<TAB>'
let g:nerdtree_tabs_focus_on_files=1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#tab_nr_type = 2
let g:airline#extensions#tabline#show_tabs = 1
let g:airline#extensions#tabline#show_tab_nr = 2
let g:airline#extensions#tabline#tab_min_count = 2
let g:airline#extensions#tabline#exclude_preview = 1
let g:airline#extensions#tabline#show_buffers = 0
let g:airline#extensions#ale#enabled = 1
let g:ale_python_pylint_options="--disable=C0111,C0103,C1801,C0325"
let g:deoplete#enable_at_startup = 1
let g:vimshell_prompt_expr =
\ 'escape(fnamemodify(getcwd(), ":~").">", "\\[]()?! ")." "'
let g:vimshell_prompt_pattern = '^\%(\f\|\\.\)\+> '
let g:clang_c_completeopt = "menu,preview,noinsert,noselect"
let g:clang_cpp_completeopt = "menu,preview,noinsert,noselect"
let g:syntastic_cpp_compiler_options="-std=gnu++14"
" Easymotion
let g:asyMotion_smartcase = 1
let g:EasyMotion_startofline = 0 " keep cursor colum when JK motion
" Let fzf ignore the files which is ignored by gitignore or hgignore
let $FZF_DEFAULT_COMMAND='ag -g ""'
let base_wiki = {}
let base_wiki.path = '~/Dropbox/vimwiki'
let base_wiki.syntax = 'markdown'
let base_wiki.ext = '.md'
let base_wiki.nested_syntaxes = {'python': 'python', 'c++': 'cpp', 'sh': 'sh', 'typescript': 'typescript', 'javascript': 'js', 'scala': 'scala', 'vim': 'vim'}
let g:vimwiki_list = [base_wiki]
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-f>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"
" Markdown tag bar
let g:tagbar_type_markdown = {
\ 'ctagstype' : 'markdown',
\ 'kinds' : [
\ 'h:Heading_L1',
\ 'i:Heading_L2',
\ 'k:Heading_L3'
\ ]
\ }
let g:tagbar_type_vimwiki = {
\ 'ctagstype' : 'markdown',
\ 'kinds' : [
\ 'h:Heading_L1',
\ 'i:Heading_L2',
\ 'k:Heading_L3'
\ ]
\ }
let g:LanguageClient_autoStart = 1
let g:LanguageClient_serverCommands = {
\ 'rust': ['rustup', 'run', 'nightly', 'rls'],
\ 'python': ['pyls'],
\ 'ruby': ['language_server-ruby'],
\ 'go': ['go-langserver', '-trace', '-logfile', expand('~/langserver-go.log')],
\ 'javascript': ['javascript-typescript-stdio'],
\ 'javascript.jsx': ['javascript-typescript-stdio'],
\ 'typescript': ['javascript-typescript-stdio'],
\ }
let vim_markdown_preview_hotkey='<A-m>'
let vim_markdown_preview_github=1
let vim_markdown_preview_use_xdg_open=1
let g:airline_theme='onedark'
let g:LanguageClient_diagnosticsEnable=0
" Autocmd
autocmd! InsertLeave,WinEnter * set cursorline
autocmd! InsertEnter,WinLeave * set nocursorline
autocmd! BufEnter * set laststatus=2
autocmd! BufEnter * if &buftype == 'terminal' | :set laststatus=0 | endif
autocmd! TermOpen *fish set laststatus=0
autocmd! TermOpen *fish set nonu
autocmd! BufEnter * if &buftype == 'terminal' | :startinsert | endif
autocmd! bufwritepost .vimrc source %
autocmd! bufwritepost init.vim source %
autocmd CursorHold * checktime
augroup Binary
au!
au! BufReadPre *.bin let &bin=1
au! BufReadPost *.bin if &bin | %!xxd
au! BufReadPost *.bin set ft=xxd | endif
au! BufWritePre *.bin if &bin | %!xxd -r
au! BufWritePre *.bin endif
au! BufWritePost *.bin if &bin | %!xxd
au! BufWritePost *.bin set nomod | endif
augroup END
" num toggle
command! Nu execute "call Num_Toggle()"
"Quit
command! Q execute "quit!"
command! Qa execute "quitall!"
" Sudo to write
command! W :w !sudo tee % >/dev/null
" Diff between the curret buffer and the file.
com! Diff call s:DiffWithSaved()
function! OpenChangedFiles()
only " Close all windows, unless they're modified
let status = system('git status -s | grep "^ \?\(M\|A\)" | cut -d " " -f 3')
let filenames = split(status, "\n")
if len(filenames) < 1
let status = system('git show --pretty="format:" --name-only')
let filenames = split(status, "\n")
endif
exec "edit " . filenames[0]
for filename in filenames[1:]
if len(filenames) > 4
exec "tabedit " . filename
else
exec "sp " . filename
endif
endfor
endfunction
command! OpenChangedFiles :call OpenChangedFiles()
" It doesn't work in terminal (neo)vim
hi VimwikiHeader1 guifg=Gray
hi VimwikiHeader2 guifg=Magenta
hi VimwikiHeader3 guifg=#30F30F
hi VimwikiHeader4 guifg=#B266FF
hi VimwikiHeader5 guifg=#00CC66
hi VimwikiHeader6 guifg=#FFFF00
" resize buffer
if bufwinnr(1)
map = <C-W>+
map - <C-W>-
map } <C-W>>
map { <C-W><
endif
" Use normal regex
" http://stevelosh.com/blog/2010/09/coming-home-to-vim
nnoremap / /\v
vnoremap / /\v
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :call VisualSelection('f')<CR>
vnoremap <silent> # :call VisualSelection('b')<CR>
" Smart way to move between windows
nnoremap <C-j> <C-W>j
nnoremap <C-k> <C-W>k
nnoremap <C-h> <C-W>h
nnoremap <C-l> <C-W>l
nnoremap <C-n> :NERDTreeTabsToggle<CR>
nnoremap <C-t> :tabnew %<CR>
inoremap <C-t> <Esc>:tabnew %<CR>
noremap H gT
noremap L gt
" Command
nnoremap <C-e> :Commands<cr>
" Tag list
nnoremap <C-s> :Tagbar<cr>
inoremap <C-s> <Esc>:w<cr>a
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
" Find file/buffer
nnoremap <C-p> :call fzf#vim#files('', fzf#vim#with_preview('right'))<cr>
" Auto complete for all word
inoremap <c-a> <c-x><c-n>
" 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)
cnoremap <c-s> Explore scp://
cnoremap <c-h> <Left>
cnoremap <c-j> <Down>
cnoremap <c-k> <Up>
cnoremap <c-l> <Right>
tnoremap <C-q> <C-\><C-n> inoremap <C-q> <Esc>
nnoremap <C-q> i
vnoremap <C-q> <Esc>
tnoremap <C-]> <C-\><C-n> inoremap <C-]> <Esc>
nnoremap <C-]> i
vnoremap <C-]> <Esc>
nnoremap ; :
inoremap ;; <Esc>
tnoremap ;; <C-\><C-n>
cnoremap <A-h> <Left>
cnoremap <A-j> <Down>
cnoremap <A-k> <Up>
cnoremap <A-l> <Right>
" Alt-num to switch tab
noremap <A-0> 0gt
noremap <A-1> 1gt
noremap <A-2> 2gt
noremap <A-3> 3gt
noremap <A-4> 4gt
noremap <A-5> 5gt
noremap <A-6> 6gt
noremap <A-7> 7gt
noremap <A-8> 8gt
noremap <A-9> 9gt
noremap <A-0> 0gt
" Delete one word
inoremap <C-e> <Esc>dwi
" Forware/backware word
inoremap <C-f> <Esc>w i
inoremap <C-b> <Esc>bi
" Paste text
inoremap <C-v> <Esc>pi
" Paste text from clipboard
vnoremap <c-c> "+y
vnoremap <Return> "+y
"Quickly move current line
nnoremap [e :<c-u>execute 'move -1-'. v:count1<cr>
nnoremap ]e :<c-u>execute 'move +'. v:count1<cr>
inoremap <C-d> <Plug>(neosnippet_expand_or_jump)
let g:racer_cmd = "/home/kjelly/.cargo/bin/racer"
let $RUST_SRC_PATH="/home/kjelly/rust-src/src"
nnoremap zz za
map / <Plug>(incsearch-forward)\v
map ? <Plug>(incsearch-backward)\v
map g/ <Plug>(incsearch-stay)\v
nnoremap <F5> :C ./debug.sh<cr>
inoremap <F5> <Esc>:C ./debug.sh<cr>a
nnoremap <Tab> :Files<cr>
nnoremap <S-Tab> :call OpenBuffer()<cr>
" Tab switch
tnoremap <A-1> <C-\><C-n>1gti
tnoremap <A-2> <C-\><C-n>2gti
tnoremap <A-3> <C-\><C-n>3gti
tnoremap <A-4> <C-\><C-n>4gti
tnoremap <A-5> <C-\><C-n>5gti
tnoremap <A-6> <C-\><C-n>6gti
tnoremap <A-7> <C-\><C-n>7gti
tnoremap <A-8> <C-\><C-n>8gti
tnoremap <A-9> <C-\><C-n>9gti
tnoremap <A-0> <C-\><C-n>0gti
" Tab switch
inoremap <A-1> <Esc>1gti
inoremap <A-2> <Esc>2gti
inoremap <A-3> <Esc>3gti
inoremap <A-4> <Esc>4gti
inoremap <A-5> <Esc>5gti
inoremap <A-6> <Esc>6gti
inoremap <A-7> <Esc>7gti
inoremap <A-8> <Esc>8gti
inoremap <A-9> <Esc>9gti
inoremap <A-0> <Esc>0gti
tnoremap <Insert> <C-\><C-n>
"tnoremap <C-[> <C-\><C-n> Don't enable this. Esc is useful when vim in vim
tnoremap <A-a> <C-\><C-n>
inoremap <A-a> <Esc>
nnoremap <A-a> i
vnoremap <A-a> <Esc>
cnoremap <A-a> <Esc>
tnoremap å <C-\><C-n>
inoremap å <Esc>
nnoremap å i
vnoremap å <Esc>
tnoremap <A-j> <C-\><C-n><C-w>j
tnoremap <A-k> <C-\><C-n><C-w>k
tnoremap <A-l> <C-\><C-n><C-w>l
nnoremap <A-h> <C-w>h
nnoremap <A-j> <C-w>j
nnoremap <A-k> <C-w>k
nnoremap <A-l> <C-w>l
inoremap <A-h> <Esc><C-w>h
inoremap <A-j> <Esc><C-w>j
inoremap <A-k> <Esc><C-w>k
inoremap <A-l> <Esc><C-w>l
tnoremap ˙ <C-\><C-n><C-w>h
tnoremap ∆ <C-\><C-n><C-w>j
tnoremap ˚ <C-\><C-n><C-w>k
tnoremap ¬ <C-\><C-n><C-w>l
nnoremap ˙ <C-w>h
nnoremap ∆ <C-w>j
nnoremap ˚ <C-w>k
nnoremap ¬ <C-w>l
inoremap ˙ <Esc><C-w>h
inoremap ∆ <Esc><C-w>j
inoremap ˚ <Esc><C-w>k
inoremap ¬ <Esc><C-w>l
" Find files/buffers
function! OpenBuffer()
let buf=bufnr('%')
bufdo if &buftype ==# 'terminal' | silent! execute 'file' b:term_title | endif
exec 'b' buf
execute "Buffers"
endfunction
inoremap <A-o> <Esc>:call OpenBuffer()<cr>
nnoremap <A-o> :call OpenBuffer()<cr>
tnoremap <A-o> <C-\><C-n>:call OpenBuffer()<cr>a
inoremap <A-p> <Esc>:call fzf#vim#files('', fzf#vim#with_preview('right'))<cr>
nnoremap <A-p> :call fzf#vim#files('', fzf#vim#with_preview('right'))<cr>
tnoremap <A-p> <C-\><C-n>:call fzf#vim#files('', fzf#vim#with_preview('right'))<cr>a
inoremap <A-i> <Esc>:Ag<cr>
nnoremap <A-i> :Ag<cr>
tnoremap <A-i> <C-\><C-n>:Ag<cr>a
" buufer switch
nnoremap <A-b> :b#<cr>
inoremap <A-b> <Esc>:b#<cr>
tnoremap <A-b> <C-\><C-n>:b#<cr>a
inoremap <A-;> <Esc><C-w>ja
nnoremap <A-;> a
tnoremap <A-;> <C-\><C-n><C-w>ka
" Save
inoremap <A-s> <Esc>:w<cr>a
nnoremap <A-s> :w<cr>
" Resize buffer
nnoremap <silent> <A-q> :resize +1000<cr>
nnoremap <silent> <A-w> <c-w><c-=>
nnoremap <silent> <A-e> :resize -1000<cr>
nnoremap <silent> <A-r> :vertical resize +1000<cr>
nnoremap <silent> <A-t> :vertical resize -1000<cr>
inoremap <silent> <A-q> <Esc>:resize +1000<cr>a
inoremap <silent> <A-w> <Esc><c-w><c-=>i
inoremap <silent> <A-e> <Esc>:resize -1000<cr>a
inoremap <silent> <A-r> <Esc>:vertical resize +1000<cr>a
inoremap <silent> <A-t> <Esc>:vertical resize -1000<cr>a
tnoremap <silent> <A-q> <C-\><C-n>:resize +1000<cr>a
tnoremap <silent> <A-w> <C-\><C-n><c-w><c-=>i
tnoremap <silent> <A-e> <C-\><C-n>:resize -1000<cr>a
tnoremap <silent> <A-r> <C-\><C-n>:vertical resize +1000<cr>a
tnoremap <silent> <A-t> <C-\><C-n>:vertical resize -1000<cr>a
nnoremap <silent> œ :resize +1000<cr>
nnoremap <silent> ∑ <c-w><c-=>
nnoremap <silent> ´ :resize -1000<cr>
nnoremap <silent> ® :vertical resize +1000<cr>
nnoremap <silent> † :vertical resize -1000<cr>
inoremap <silent> œ <Esc>:resize +1000<cr>a
inoremap <silent> ∑ <Esc><c-w><c-=>i
inoremap <silent> ´ <Esc>:resize -1000<cr>a
inoremap <silent> ® <Esc>:vertical resize +1000<cr>a
inoremap <silent> † <Esc>:vertical resize -1000<cr>a
tnoremap <silent> œ <C-\><C-n>:resize +1000<cr>a
tnoremap <silent> ∑ <C-\><C-n><c-w><c-=>i
tnoremap <silent> ´ <C-\><C-n>:resize -1000<cr>a
tnoremap <silent> ® <C-\><C-n>:vertical resize +1000<cr>a
tnoremap <silent> † <C-\><C-n>:vertical resize -1000<cr>a
" Paste text
tnoremap <A-v> <C-\><C-n>pi
inoremap <A-v> <Esc>pi
inoremap <A-r>r <Esc>:C ! <cr>a
inoremap <A-r>1 <Esc>:C g1<cr>a
inoremap <A-r>2 <Esc>:C g2<cr>a
inoremap <A-r>3 <Esc>:C g3<cr>a
inoremap <A-r>4 <Esc>:C g4<cr>a
inoremap <A-r>5 <Esc>:C g5<cr>a
inoremap <A-r>6 <Esc>:C g6<cr>a
inoremap <A-r>7 <Esc>:C g7<cr>a
inoremap <A-r>8 <Esc>:C g8<cr>a
inoremap <A-r>9 <Esc>:C g9<cr>a
inoremap <A-r>0 <Esc>:C g0<cr>a
nnoremap <A-r>r <Esc>:C !<cr>
nnoremap <A-r>1 <Esc>:C g1<cr>
nnoremap <A-r>2 <Esc>:C g2<cr>
nnoremap <A-r>3 <Esc>:C g3<cr>
nnoremap <A-r>4 <Esc>:C g4<cr>
nnoremap <A-r>5 <Esc>:C g5<cr>
nnoremap <A-r>6 <Esc>:C g6<cr>
nnoremap <A-r>7 <Esc>:C g7<cr>
nnoremap <A-r>8 <Esc>:C g8<cr>
nnoremap <A-r>9 <Esc>:C g9<cr>
nnoremap <A-r>0 <Esc>:C g0<cr>
nnoremap <A-d> :DevDocsUnderCursor<cr>
nnoremap ∂ :DevDocsUnderCursor<cr>
" Tab navigate
nnoremap <A-,> gT
nnoremap <A-.> gt
inoremap <A-,> <ESC>gTi
inoremap <A-.> <ESC>gti
tnoremap <A-,> <C-\><C-n>gTi
tnoremap <A-.> <C-\><C-n>gti
nnoremap <silent> f :<C-u>call EasyMotion#overwin#w()<CR>
nnoremap <A-n> :NERDTreeTabsToggle<CR>
inoremap <A-n> <Esc>:NERDTreeTabsToggle<CR>
tnoremap <A-n> <C-\><C-n>:NERDTreeTabsToggle<CR>
inoremap <A-g> <C-o>:register<cr>
nnoremap <A-g> :register<cr>
function! ShowDoc()
let l:my_filetype = &filetype
echo l:my_filetype
if l:my_filetype == 'scala'
execute "EnDocBrowse"
elseif l:my_filetype == 'java'
execute "EnDocBrowse"
else
call LanguageClient_textDocument_hover()
endif
endfunction
function! ShowDef()
let l:my_filetype = &filetype
echo l:my_filetype
if l:my_filetype == 'scala'
execute "EnDeclaration"
elseif l:my_filetype == 'java'
execute "EnDeclaration"
else
call LanguageClient_textDocument_definition()
endif
endfunction
nnoremap <silent> K :call ShowDoc()<CR>
nnoremap <silent> gd :call ShowDef()<CR>
inoremap <silent><expr> <A-/>
\ pumvisible() ? "\<C-n>" :
\ deoplete#mappings#manual_complete()" Grep
" B for current buffer
" For example, Lines for Lines in loaded buffers.
" BLines for Lines in the current buffer
nnoremap <leader>zl :Lines<cr>
nnoremap <leader>zbl :BLines<cr>
nnoremap <leader>zc :Commits<cr>
nnoremap <leader>zbc :BCommits<cr>
nnoremap <leader>zh :History<cr>
nnoremap <leader>zm :Marks<cr>
nnoremap <leader>za :Ag<cr>
nnoremap <leader>zf :Files<cr>
nnoremap <leader>zp :Files<cr>
nnoremap <leader>zo :Buffers<cr>
nnoremap <leader>zg :GitFiles<cr>
nnoremap <silent> <leader>gs :Gstatus<CR>
nnoremap <silent> <leader>gd :Gdiff<CR>
nnoremap <silent> <leader>gc :Gcommit<CR>
nnoremap <silent> <leader>gb :Gblame<CR>
nnoremap <silent> <leader>gl :Glog<CR>
nnoremap <silent> <leader>gp :Git push<CR>
nnoremap <silent> <leader>gr :Gread<CR>
nnoremap <silent> <leader>gw :Gwrite<CR>
nnoremap <silent> <leader>ge :Gedit<CR>
nnoremap <silent> <leader>gi :Git add -p %<CR>
nnoremap <silent> <leader>gg :SignifyToggle<CR>
nnoremap <silent> <leader>gu :Gpull --rebase<CR>
nnoremap <silent> <leader>ga :Agit<CR>
" When you press <leader>r you can search and replace the selected text
vnoremap <silent> <leader>r :call VisualSelection('replace')<CR>
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :call VisualSelection('f')<CR>
vnoremap <silent> # :call VisualSelection('b')<CR>
" Disable highlight
nnoremap <silent> <leader>g<cr> :noh<cr>
" Switch CWD to the directory of the open buffer
nnoremap <leader>cd :cd %:p:h<cr>:pwd<cr>
nnoremap <silent> <leader>fx :Explore<space>
nnoremap <silent> <leader>fr :Explore scp://
nnoremap <silent> <leader>fb :Rexplore<CR>
nnoremap <silent> <leader>ft :NERDTreeToggle<CR>
" Tab mappings
nnoremap <leader>tn :tabnew %<cr>
nnoremap <leader>to :tabonly<cr>
nnoremap <leader>tc :tabclose<cr>
nnoremap <leader>tm :tabmove
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
nnoremap <leader>te :terminal<cr>
" Open vimgrep and put the cursor in the right position
"nnoremap <leader>gv :vimgrep // **/* <left><left><left><left><left><left><left>
" Vimgreps in the current file
"nnoremap <leader><space> :vimgrep // <Home><right><right><right><right><right><right><right><right><right>
" close buffer/window
nnoremap <leader>qq :Bclose<cr>:q<cr>
nnoremap <leader>qw :q<cr>
nnoremap <leader>qb :Bclose<cr>
" State
nnoremap <leader>sn :set nu!<cr>
nnoremap <leader>sw :set wrap!<cr>
nnoremap <leader>sp :setlocal paste!<cr>
nnoremap <leader>sm :call ToggleMouse()<cr>
nnoremap <leader>ss :call ToggleStatusLine()<cr>
" Find file in NERDTree
nnoremap <leader>ff :NERDTreeMirrorOpen<cr>:NERDTreeTabsFind<cr>
nnoremap <leader>fe :edit <c-r>=expand("%:p:h")<cr>/
nnoremap <leader>ed :Explore <c-r>=expand("%:p:h")<cr><cr>
nnoremap <leader>fi :NERDTreeMirrorOpen<cr>:NERDTreeTabsFind<cr>
" Bookmarks keybinding
"nnoremap <Leader>bt <Plug>BookmarkToggle
"nnoremap <Leader>bi <Plug>BookmarkAnnotate
"nnoremap <Leader>ba <Plug>BookmarkShowAll
"nnoremap <Leader>bj <Plug>BookmarkNext
"nnoremap <Leader>bk <Plug>BookmarkPrev
"nnoremap <Leader>bc <Plug>BookmarkClear
"nnoremap <Leader>bx <Plug>BookmarkClearAll
"nnoremap <Leader>bk <Plug>BookmarkMoveUp
"nnoremap <Leader>bj <Plug>BookmarkMoveDown
"nnoremap <leader>w :W3mTab google
" Easymotion
nmap <leader>ms <Plug>(easymotion-s)
nmap <leader>mf <Plug>(easymotion-overwin-w)
nmap <Leader>mh <Plug>(easymotion-linebackward)
nmap <Leader>mj <Plug>(easymotion-j)
nmap <Leader>mk <Plug>(easymotion-k)
nmap <Leader>ml <Plug>(easymotion-lineforward)
" Gina
"nnoremap <leader>vs :Gina status<cr>
"nnoremap <leader>vpl :Gina pull<cr>
"nnoremap <leader>vph :Gina push<cr>
"nnoremap <leader>vf :Gina fetch<cr>
"nnoremap <leader>vd :Gina diff<cr>
"nnoremap <leader>vl :Gina log<cr>
"nnoremap <leader>vc :Gina commit<cr>
"nnoremap <leader>va :Gina add<space>
"nnoremap <leader>vt :Gina tag<cr>
"nnoremap <leader>vb :Gina branch<cr>
"nnoremap <leader>vv :Gina<space>
autocmd FileType vimwiki nmap <leader><space> <Plug>VimwikiToggleListItem
nnoremap <leader>wf :call fzf#vim#ag('', {'dir': '~/Dropbox/vimwiki/', 'down': '40%'})<cr>
nnoremap <leader>eu :UndotreeToggle<cr>
nnoremap <leader>es :e $MYVIMRC<cr>
nnoremap <leader>er :registers<cr>
" open new terminal in new tab/buffer.
map <leader>tt :tabnew %<cr>:terminal<cr>
map <leader>tb :split<cr><c-w>j:terminal<cr>
nnoremap <leader>bp :b#<cr>
nnoremap <silent> <leader>lsf :call LanguageClient_textDocument_documentSymbol()<CR>
nnoremap <silent> <leader>lsw :call LanguageClient_workspace_symbol()<CR>
nnoremap <silent> <leader>lrf :call LanguageClient_textDocument_references()<CR>
nnoremap <silent> <leader>lrn :call LanguageClient_textDocument_rename()<CR>
nnoremap <silent> <leader>lf :call LanguageClient_textDocument_formatting()<CR>
source ~/.vim_custom.vim
"silent colorscheme desert
silent! colorscheme onedark
let g:lmap = {}
let g:llmap = {}
"let g:lmap.v = { 'name' : 'Version Controll' }
let g:lmap.g = { 'name' : 'Git' }
let g:lmap.z = { 'name' : 'Grep/Find/FZF' }
let g:lmap.t = { 'name' : 'Tab' }
let g:lmap.b = { 'name' : 'Buffer/Bookmark' }
let g:lmap.c = { 'name' : 'Comment/cd' }
let g:lmap.q = { 'name' : 'Quit' }
let g:lmap.l = { 'name' : 'Language' }
let g:lmap.f = { 'name' : 'File/esearch' }
let g:lmap.s = { 'name' : 'Status' }
let g:lmap.m = { 'name' : 'Moves' }
let g:lmap.w = { 'name' : 'Wiki' }
let g:lmap.e = { 'name' : 'Edit' }
let g:lmap.l.s = { 'name' : 'Doc/Worspace Symbol' }
let g:lmap.l.r = { 'name' : 'Rename/Reference' }
silent! call leaderGuide#register_prefix_descriptions(mapleader, "g:lmap")
silent! call leaderGuide#register_prefix_descriptions(maplocalleader, "g:llmap")
nnoremap <silent> <leader> :<c-u>LeaderGuide ','<CR>
nnoremap <silent> <localleader> :<c-u>LeaderGuide '_'<CR>
" Workspace Setup
" ----------------
function! DefaultWorkspace()
sp
wincmd j
resize 8
terminal
wincmd k
endfunction
command! -register DefaultWorkspace call DefaultWorkspace()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment