Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
859 lines (703 sloc) 23.2 KB
let mapleader = ","
let maplocalleader = "\<space>"
" 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
{% if nvim %}
{% else %}
if &shell =~# 'fish$'
set shell=sh
endif
{% endif %}
set nocompatible " be iMproved
filetype off " required before plugins
{% if nvim %}
silent! call plug#begin('~/.config/nvim/plugged')
{% else %}
silent! call plug#begin('~/.vim/plugged')
{% endif %}
Plug 'hecal3/vim-leader-guide'
"Autojump to 1st non-blank when j/k into leading spaces.
Plug 'fcpg/vim-shore'
Plug 'scrooloose/nerdtree', { 'on': ['NERDTreeToggle', 'NERDTreeTabsToggle', 'NERDTreeMirrorOpen', 'NERDTreeTabsFind'] }
Plug 'Xuyuanp/nerdtree-git-plugin', { 'on': ['NERDTreeToggle', 'NERDTreeTabsToggle', 'NERDTreeMirrorOpen', 'NERDTreeTabsFind'] }
Plug 'jistr/vim-nerdtree-tabs', { 'on': ['NERDTreeToggle', 'NERDTreeTabsToggle', 'NERDTreeMirrorOpen', 'NERDTreeTabsFind'] }
"Plug 'vim-scripts/grep.vim'
"Plug 'ervandew/supertab'
"Plug 'DevWurm/autosession.vim'
"Plug 'ntpeters/vim-better-whitespace'
Plug 'gagoar/stripwhitespaces'
" + for expand, _ for shrink
Plug 'terryma/vim-expand-region'
Plug 'bling/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" vim-airline-clock and gitgutter will make neovim memory leak
" https://github.com/neovim/neovim/issues/7871
"Plug 'enricobacis/vim-airline-clock'
Plug 'easymotion/vim-easymotion'
Plug 'itchyny/calendar.vim', { 'on': 'Calendar'}
Plug 'vimwiki/vimwiki', { 'on': 'VimwikiIndex' }
Plug 'haya14busa/incsearch.vim'
Plug 'fidian/hexmode'
Plug 'blueyed/vim-diminactive' " use different background color for inactive window
Plug 'janko-m/vim-test', { 'on': ['TestFile','TestLast','TestNearest','TestSuite','TestVisit']}
Plug 'mhinz/vim-grepper', { 'on': ['Grepper', '<plug>(GrepperOperator)'] }
Plug 'simeji/winresizer'
"Plug 'pseewald/vim-anyfold'
Plug 'google/vim-searchindex'
Plug 't9md/vim-choosewin'
Plug 'john-nanney/pushd.vim'
" File manager
Plug 'cocopon/vaffle.vim'
" Helper for netrw. I use vaffle. It will useless
"Plug 'tpope/vim-vinegar'
" This support rclone.
"Plug 'ipod825/vim-netranger'
Plug 'Yggdroot/indentLine'
"Plug 'vim-multiple-cursors'
"Plug 'osyo-manga/vim-over'
"Plug 'justinmk/vim-gtfo'
"Plug 'Shougo/unite.vim'
"Plug 'JamshedVesuna/vim-markdown-preview' " sudo pip install grip
" set filetype=rest
" <c-j> for send request
" http://localhost:9200
" POST /testindex/testtype
" {
" "key": "new key",
" "value": "new value"|
" }
Plug 'diepm/vim-rest-console'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
"Plug 'ctrlpvim/ctrlp.vim'
" colorscheme
Plug 'morhetz/gruvbox'
Plug 'joshdick/onedark.vim'
Plug 'iCyMind/NeoSolarized'
Plug 'liuchengxu/space-vim-dark' " Good
Plug 'lifepillar/vim-solarized8'
Plug 'tomasiser/vim-code-dark'
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'tyrannicaltoucan/vim-deep-space'
Plug 'connorholyday/vim-snazzy'
Plug 'bluz71/vim-moonfly-colors'
Plug 'hzchirs/vim-material'
Plug 'kaicataldo/material.vim'
" Lang
Plug 'dag/vim-fish'
Plug 'ekalinin/Dockerfile.vim'
Plug 'hashivim/vim-vagrant'
"Plug 'ensime/ensime-vim', { 'do': ':UpdateRemotePlugins' }
{% if not programming %}"{% endif %}Plug 'artur-shaik/vim-javacomplete2', { 'for': 'java' }
{% if not programming %}"{% endif %}Plug 'fatih/vim-go', { 'for': 'go' }
{% if not programming %}"{% endif %}Plug 'pangloss/vim-javascript', { 'for': 'javascript' }
{% if not programming %}"{% endif %}Plug 'plasticboy/vim-markdown', { 'for': 'markdown' }
{% if not programming %}"{% endif %}Plug 'pearofducks/ansible-vim', { 'for': 'ansible' }
{% if not programming %}"{% endif %}Plug 'Shougo/vimproc.vim', {'do' : 'make'}
{% if not programming %}"{% endif %}Plug 'HerringtonDarkholme/yats.vim', { 'for': 'typescript' } " typescript
{% if not programming %}"{% endif %}Plug 'Glench/Vim-Jinja2-Syntax'
"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
if executable("fcitx") == 1
Plug 'vim-scripts/fcitx.vim'
endif
{% if programming %}
Plug 'kjelly/auto-pairs'
Plug 'tpope/vim-fugitive'
Plug 'cohama/agit.vim', { 'on': ['Agit', 'AgitFile'] }
"Plug 'lambdalisue/gina.vim'
Plug 'godlygeek/tabular', { 'on': 'Tabularize' }
Plug 'majutsushi/tagbar', { 'on': ['Tagbar'] }
" emmet `<c-y>,` for expand `div>a` to `<div><a></a></div>
Plug 'mattn/emmet-vim'
Plug 'w0rp/ale', { 'for': 'go'}
Plug 'scrooloose/nerdcommenter'
" Useful for handling tag
Plug 'tpope/vim-surround'
Plug 'Shougo/denite.nvim'
Plug 'iamcco/devdocs.nvim', { 'do': 'npm install' }
"Plug 'myusuf3/numbers.vim'
Plug 'mbbill/undotree', { 'on': ['UndotreeToggle']}
" 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', { 'on': 'DevDocsUnderCursor'}
{% if nvim %}
if has('python3')
" Buffer filtering
Plug 'lambdalisue/lista.nvim', { 'do': ':UpdateRemotePlugins'}
Plug 'kjelly/nvim-multiterm', { 'do': ':UpdateRemotePlugins'}
Plug 'vim-vdebug/vdebug', { 'on': 'VdebugStart'}
endif
"Plug 'Shougo/neosnippet'
"Plug 'Shougo/neosnippet-snippets'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
"Plug 'ncm2/ncm2'
"Plug 'roxma/nvim-yarp'
"Plug 'ncm2/ncm2-bufword'
"Plug 'ncm2/ncm2-tmux'
"Plug 'ncm2/ncm2-path'
"Plug 'ncm2/ncm2-syntax' | Plug 'Shougo/neco-syntax'
"Plug 'ncm2/ncm2-vim' | Plug 'Shougo/neco-vim'
"Plug 'ncm2/ncm2-ultisnips'
if has('python3')
Plug 'autozimu/LanguageClient-neovim', { 'do': 'bash ./install.sh', 'branch': 'next' }
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
"Plug 'roxma/nvim-completion-manager' "this is like deoplete
"Plug 'roxma/nvim-cm-tern' "javascript
"Plug 'fgrsnau/ncm-otherbuf' "Word from other buffers
"Plug 'calebeby/ncm-css'
"Plug 'mhartington/nvim-typescript'
" it's needed because lsp doesn't work for go
"Plug 'zchee/deoplete-go', { 'do': 'make', 'for': 'go'}
"Plug 'zchee/deoplete-jedi'
"Plug 'mhartington/nvim-typescript'
"Plug 'ternjs/tern_for_vim'
"Plug 'carlitux/deoplete-ternjs'
else
" If not programming, use pure vimL plugins for vim and neovim.
Plug 'prabirshrestha/asyncomplete.vim' "this is like deoplete
Plug 'prabirshrestha/asyncomplete-buffer.vim'
Plug 'prabirshrestha/asyncomplete-file.vim'
Plug 'wellle/tmux-complete.vim'
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#file#get_source_options({
\ 'name': 'file',
\ 'whitelist': ['*'],
\ 'priority': 10,
\ 'completor': function('asyncomplete#sources#file#completor')
\ }))
let g:tmuxcomplete#asyncomplete_source_options = {
\ 'name': 'tmuxcomplete',
\ 'whitelist': ['*'],
\ 'config': {
\ 'splitmode': 'words',
\ 'filter_prefix': 1,
\ 'show_incomplete': 1,
\ 'sort_candidates': 0,
\ 'scrollback': 0,
\ 'truncate': 0
\ }
\ }
endif
Plug 'Shougo/neco-vim'
Plug 'Shougo/neco-syntax'
" project-wide async search and replace
" `,ff` for esearch.
Plug 'eugen0329/vim-esearch'
{% else %}
Plug 'Valloric/YouCompleteMe'
"Plug 'maralla/completor.vim' "for vim8
{% endif %}
{% else %}
{% endif %}
{% if nvim %}
Plug 'mhinz/neovim-remote'
"Plug 'kassio/neoterm', { 'commit': '9e33da0a' }
" For neovim-qt or go-nvim
Plug 'equalsraf/neovim-gui-shim'
{% endif %}
call plug#end()
silent! call denite#custom#map('insert', '<C-j>', '<denite:move_to_next_line>', 'noremap')
silent! call denite#custom#map('insert', '<C-k>', '<denite:move_to_previous_line>', 'noremap')
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
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set dir=~/.vim_cache/swapfiles
set backup
set backupdir=~/.vim_cache
set undofile
set undodir=~/.vim_cache
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => 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 nowrap "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 foldlevel=9
set sessionoptions+=globals
if executable("fish") == 1
set shell=fish
endif
let @/ = ""
let anyfold_activate=1
let anyfold_fold_comments=1
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 = 0
"let g:vimshell_prompt_expr =
"\ 'escape(fnamemodify(getcwd(), ":~").">", "\\[]()?! ")." "'
"let g:vimshell_prompt_pattern = '^\%(\f\|\\.\)\+> '
" Easymotion
let g:EasyMotion_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
if executable("ag") == 1
let $FZF_DEFAULT_COMMAND='ag -g ""'
endif
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>"
let g:UltiSnipsRemoveSelectModeMappings = 0
" 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': ['rls'],
\ 'python': ['pyls'],
\ 'ruby': ['language_server-ruby'],
\ 'go': ['go-langserver', '-gocodecompletion', '-func-snippet-enabled=false', '-trace', '-logfile', expand('~/langserver-go.log')],
\ 'javascript': ['typescript-language-server', '--stdio'],
\ 'javascript.jsx': ['typescript-language-server', '--stdio'],
\ 'typescript': ['typescript-language-server', '--stdio'],
\ 'dart': ['dart_language_server'],
\ 'css': ['css-languageserver', '--stdio'],
\ 'sass': ['css-languageserver', '--stdio'],
\ 'dockfile': ['docker-langserver', '--stdio'],
\ 'c': ['cquery', '--log-file=/tmp/cq.log'],
\ 'cpp': ['cquery', '--log-file=/tmp/cq.log'],
\ }
let g:LanguageClient_loadSettings = 1
let g:LanguageClient_settingsPath = '~/.config/nvim/settings.json'
let g:LanguageClient_diagnosticsDisplay={
\ 1: {
\ "name": "Error",
\ "texthl": "ALEError",
\ "signText": "X",
\ "signTexthl": "ALEErrorSign",
\ },
\ 2: {
\ "name": "Warning",
\ "texthl": "ALEWarning",
\ "signText": "W",
\ "signTexthl": "ALEWarningSign",
\ },
\ 3: {
\ "name": "Information",
\ "texthl": "ALEInfo",
\ "signText": "I",
\ "signTexthl": "ALEInfoSign",
\ },
\ 4: {
\ "name": "Hint",
\ "texthl": "ALEInfo",
\ "signText": "H",
\ "signTexthl": "ALEInfoSign",
\ },
\ }
let g:LanguageClient_diagnosticsEnable=1
let g:bookmark_no_default_key_mappings = 1
let g:UltiSnipsNoPythonWarning = 1
let g:go_list_type = "quickfix"
{% if python2_exec is defined and python3_exec.exist %}
let g:python_host_prog='{{ python2_exec.path }}'
{% endif %}
{% if python3_exec is defined and python3_exec.exist %}
let g:python3_host_prog='{{ python3_exec.path }}'
{% endif %}
let $BROWSER='w3m'
let g:AutoPairsFlyMode = 1
let g:AutoPairsShortcutToggle = ''
let g:AutoPairsShortcutFastWrap = ''
let g:AutoPairsShortcutJump = ''
let g:AutoPairsMapCh = ''
let g:AutoPairsMapSpace = ''
let g:AutoPairsShortcutBackInsert ='<M-\>'
let g:vrc_keepalt = 1
let g:vrc_curl_opts = {
\ '-sS': '',
\ '--connect-timeout': 10,
\}
let g:NERDTreeWinSize=20
{% if nvim %}let test#strategy = "neovim" {% endif %}
"Fuzzy matching for complete
let g:cm_matcher={'module': 'cm_matchers.fuzzy_matcher', 'case': 'smartcase'}
"
"fuzzy matching
silent! call deoplete#custom#source('_', 'matchers', ['matcher_full_fuzzy'])
" Disable the truncate feature.
silent! call deoplete#custom#source('_', 'max_abbr_width', 0)
silent! call deoplete#custom#source('_', 'max_menu_width', 0)
let g:deoplete#omni#input_patterns={}
let g:deoplete#omni#input_patterns.scala='[^. *\t]\.\w*'
" Autocmd
autocmd! InsertLeave,WinEnter * set cursorline
autocmd! InsertEnter,WinLeave * set nocursorline
{% if nvim %}
autocmd! BufEnter * set laststatus=2
"autocmd! BufEnter * if &buftype == 'terminal' | :set laststatus=0 | endif
"autocmd! TermOpen *sh set laststatus=0
autocmd! TermOpen *sh* set nonu
"autocmd! BufEnter * if &buftype == 'terminal' | :startinsert | endif
{% if programming %}
autocmd! InsertEnter * silent! call deoplete#enable()
"autocmd! BufEnter * silent! call ncm2#enable_for_buffer()
"set completeopt=noinsert,menuone,noselect
{% endif %}
{% endif %}
autocmd! bufwritepost .vimrc source %
autocmd! bufwritepost init.vim source %
autocmd! CursorHold * checktime
autocmd! BufCreate __REST_response__ vertical resize 20
autocmd! BufCreate __REST_response__ set nonu
autocmd! BufEnter __REST_response__ set modifiable
autocmd! FileType tagbar vertical resize 20
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
command! Cd1 :cd ..
command! Cd2 :cd ../..
command! Cd3 :cd ../../..
command! E :Explore
" Similarly, we can apply it to fzf#vim#grep. To use ripgrep instead of ag:
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
" 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
{% include './templates/keybindings.vim' %}
{% include './templates/keybindings_leader.vim' %}
{% if nvim and programming %}set termguicolors{% endif %}
"silent colorscheme desert
if filereadable(expand("~/.vim_custom.vim")) && match(readfile(expand("~/.vim_custom.vim")),"colorscheme")==-1
silent! colorscheme gruvbox
endif
if !filereadable(expand("~/.vim_custom.vim"))
silent! colorscheme gruvbox
endif
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/Window' }
let g:lmap.r = { 'name' : 'Run/Test' }
let g:lmap.o = { 'name' : 'Fold' }
let g:lmap.e = { 'name' : 'Edit' }
let g:lmap.e.c = { 'name' : 'Copy file path' }
let g:lmap.l.s = { 'name' : 'Doc/Worspace Symbol' }
let g:lmap.l.r = { 'name' : 'Rename/Reference' }
let g:lmap.l.t = { 'name' : 'Test' }
let g:lmap.m.p = [ 'normal! [`', 'Previous mark']
let g:lmap.m.n = [ 'normal! ]`', 'Next mark']
let $PATH .= ':' . fnamemodify(expand('$MYVIMRC'), ':h') . '/bin'
let g:indentLine_fileTypeExclude = ['vimwiki', 'markdown', 'calendar', 'json']
let g:indentLine_bufTypeExclude = ['help', 'terminal']
let g:indentLine_bufNameExclude= ['*.md']
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 '<space>'<CR>
{% if nvim %}
" Workspace Setup
" ----------------
function! DefaultWorkspace()
sp
wincmd j
resize 8
terminal
wincmd k
endfunction
command! -register DefaultWorkspace call DefaultWorkspace()
{% endif %}
" Wiki
" ----------------
function! Wiki()
set autoread
set autowrite
VimwikiIndex
endfunction
command! -register Wiki call Wiki()
silent! source ~/.vim_custom.vim