vim/vimrc

1714 lines
49 KiB
VimL
Raw Normal View History

2018-12-02 21:31:01 +00:00
" ●
2017-09-10 20:22:02 +00:00
2019-02-18 20:52:37 +00:00
if &shell =~# 'fish$'
set shell=bash
endif
2018-12-05 17:26:36 +00:00
runtime vimrc-config
2018-12-02 22:33:19 +00:00
let g:vimrc_load_dev_plugins = exists('g:vimrc_load_dev_plugins')
\ ? g:vimrc_load_dev_plugins : 0
let g:vimrc_enable_statusline = exists('g:vimrc_enable_statusline')
\ ? g:vimrc_enable_statusline : 0
let g:vimrc_enable_tabline = exists('g:vimrc_enable_tabline')
\ ? g:vimrc_enable_tabline : 0
let g:vimrc_auto_window_settings = exists('g:vimrc_auto_window_settings')
\ ? g:vimrc_auto_window_settings : 0
"}}}
" #plugins {{{
2018-11-04 16:15:18 +00:00
if empty(glob('~/.vim/autoload/plug.vim'))"{{{
2018-09-25 13:54:09 +00:00
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
2018-11-04 16:15:18 +00:00
"}}}
2018-11-18 22:07:16 +00:00
if !has('nvim')
call plug#begin('~/.vim/bundle')
2018-09-25 13:54:09 +00:00
2018-11-27 21:57:06 +00:00
Plug '~/.config/vim/vim/bundle/vim-learnxiny'
2018-12-02 21:31:01 +00:00
" #Netrw {{{
let g:netrw_liststyle=3
let g:netrw_list_hide='^\..*'
let g:netrw_preview = 0
"}}}
" #MatchTagAlways{{{
" https://github.com/Valloric/MatchTagAlways
Plug 'Valloric/MatchTagAlways'
let g:mta_filetypes = {
\ 'jinja' : 1,
\ 'html' : 1,
\ 'vue' : 1,
\ 'xhtml' : 1,
\ 'xml' : 1,
\}
"}}}
" #Obsession{{{
Plug 'tpope/vim-obsession'
"}}}
" #switch {{{
"https://github.com/AndrewRadev/switch.vim
Plug 'AndrewRadev/switch.vim'
let g:switch_mapping = '<space>-'
let g:switch_custom_definitions = [
\ ['0', '1'],
\ ['ease-in', 'ease-out', 'ease-in-out', 'linear'],
\ ['auto', 'none'],
\ ['left', 'right'],
\ ['top', 'bottom'],
\ ['row', 'column'],
2018-12-15 15:09:02 +00:00
\ ['relative', 'absolute', 'fixed'],
\ ['private', 'public', 'protected']
2018-12-02 21:31:01 +00:00
\ ]
"}}}
" #undotree {{{
Plug 'mbbill/undotree'
nnoremap <space>ut :UndotreeToggle<cr>
"}}}
" #tcomment_vim{{{
" https://github.com/tomtom/tcomment_vim
Plug 'tomtom/tcomment_vim'
"}}}
" #vim-easy-align {{{
" https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'
xmap ga <Plug>(EasyAlign)
nmap ga <Plug>(EasyAlign)
"}}}
2018-12-12 21:18:10 +00:00
" #vim-fzf {{{
" https://github.com/junegunn/fzf.vim
if executable('fzf') && v:version >= 704
Plug 'junegunn/fzf.vim'
2019-02-18 20:52:37 +00:00
nnoremap <space>fg :GFiles<CR>
2018-12-12 21:18:10 +00:00
nnoremap <space>ff :Files<CR>
2019-02-18 20:52:37 +00:00
nnoremap <space>fr :History<CR>
2018-12-12 21:18:10 +00:00
nnoremap <space>ft :Tags<CR>
nnoremap <space>fb :Buffers<CR>
nnoremap <space>fh :Helptags<CR>
nnoremap <space>fa :Ag<CR>
2019-02-18 20:52:37 +00:00
nnoremap <space>fA :Ag!<CR>
2018-12-12 21:18:10 +00:00
" Ag! gives fullscreen with preview
command! -bang -nargs=* Ag
\ call fzf#vim#ag(<q-args>,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Label'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'WildMenu'],
\ 'info': ['fg', 'Comment'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Constant'],
\ 'pointer': ['fg', 'Special'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
endif
"}}}
2019-02-22 20:08:53 +00:00
" #vim-markdown{{{
2019-02-13 12:26:52 +00:00
" https://github.com/plasticboy/vim-markdown
Plug 'plasticboy/vim-markdown'
let g:vim_markdown_toc_autofit = 1
let g:vim_markdown_fenced_languages = ['bash=sh']
2019-02-22 20:08:53 +00:00
"}}}
2018-12-02 21:31:01 +00:00
" #vim-qlist {{{
" Original: https://github.com/romainl/vim-qlist
Plug 'studio-vx/vim-qlist'
"}}}
" #vim-repeat{{{
" https://github.com/tpope/vim-repeat
Plug 'tpope/vim-repeat'
"}}}
" #vim-rsi{{{
"https://github.com/tpope/vim-rsi
Plug 'tpope/vim-rsi'
"}}}
" #vim-surround{{{
Plug 'tpope/vim-surround'
"}}}
" #vim-fugitive{{{
" https://github.com/tpope/vim-fugitive/blob/master/README.markdown
Plug 'tpope/vim-fugitive'
nnoremap <silent> <space>gs :Gstatus<CR>
nnoremap <silent> <space>gd :tabedit %<CR>:Gdiff<CR>
nnoremap <silent> <space>gc :Gcommit<CR>
nnoremap <silent> <space>gl :Glog<CR>
nnoremap <silent> <space>gp :Gpush<CR>:copen<CR>
2019-01-16 23:08:30 +00:00
nnoremap <silent> <space>gp :Gpushjob<CR>:copen<CR>
2018-12-02 21:31:01 +00:00
"}}}
" #wakatime{{{
" https://wakatime.com/vim
Plug 'wakatime/vim-wakatime'
2019-01-16 23:08:30 +00:00
"}}}
" #wal.vim {{{
" https://github.com/dylanaraps/wal.vim
Plug 'dylanaraps/wal.vim'
2018-12-02 21:31:01 +00:00
"}}}
2019-02-22 21:43:35 +00:00
" development plugins
2018-12-02 22:33:19 +00:00
if g:vimrc_load_dev_plugins
2018-11-25 23:03:43 +00:00
" #ALE {{{
" https://github.com/w0rp/ale
Plug 'w0rp/ale'
2019-02-09 22:15:36 +00:00
" let g:ale_completion_enabled = 1
2018-11-25 23:03:43 +00:00
let g:ale_sign_column_always = 1
let g:ale_open_list = 0
2019-01-16 23:08:30 +00:00
" when coc enabled
" let g:ale_linters = {'scss': ['stylelint'], 'javascript': [], 'php':['php'], 'html':['htmlhint'], 'python': [], 'vue': []}
" when coc not enabled
2019-01-19 13:26:15 +00:00
let g:ale_linters = {'scss': ['stylelint'], 'javascript': ['tsserver', 'eslint'], 'json': ['jsonlint'], 'php':['php'], 'python': ['pyls', 'flake8'], 'html':['htmlhint'], 'vue': ['vls', 'eslint']}
2019-01-16 23:08:30 +00:00
2018-11-25 23:03:43 +00:00
let g:ale_html_htmlhint_options = '-c ~/.htmlhintrc --format=unix'
2019-01-18 23:36:04 +00:00
let g:ale_fixers = {'javascript': ['eslint'], 'json': ['jq'], 'python': ['black'], 'vue': ['eslint']}
2018-11-25 23:03:43 +00:00
let g:ale_sign_error = 'Α'
let g:ale_sign_warning = 'α'
2019-01-18 23:36:04 +00:00
nmap \\ <Plug>(ale_detail)
nmap \f <Plug>(ale_fix)
nmap \r <Plug>(ale_find_references)
nmap \g <Plug>(ale_go_to_definition)
nmap \d <Plug>(ale_documentation)
nmap \h <Plug>(ale_hover)
nmap \n <Plug>(ale_next)
nmap \p <Plug>(ale_previous)
2019-01-16 23:08:30 +00:00
"}}}
" " #coc.nvim{{{
" " https://github.com/neoclide/coc.nvim
" Plug 'neoclide/coc.nvim', {'tag': '*', 'do': { -> coc#util#install()}}
"
" let g:coc_snippet_next = '<tab>'
" let g:coc_snippet_prev = '<s-tab>'
"
" inoremap <silent><expr> <c-n> coc#refresh()
" nnoremap <silent> K :call <SID>show_documentation()<CR>
" nnoremap <silent> \d <Plug>(coc-definition)
" nnoremap <silent> \y <Plug>(coc-type-definition)
" nnoremap <silent> \i <Plug>(coc-implementation)
" nnoremap <silent> \r <Plug>(coc-references)
" nnoremap \n <Plug>(coc-rename)
" vnoremap \f <Plug>(coc-format-selected)
" nnoremap \f <Plug>(coc-format-selected)
" command! -nargs=0 Format :call CocAction('format')
" command! -nargs=? Fold :call CocAction('fold', <f-args>)
"
" function! s:show_documentation()
" if &filetype == 'vim' || &filetype == 'help'
" execute 'h '.expand('<cword>')
" else
" call CocAction('doHover')
" endif
" endfunction
" " }}}
2018-11-20 09:47:07 +00:00
" #colorV {{{
2018-11-18 22:07:16 +00:00
" original:
" https://github.com/gu-fan/colorv.vim
" Plug 'gu-fan/colorv.vim'
" custom fork:
" https://github.com/studio-vx/colorv.vim
Plug 'studio-vx/colorv.vim'
let g:ColorVForceGuiColors = 1
let g:colorv_no_global_map = 1
let g:colorv_win_pos = 'top'
let g:colorv_preview_area = 0
nnoremap <space>cv :ColorV<CR>
nnoremap <space>ce :ColorVEdit<CR>
nnoremap <space>cc :call ToggleColorPreview()<CR>
nnoremap <space>ci :ColorVInsert<CR>
nnoremap <space>cp :ColorVPicker<CR>
let w:colorv_is_previewing = 0
function! ToggleColorPreview() abort "{{{
if !exists('w:colorv_is_previewing')
let w:colorv_is_previewing = 0
endif
if w:colorv_is_previewing == 0
execute 'ColorVPreview'
let w:colorv_is_previewing = 1
else
execute 'ColorVClear'
let w:colorv_is_previewing = 0
endif
endfunction "}}}
2018-09-25 13:54:09 +00:00
2018-11-18 22:07:16 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #css3-syntax{{{
2018-11-18 22:07:16 +00:00
Plug 'hail2u/vim-css3-syntax'
2018-10-31 09:04:26 +00:00
2019-02-22 21:43:35 +00:00
"}}}
" #delimitMate{{{
" https://github.com/Raimondi/delimitMate
Plug 'Raimondi/delimitMate'
let delimitMate_expand_cr = 1
let delimitMate_expand_space = 1
2018-11-18 22:07:16 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #emmet-vim {{{
2018-11-18 22:07:16 +00:00
" https://github.com/mattn/emmet-vim
Plug 'mattn/emmet-vim'
let g:user_emmet_leader_key=',,'
let g:user_emmet_settings = {
\ 'indentation': ' ',
\}
2018-11-17 20:22:58 +00:00
2018-11-18 22:07:16 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #gitgutter {{{
2018-11-18 22:07:16 +00:00
" https://github.com/airblade/vim-gitgutter/blob/master/README.mkd
Plug 'airblade/vim-gitgutter'
2018-09-25 13:54:09 +00:00
2018-11-18 22:07:16 +00:00
nmap ]h <Plug>GitGutterNextHunk
nmap [h <Plug>GitGutterPrevHunk
omap ih <Plug>GitGutterTextObjectInnerPending
omap ah <Plug>GitGutterTextObjectOuterPending
xmap ih <Plug>GitGutterTextObjectInnerVisual
xmap ah <Plug>GitGutterTextObjectOuterVisual
2018-09-25 13:54:09 +00:00
2018-11-18 22:07:16 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #gitv{{{
2018-11-18 22:07:16 +00:00
" https://github.com/gregsexton/gitv
Plug 'gregsexton/gitv'
2018-11-04 17:48:13 +00:00
2018-11-18 22:07:16 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #html5{{{
2018-11-18 22:07:16 +00:00
" https://github.com/othree/html5.vim
Plug 'othree/html5.vim'
2018-11-17 20:22:58 +00:00
2018-11-18 22:07:16 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #i3config.vim{{{
2018-11-18 22:07:16 +00:00
" https://github.com/mboughaba/i3config.vim
Plug 'mboughaba/i3config.vim'
2018-11-17 20:22:58 +00:00
2018-11-18 22:07:16 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #inline_edit.vim {{{
2018-11-18 22:07:16 +00:00
" https://github.com/AndrewRadev/inline_edit.vim
Plug 'AndrewRadev/inline_edit.vim'
2018-11-17 20:22:58 +00:00
2018-11-18 22:07:16 +00:00
let g:inline_edit_patterns = [{
\ 'main_filetype': '*html',
\ 'sub_filetype': 'scss',
\ 'indent_adjustment': 1,
\ 'start': '<style\>[^>]*lang=.scss[^>]*>',
\ 'end': '</style>'
\ }]
2018-11-17 20:22:58 +00:00
2018-11-18 22:07:16 +00:00
let g:inline_edit_autowrite = 1
let g:inline_edit_proxy_type = 'tempfile'
let g:inline_edit_new_buffer_command ='tabedit'
let g:inline_edit_modify_statusline = 0
2018-11-17 20:22:58 +00:00
2018-11-18 22:07:16 +00:00
nnoremap <space>ie :InlineEdit<cr>
2018-11-17 20:22:58 +00:00
2018-11-18 22:07:16 +00:00
"}}}
2018-12-29 19:55:03 +00:00
" #livedown.vim {{{
" https://github.com/shime/vim-livedown
Plug 'shime/vim-livedown'
let g:livedown_port = 4343
let g:livedown_command = '/home/ray/.npm-global/bin/livedown'
let g:livedown_open = 0
let g:livedown_browser = 'qutebrowser'
nnoremap <space>md :LivedownToggle<CR>
"}}}
2018-11-20 09:47:07 +00:00
" #php.vim{{{
2018-11-18 22:07:16 +00:00
" https://github.com/StanAngeloff/php.vim
Plug 'StanAngeloff/php.vim'
2018-11-04 17:48:13 +00:00
2018-11-18 22:07:16 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #phpcomplete.vim{{{
2018-11-18 22:07:16 +00:00
" https://github.com/shawncplus/phpcomplete.vim
Plug 'shawncplus/phpcomplete.vim'
" https://github.com/dsawardekar/wordpress.vim
" For up to date Wordpress Files see:
" https://github.com/joseluis/wordpress.vim-generator
2018-11-17 20:22:58 +00:00
2018-11-18 22:07:16 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #quickscope{{{
2018-11-18 22:07:16 +00:00
" https://github.com/unblevable/quick-scope
Plug 'unblevable/quick-scope'
let g:qs_highlight_on_keys = ['f', 'F', 't', 'T']
"}}}
2019-02-22 20:08:53 +00:00
" #rainbow{{{
" https://github.com/luochen1990/rainbow/blob/master/README.md
Plug 'luochen1990/rainbow'
let g:rainbow_active = 0
nnoremap <silent><space>rt :RainbowToggle<cr>
"}}}
2018-11-20 09:47:07 +00:00
" #scss-syntax{{{
2018-11-18 22:07:16 +00:00
Plug 'cakebaker/scss-syntax.vim'
2018-11-04 17:48:13 +00:00
2018-11-18 22:07:16 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #tagbar {{{
2018-11-18 22:07:16 +00:00
Plug 'majutsushi/tagbar'
nnoremap <space>tb :TagbarOpen fj<CR>
nnoremap <space>] :tag /[.#@]<c-r>=expand('<cword>')<cr><cr>
let g:tagbar_autoclose = 1
" let g:tagbar_autopreview = 1
" let g:tagbar_previewwin_pos = ''
let g:tagbar_type_css = {
\ 'ctagstype' : 'css',
\ 'kinds' : [
\ 'c:classes',
\ 'i:ids',
\ 't:tags',
\ 'm:medias'
\ ]
\}
let g:tagbar_type_scss = {
\ 'ctagstype' : 'scss',
\ 'kinds' : [
\ 'v:variables',
\ 'c:classes',
\ 'i:ids',
\ 't:tags',
\ 'd:medias',
\ 'm:mixins',
\ 'f:functions'
\ ]
\}
let g:tagbar_type_vue = {
\ 'ctagstype' : 'vue',
\ 'kinds' : [
\ 'o:objects',
\ 'f:functions',
\ 'a:array',
\ 's:string',
\ 'b:boolean',
\ 'n:number',
\ 'v:variable'
\ ]
\ }
2018-09-25 13:54:09 +00:00
2018-11-18 22:07:16 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #ultisnips {{{
2018-11-18 22:07:16 +00:00
" https://github.com/sirver/UltiSnips
Plug 'SirVer/ultisnips'
" and some snippets
" https://github.com/honza/vim-snippets
" Plug 'honza/vim-snippets'
nnoremap <space>ul :call ListUltisnips()<cr>
inoremap jkul <c-o>:call ListUltisnips()<cr>
let g:UltiSnipsSnippetsDir='~/.vim/UltiSnips'
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
2018-12-08 09:39:20 +00:00
let g:UltiSnipsExpandTrigger='<tab>'
2018-11-18 22:07:16 +00:00
let g:UltiSnipsJumpForwardTrigger='<tab>'
let g:UltiSnipsJumpBackwardTrigger='<s-tab>'
let g:UltiSnipsEditSplit='horizontal'
function! ListUltisnips() abort"{{{
2018-09-25 13:54:09 +00:00
let l:snips = UltiSnips#SnippetsInCurrentScope(1)
let l:keylist = sort(keys(l:snips))
2018-11-18 22:07:16 +00:00
echo ' --------------------------------------------------'
2018-09-25 13:54:09 +00:00
for l:key in l:keylist
2018-11-18 22:07:16 +00:00
echo printf(" %-10s\t%s", l:key, l:snips[l:key])
2018-09-25 13:54:09 +00:00
endfor
2018-11-18 22:07:16 +00:00
echo '---------------------------------------------------'
endfunction
2018-11-05 20:12:38 +00:00
2018-11-18 22:07:16 +00:00
"}}}
function! CompleteSnippets(findstart, base)"{{{
if a:findstart
let l:line = getline('.')
let l:start = col('.') - 1
while l:start > 0 && l:line[l:start - 1] =~ '\a'
let l:start -= 1
endwhile
return l:start
else
let l:res = []
let l:snips = UltiSnips#SnippetsInCurrentScope(1)
let l:keylist = sort(keys(l:snips))
for l:key in l:keylist
if l:key =~ '^' . a:base
let l:item = {'word': l:key, 'menu': l:snips[l:key]}
call add(l:res, l:item)
endif
endfor
return l:res
endif
endfunction
2018-09-25 13:54:09 +00:00
2018-11-18 22:07:16 +00:00
"}}}
2018-09-25 15:45:42 +00:00
2018-11-18 22:07:16 +00:00
set completefunc=CompleteSnippets
2018-09-25 13:54:09 +00:00
2018-11-18 22:07:16 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #vim-dispatch{{{
2018-11-18 22:07:16 +00:00
" https://github.com/tpope/vim-dispatch
Plug 'tpope/vim-dispatch'
2018-09-25 13:54:09 +00:00
2019-02-18 20:52:37 +00:00
"}}}
" #vim-fish{{{
" https://github.com/dag/vim-fish
Plug 'dag/vim-fish'
2018-11-18 22:07:16 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #vim-gutentags {{{
2018-11-18 22:07:16 +00:00
" https://github.com/ludovicchabant/vim-gutentags
Plug 'ludovicchabant/vim-gutentags'
2018-11-04 16:15:18 +00:00
2018-11-18 22:07:16 +00:00
let g:gutentags_ctags_tagfile = '.tags'
let g:gutentags_ctags_exclude = ['package.json', 'Session.vim', 'package-lock.json', 'TODO.txt']
2018-11-04 16:15:18 +00:00
2018-11-23 21:45:55 +00:00
"}}}
" #vim-javascript{{{
Plug 'pangloss/vim-javascript'
2018-11-24 22:36:49 +00:00
"}}}
" #vim-Jinja2-Syntax{{{
" https://github.com/studio-vx/Vim-Jinja2-Syntax
" original: https://github.com/Glench/Vim-Jinja2-Syntax
Plug 'studio-vx/Vim-Jinja2-Syntax'
2018-11-18 22:07:16 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #vim-json{{{
2018-11-18 22:07:16 +00:00
" https://github.com/elzr/vim-json
Plug 'elzr/vim-json'
2018-11-04 16:15:18 +00:00
2018-11-18 22:07:16 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #vim-lsp {{{
2018-11-18 22:07:16 +00:00
" https://github.com/prabirshrestha/vim-lsp
2018-11-25 17:55:50 +00:00
" Plug 'prabirshrestha/async.vim'
" Plug 'prabirshrestha/vim-lsp'
"
" let g:lsp_signs_enabled = 1
" let g:lsp_signs_error = {'text': '▶'}
" let g:lsp_signs_warning = {'text': '▶'}
" let g:lsp_signs_information = {'text': '◆'}
" let g:lsp_signs_hint = {'text': '◆'}
" let g:lsp_diagnostics_echo_cursor = 1
" let g:lsp_diagnostics_echo_delay = 0
" nnoremap \l :cclose<CR>:LspDocumentDiagnostics<cr>
" nnoremap \h :LspHover<cr>
" nnoremap \d :LspDefinition<cr>
" nnoremap \r :LspReferences<cr>
" nnoremap \n :LspRename<cr>
" nnoremap \s :LspDocumentSymbol<cr>
" nnoremap \w :LspWorkspaceSymbol<cr>
" nnoremap \ff :LspDocumentFormat<cr>
" nnoremap \fr :LspDocumentRangeFormat<cr>
" augroup User lsp_setup
" autocmd!
" if executable('vls') "{{{
" autocmd User lsp_setup call lsp#register_server({
" \ 'name': 'vue',
" \ 'cmd': {server_info->['vls']},
" \ 'whitelist': ['vue'],
" \ })
" endif
" "}}}
" if executable('pyls') "{{{
" autocmd User lsp_setup call lsp#register_server({
" \ 'name': 'pyls',
" \ 'cmd': {server_info->['pyls']},
" \ 'whitelist': ['python'],
" \ })
" endif
" "}}}
" if executable('typescript-language-server') "{{{
" au User lsp_setup call lsp#register_server({
" \ 'name': 'typescript-language-server',
" \ 'cmd': { server_info->[&shell, &shellcmdflag, 'typescript-language-server --stdio']},
" \ 'root_uri': { server_info->lsp#utils#path_to_uri(lsp#utils#find_nearest_parent_directory(lsp#utils#get_buffer_path(), '.git/..'))},
" \ 'whitelist': ['typescript', 'javascript', 'javascript.jsx']
" \ })
" endif
" "}}}
" augroup END
2018-11-04 16:15:18 +00:00
2018-11-18 22:07:16 +00:00
""}}}
2018-11-23 21:45:55 +00:00
" #vim-SyntaxRange{{{
" https://github.com/inkarkat/vim-SyntaxRange
2018-11-25 11:12:14 +00:00
" Plug 'inkarkat/vim-SyntaxRange'
" command! HiJinja call SyntaxRange#Include('{{', '}}', 'jinja', 'jinjaBraces', 'jinjaVariable')
2018-11-24 22:36:49 +00:00
" command! HiJinja call SyntaxRange#IncludeEx('start=/{{-\?/hs=s+2 end=/-\?}}/he=s-1', 'jinja')
2018-11-23 21:45:55 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #vim-vue {{{
2018-11-18 22:07:16 +00:00
" https://github.com/posva/vim-vue
Plug 'posva/vim-vue'
" disable preprocessor checking for vue files - increases speed
let g:vue_disable_pre_processors=0
" set custom syntax highlighting
augroup fixhighlighting
autocmd!
autocmd BufNewFile,BufRead *.vue syntax sync fromstart
augroup END
2018-11-17 20:22:58 +00:00
2018-11-20 09:47:07 +00:00
" #vim-yaml
2018-11-18 22:07:16 +00:00
" https://github.com/stephpy/vim-yaml
Plug 'stephpy/vim-yaml'
2018-11-17 20:22:58 +00:00
2018-11-20 09:47:07 +00:00
" #python-syntax
2018-11-18 22:07:16 +00:00
" https://github.com/vim-python/python-syntax
Plug 'vim-python/python-syntax'
let g:python_highlight_all = 1
2018-11-04 16:15:18 +00:00
2018-11-18 22:07:16 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #vimwiki {{{
2018-11-18 22:07:16 +00:00
" https://github.com/vimwiki/vimwiki
Plug 'vimwiki/vimwiki'
let g:vimwiki_list = [{'path': '~/vimwiki/', 'path_html': '~/vimwiki_html/'}]
2018-11-04 16:15:18 +00:00
2018-11-18 22:07:16 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #wordpress.vim{{{
2018-11-18 22:07:16 +00:00
" doesn't support universal ctags
2018-11-20 09:47:07 +00:00
" #Plug 'dsawardekar/wordpress.vim'
2018-11-18 22:07:16 +00:00
" This fork does:
" https://github.com/DArcMattr/wordpress.vim/tree/universal-ctags
" Using studio-vx fork
Plug 'studio-vx/wordpress.vim', { 'branch': 'universal-ctags' }
2018-11-17 20:22:58 +00:00
2018-11-18 22:07:16 +00:00
"}}}
2018-11-20 09:47:07 +00:00
" #vim-git{{{
2018-11-18 22:07:16 +00:00
" https://github.com/tpope/vim-git
Plug 'tpope/vim-git'
2018-11-17 20:22:58 +00:00
2018-11-18 22:07:16 +00:00
"}}}
2018-12-02 21:31:01 +00:00
endif
2018-11-18 22:07:16 +00:00
call plug#end()
endif
2018-11-04 16:15:18 +00:00
runtime macros/matchit.vim
2018-11-05 20:12:38 +00:00
"----------------------------------------------------------------------------}}}
2018-09-25 13:54:09 +00:00
" #functions {{{
2018-11-01 09:56:40 +00:00
2018-09-25 13:54:09 +00:00
function! SetColor(name, fg, bg, fg_l, bg_l, style) abort"{{{
if &background ==? 'dark'
if a:fg ==? 'normal'
let l:guifg = ' guifg=' . g:d_normal_fg
let l:ctermfg = 'ctermfg=black'
" let l:termfg = 'termfg=black'
elseif a:fg ==? 'none'
let l:guifg = ' guifg=' . g:d_normal_bg
let l:ctermfg = ' ctermfg=white'
" let l:termfg = ' termfg=white'
elseif a:fg ==? ''
let l:guifg = ''
let l:ctermfg = ''
" let l:termfg = ''
else
let l:guifg = ' guifg=' . a:fg
let l:ctermfg = ' ctermfg=black'
" let l:termfg = ' termfg=black'
endif
if a:bg ==? 'none'
let l:guibg = ' guibg=NONE'
let l:ctermbg = ' ctermbg=none'
" let l:termbg = ' termbg=none'
elseif a:bg ==? ''
let l:guibg = ''
let l:ctermbg = ''
" let l:termbg = ''
else
let l:guibg = ' guibg=' . a:bg
let l:ctermbg = ' ctermbg=black'
endif
else " light background
if a:fg_l ==? 'normal'
let l:guifg = ' guifg=' . g:l_normal_fg
let l:ctermfg = ' ctermfg=black'
" let l:termfg = ' termfg=black'
elseif a:fg_l ==? 'none'
let l:guifg = ' guifg=' . g:l_normal_bg
let l:ctermfg = ' ctermfg=white'
" let l:termfg = ' termfg=white'
elseif a:fg_l ==? ''
let l:guifg = ''
let l:ctermfg = ''
let l:termfg = ''
else
let l:guifg = ' guifg=' . a:fg_l
let l:ctermfg = ' ctermfg=black'
" let l:termfg = ' termfg=black'
endif
if a:bg_l ==? 'none'
let l:guibg = ' guibg=NONE'
let l:ctermbg = ' ctermbg=none'
" let l:termbg = ' termbg=none'
elseif a:bg_l ==? ''
let l:guibg = ''
let l:ctermbg = ''
" let l:termbg = ''
else
let l:guibg = ' guibg=' . a:bg_l
let l:ctermbg = ' ctermbg=white'
" let l:termbg = ' termbg=white'
endif
endif
if a:style ==? ''
let l:style = ' term=none cterm=none gui=NONE'
else
let l:style = ' term=' . a:style . ' cterm=' . a:style . ' gui=' . a:style
endif
let l:histring = 'hi! ' . a:name . l:guifg . l:guibg . l:style
let l:histring .= l:ctermfg . l:ctermbg
" let l:histring .= l:termfg . l:termbg
execute 'hi clear ' . a:name
execute l:histring
2018-11-05 20:12:38 +00:00
endfunction
2018-09-25 13:54:09 +00:00
2018-11-05 20:12:38 +00:00
"}}}
2018-09-25 13:54:09 +00:00
function! GetStatusFrag(condition, colorname, conditionprefix, text) abort "{{{
" TODO better name
let l:frag='%#' . a:colorname . '#'
let l:frag.=a:conditionprefix
let l:frag.='%{(' . a:condition . ")?'" . a:text . "':''}"
return l:frag
2018-11-05 20:12:38 +00:00
endfunction
2018-09-25 13:54:09 +00:00
2018-11-05 20:12:38 +00:00
"}}}
2018-09-25 14:24:27 +00:00
function! MyFoldText() "{{{
2018-10-04 18:33:32 +00:00
if !exists('g:foldtext_column')
let g:foldtext_column = 80 " column to right align foldtext with
endif
if !exists('b:foldtext_column')
let b:foldtext_column = g:foldtext_column " column to right align foldtext with
endif
if !exists('g:foldtext_maxcolumn')
let g:foldtext_maxcolumn = 120
endif
2018-09-25 13:54:09 +00:00
2018-10-10 08:31:33 +00:00
let l:linecount = v:foldend - v:foldstart
2018-09-25 15:30:12 +00:00
" don't display foldmarker braces
2018-11-04 17:48:13 +00:00
" put one of the braces in brackets so vim doesn't treat
" it as an actual fold marker
let l:line = substitute(getline(v:foldstart), '"\?{\({\){', '', '')
2018-09-25 15:30:12 +00:00
" don't display vim comment quotation marks
2018-12-03 23:44:36 +00:00
" TODO other comment markers
2018-10-04 18:33:32 +00:00
let l:line = substitute(l:line, "\^\"\\s\\?", '', '')
2018-09-25 13:54:09 +00:00
2018-11-17 16:44:28 +00:00
" let l:postfix = l:linecount . ' ' . substitute(v:folddashes, '-', '•', 'g')
let l:postfix = l:linecount . ' ' . substitute(v:folddashes, '-', '↓', 'g')
2018-10-14 12:21:10 +00:00
while strchars(l:postfix) < 7
2018-09-25 13:54:09 +00:00
let l:postfix = ' ' . l:postfix
endwhile
2018-11-17 16:44:28 +00:00
" let l:postfix = ' ↓ ' . l:postfix
2018-09-25 13:54:09 +00:00
let l:len_line = len(l:line)
2018-09-25 15:30:12 +00:00
let l:len_postfix = strchars(l:postfix)
2018-09-25 13:54:09 +00:00
2018-10-04 18:33:32 +00:00
if l:len_line + l:len_postfix <= b:foldtext_column
let l:padding = ' '[l:len_line + l:len_postfix + 0:b:foldtext_column - 1]
2018-09-25 13:54:09 +00:00
let l:foldtext = l:line . l:padding . l:postfix
else
2018-10-10 08:59:22 +00:00
let l:sniptext = ' ⋯'
2018-10-04 18:33:32 +00:00
let l:foldtext = l:line[:b:foldtext_column - 1 - strchars(l:sniptext) - l:len_postfix] . l:sniptext . l:postfix
2018-09-25 13:54:09 +00:00
endif
return l:foldtext
2018-11-05 20:12:38 +00:00
endfunction
2018-09-25 13:54:09 +00:00
2018-11-05 20:12:38 +00:00
"}}}
2018-10-04 18:33:32 +00:00
function! IndentFoldTextColumn(amount) abort "{{{
if !exists('g:foldtext_column')
" column to right align foldtext with
let g:foldtext_column = 80
endif
if !exists('b:foldtext_column')
" column to right align foldtext with
let b:foldtext_column = g:foldtext_column
endif
if a:amount == 0
let b:foldtext_column = g:foldtext_column
return
endif
let l:newcolumn = b:foldtext_column + a:amount
if l:newcolumn < 20
let l:newcolumn = 20
elseif l:newcolumn > g:foldtext_maxcolumn
let l:newcolumn = g:foldtext_maxcolumn
endif
let b:foldtext_column = l:newcolumn
endfunction
nnoremap <space>z, :<C-U>call IndentFoldTextColumn(-5 * (v:count == 0 ? 1 : v:count))<CR>
nnoremap <space>z. :<C-U>call IndentFoldTextColumn(5 * (v:count == 0 ? 1 : v:count))<CR>
nnoremap <space>z= :call IndentFoldTextColumn(0)<CR>
2018-11-05 20:12:38 +00:00
"}}}
2018-11-23 20:25:08 +00:00
function! <SID>SynStack()"{{{
if !exists('*synstack')
return
endif
2018-11-23 21:45:55 +00:00
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val,"name")') '-> ' . synIDattr(synIDtrans(synID(line('.'),col('.'),1)), 'name' )
2018-11-23 20:25:08 +00:00
endfunc
nmap <space>pp :call <SID>SynStack()<CR>
2018-11-05 20:12:38 +00:00
"}}}
2018-10-04 18:33:32 +00:00
function! s:Get_env() abort "{{{
2018-09-25 13:54:09 +00:00
" devdocs DD
" https://gist.github.com/romainl/8d3b73428b4366f75a19be2dad2f0987#file-devdocs-vim
if has('win64') || has('win32') || has('win16')
return 'WINDOWS'
else
return toupper(substitute(system('uname'), '\n', '', ''))
endif
endfunction
" What command to use on what system
let s:cmds = {'DARWIN': 'open', 'LINUX': 'qutebrowser', 'WINDOWS': 'start'}
" Build the URL stub
let s:stub = s:cmds[<SID>Get_env()] . " 'http://devdocs.io/?q="
command! -nargs=* DD silent! call system(len(split(<q-args>, ' ')) == 0 ?
\ s:stub . &ft . ' ' . expand('<cword>') . "'" : len(split(<q-args>, ' ')) == 1 ?
\ s:stub . &ft . ' ' . <q-args> . "'" : s:stub . <q-args> . "'")
2018-11-05 20:12:38 +00:00
"}}}
2018-09-25 13:54:09 +00:00
if !exists('*RangerExplorer') "{{{
2018-10-04 18:33:32 +00:00
" use ranger as file manager
function RangerExplorer() abort
exec 'silent !ranger --choosefile=/tmp/vim_ranger_current_file ' . expand('%:p:h')
if filereadable('/tmp/vim_ranger_current_file')
exec 'edit ' . system('cat /tmp/vim_ranger_current_file')
call system('rm /tmp/vim_ranger_current_file')
endif
redraw!
endfun
map <space>ra :call RangerExplorer()<CR>
2018-09-25 13:54:09 +00:00
endif
2018-11-05 20:12:38 +00:00
"}}}
2018-09-25 13:54:09 +00:00
function! SetColorColumn() abort"{{{
if &buftype == ''
2018-10-04 18:33:32 +00:00
setlocal colorcolumn=80,120
2018-09-25 13:54:09 +00:00
endif
endfunction
2018-11-05 20:12:38 +00:00
"}}}
2018-09-25 13:54:09 +00:00
function! GetLinterStatus(key) abort "{{{
let l:statuscount = 0
if exists('b:ale_linted')
let l:linter = ale#statusline#Count(bufnr(''))
else
let l:linter = GetDiagnosticCountsFromSigns(bufnr(''))
endif
if has_key(l:linter, a:key)
let l:statuscount = l:linter[a:key]
endif
2018-11-01 17:57:43 +00:00
return l:statuscount
2018-09-25 13:54:09 +00:00
endfunction
2018-11-05 20:12:38 +00:00
"}}}
2018-10-04 18:33:32 +00:00
function! s:RunShellCommand(cmdline) abort"{{{
2018-09-25 13:54:09 +00:00
" Shell command
" http://vim.wikia.com/wiki/VimTip1599
2018-11-23 11:14:42 +00:00
let l:expanded_cmdline = a:cmdline
2018-09-25 13:54:09 +00:00
for l:part in split(a:cmdline, ' ')
if l:part[0] =~ '\v[%#<]'
let l:expanded_part = fnameescape(expand(l:part))
let l:expanded_cmdline = substitute(l:expanded_cmdline, l:part, l:expanded_part, '')
endif
endfor
if g:shell_scratch_buffer_nr > -1
let l:win_nr = bufwinnr(g:shell_scratch_buffer_nr)
if l:win_nr < 0
execute 'bdelete' g:shell_scratch_buffer_nr
top new
let g:shell_scratch_buffer_nr = bufnr('%')
else
execute l:win_nr. ' wincmd w'
setlocal modifiable
%delete _
endif
else
top new
let g:shell_scratch_buffer_nr = bufnr('%')
endif
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
2018-11-23 11:14:42 +00:00
nnoremap <buffer> q :bdelete<CR>
2018-09-25 13:54:09 +00:00
augroup ResetShellBufferNr
autocmd! * <buffer>
autocmd BufUnload <buffer> let g:shell_scratch_buffer_nr = -1
augroup END
" call setline(1, 'You entered: ' . a:cmdline)
" call setline(2, 'Expanded Form: ' .l:expanded_cmdline)
" call setline(3,substitute(getline(2),'.','=','g'))
execute '$read !'. l:expanded_cmdline
1
setlocal nomodifiable
if !exists('b:shell_line_count')
let b:shell_line_count = line('$')
if b:shell_line_count > 25
let b:shell_line_count = 20
endif
execute 'resize' b:shell_line_count + 1
endif
wincmd p
endfunction
command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)
let g:shell_scratch_buffer_nr = -1
2018-11-05 20:12:38 +00:00
"}}}
2018-09-25 13:54:09 +00:00
function! GetDiagnosticCountsFromSigns(buffer) abort "{{{
let l:error = 0
let l:warn = 0
let l:info = 0
let l:hint = 0
redir => l:result
silent exec 'sign place buffer=' . a:buffer
redir end
let l:lines = split(l:result, '\n')
for l:line in l:lines
if l:line =~? 'Error'
let l:error += 1
endif
if l:line =~? 'Warning'
let l:warn += 1
endif
if l:line =~? 'Info'
let l:info += 1
endif
if l:line =~? 'Hint'
let l:hint += 1
endif
endfor
return {'error': l:error, 'warning': l:warn, 'info': l:info, 'hint': l:hint}
endfunction
2018-11-05 20:12:38 +00:00
"}}}
2018-10-04 18:33:32 +00:00
function! SaveAndExecute(ex_command) abort "{{{
2018-09-25 13:54:09 +00:00
" https://stackoverflow.com/a/40195855
" ex_command: command to run to execute file
" SOURCE [reusable window]: https://github.com/fatih/vim-go/blob/master/autoload/go/ui.vim
" save and reload current file
2018-10-04 18:33:32 +00:00
silent execute 'update | edit'
2018-09-25 13:54:09 +00:00
" get file path of current file
2018-10-04 18:33:32 +00:00
let s:current_buffer_file_path = expand('%')
2018-09-25 13:54:09 +00:00
2018-10-04 18:33:32 +00:00
let s:output_buffer_name = 'Output'
let s:output_buffer_filetype = 'output'
2018-09-25 13:54:09 +00:00
" reuse existing buffer window if it exists otherwise create a new one
2018-10-04 18:33:32 +00:00
if !exists('c:buf_nr') || !bufexists(s:buf_nr) || bufwinnr(s:buf_nr) == -1
2018-09-25 13:54:09 +00:00
silent execute 'top new ' . s:output_buffer_name
let s:buf_nr = bufnr('%')
elseif bufwinnr(s:buf_nr) != bufwinnr('%')
silent execute bufwinnr(s:buf_nr) . 'wincmd w'
endif
2018-10-04 18:33:32 +00:00
silent execute 'setlocal filetype=' . s:output_buffer_filetype
2018-09-25 13:54:09 +00:00
setlocal bufhidden=delete
setlocal buftype=nofile
setlocal noswapfile
setlocal nobuflisted
setlocal winfixheight
setlocal cursorline " make it easy to distinguish
setlocal nonumber
setlocal norelativenumber
setlocal showbreak=""
nnoremap <silent> <buffer> q :bdelete!<CR>'.zz
" clear the buffer
setlocal noreadonly
" setlocal modifiable
%delete _
" add the console output
silent execute '.!'. a:ex_command . ' ' . shellescape(s:current_buffer_file_path, 1)
" resize window to content length
" Note: This is annoying because if you print a lot of lines then your code buffer is forced to a height of one line every time you run this function.
" However without this line the buffer starts off as a default size and if you resize the buffer then it keeps that custom size after repeated runs of this function.
" But if you close the output buffer then it returns to using the default size when its recreated
"execute 'resize' . line('$')
" make the buffer non modifiable
setlocal readonly
" setlocal nomodifiable
endfunction
2018-10-21 08:25:46 +00:00
2018-11-05 20:12:38 +00:00
"}}}
2018-11-01 09:56:40 +00:00
function! JsIncludeExpr(file)"{{{
2018-10-21 08:25:46 +00:00
" substitute(substitute(v:fname,'^[\\~@]\/','./',''),'^[\\~@]','./node_modules/','')
return substitute(substitute(a:file,'^[\\~@]\/','./',''),'^[\\~@]','./node_modules/','')
2018-11-05 20:12:38 +00:00
endfunction
2018-11-01 09:56:40 +00:00
2018-11-27 21:57:06 +00:00
"}}}
function! Redir(cmd) "{{{
for win in range(1, winnr('$'))
if getwinvar(win, 'scratch')
execute win . 'windo close'
endif
endfor
if a:cmd =~ '^!'
let output = system(matchstr(a:cmd, '^!\zs.*'))
else
redir => output
execute a:cmd
redir END
endif
vnew
let w:scratch = 1
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
call setline(1, split(output, "\n"))
endfunction
command! -nargs=1 -complete=command Redir silent call Redir(<q-args>)
" Usage:
" :Redir hi ............. show the full output of command ':hi' in a scratch window
" :Redir !ls -al ........ show the full output of command ':!ls -al' in a scratch window
2018-09-25 13:54:09 +00:00
"}}}
2019-01-16 23:08:30 +00:00
function Test() abort "{{{
let job = job_start('ls -lah', {'callback': 'Testcallback'})
endfunction
"}}}
function Testcallback(channel, msg) abort
echom a:channel . ': ' . a:msg
endfunction
"}}}
2018-11-05 20:12:38 +00:00
"----------------------------------------------------------------------------}}}
2018-11-17 20:22:58 +00:00
"#commands{{{
2018-11-21 14:28:03 +00:00
" TrimWhitespace{{{
2018-11-17 20:22:58 +00:00
command! -range=% TrimWhitespace let b:wv = winsaveview() |
\ keeppattern <line1>,<line2>s/\s\+$// |
\ call winrestview(b:wv)
2018-11-21 14:28:03 +00:00
"}}}
" Scratch, ScratchVertical{{{
2018-11-21 14:25:30 +00:00
command! Scratch new | setlocal buftype=nofile | setlocal bufhidden=hide | setlocal noswapfile
command! ScratchVertical vnew | setlocal buftype=nofile | setlocal bufhidden=hide | setlocal noswapfile
2018-11-21 14:28:03 +00:00
"}}}
2018-11-17 20:22:58 +00:00
"}}}
" #settings {{{
2018-09-25 13:54:09 +00:00
scriptencoding utf-8
syntax on
2018-11-01 09:56:40 +00:00
set fillchars=stl:\ ,stlnc:\ ,vert:┃
2018-09-25 13:54:09 +00:00
set guioptions-=mTrLb
set guioptions+=c
set updatetime=100
2018-10-17 06:58:24 +00:00
set timeoutlen=500
2018-11-01 21:53:04 +00:00
set lazyredraw
2018-09-25 13:54:09 +00:00
2018-12-02 21:31:01 +00:00
" the ;/home/ray tells vim to stop searching at /home/ray
set tags+=./.tags,.tags,./tags-py,.tags-py;/home/ray/
2018-09-25 13:54:09 +00:00
" persisitent undo file
set undofile
2018-10-10 08:31:33 +00:00
set viewoptions-=options
2018-09-25 13:54:09 +00:00
set ignorecase
set smartcase
set wildmenu
set wildmode=longest:full,full
2018-10-08 18:28:02 +00:00
set wildignore+=/node_modules/,dist/
2018-09-25 13:54:09 +00:00
2018-11-02 20:25:06 +00:00
" Use ag over grep
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor\ --ignore\ node_modules
endif
2018-09-25 13:54:09 +00:00
set hidden
set number relativenumber
set hlsearch
" set completeopt=menuone,preview
2019-02-09 22:15:36 +00:00
set completeopt=menuone
2018-09-25 13:54:09 +00:00
set nospell
set spelllang=en_gb
2018-11-25 19:32:05 +00:00
set diffopt+=vertical
2018-09-25 13:54:09 +00:00
set tabstop=8
set softtabstop=2
set shiftwidth=2
set shiftround
set expandtab
set autoindent
set textwidth=180
set formatoptions=cq
set wrapmargin=0
2018-11-01 09:56:40 +00:00
set cursorline
set foldcolumn=2
2018-12-12 09:09:04 +00:00
if has('patch-7-4-2201')
set signcolumn=yes
endif
2018-10-04 18:33:32 +00:00
set colorcolumn=80,120
2018-09-25 13:54:09 +00:00
set iskeyword+=-
set scrolloff=10
set showcmd
set incsearch
set laststatus=2
set shortmess=aoOT
2018-10-04 18:33:32 +00:00
set cmdheight=3
2018-09-25 13:54:09 +00:00
2018-12-03 23:44:36 +00:00
set foldmethod=manual
2018-09-25 13:54:09 +00:00
set showmode
set autoindent
set breakindent
2018-11-23 11:14:42 +00:00
set showbreak=\ \ ↳\
2018-09-25 13:54:09 +00:00
set mouse=a
set listchars=eol,tab:>-,trail:~,extends:>,precedes:<,space
set foldtext=MyFoldText()
2019-02-13 12:26:52 +00:00
set conceallevel=2
2019-02-18 20:52:37 +00:00
set concealcursor=
2018-11-05 20:12:38 +00:00
"----------------------------------------------------------------------------}}}
2018-09-25 13:54:09 +00:00
" #mappings {{{
let g:mapleader = ' '
2018-11-19 13:38:12 +00:00
" miscallaneous {{{
2018-11-15 21:25:44 +00:00
nnoremap 0 ^
2018-11-19 17:02:54 +00:00
nnoremap <silent><space>cs :let @/=""<cr>
2018-09-25 13:54:09 +00:00
nnoremap : :setlocal norelativenumber<CR>:
nnoremap <silent> <space>rc :so $MYVIMRC<CR>
2018-11-25 19:32:05 +00:00
nnoremap <silent> <space>nn :setlocal invrelativenumber<CR>
2018-09-25 13:54:09 +00:00
nnoremap <silent><expr> <space>nh (&hls && v:hlsearch ? ':nohls' : ':set hls')."\n"
nnoremap <silent> <space>sl :set invlist<CR>
nnoremap <space>aa A<left>
nnoremap <space>a2 A<left><left>
nnoremap <space>ab A<C-o>B
nnoremap <space>co :!clear;
2019-02-22 21:30:56 +00:00
nnoremap <space>;; A;
nnoremap <space>;j jA;
2018-09-25 13:54:09 +00:00
" Focus on current fold, close the rest
nnoremap <silent> <space>zz zMzvzt
" replace current word with last yanked/deleted text
nnoremap <silent> <space>rr "_diwP
" replace current word with last yanked text
nnoremap <silent> <space>ry diw"0P
" quick grep of visual selection
vnoremap <space>gr y:grep! -R <C-r>" .
" open quickfix window of TODOs
2019-01-18 17:50:29 +00:00
nnoremap <space>td :grep! -R 'TODO' .<CR>:botright cwindow<CR>:echo len(getqflist()) 'TODOs'<CR>
2018-09-25 13:54:09 +00:00
" devdocs mapping
nnoremap <space>dd :DD<CR>
" write and delete current buffer
nnoremap <space>bx :w\|bd<cr>
2018-11-19 13:38:12 +00:00
" sync highlighting from start
nnoremap <silent><space>ss :syntax sync fromstart<CR>
2018-09-25 13:54:09 +00:00
2018-11-12 12:29:32 +00:00
"}}}
2018-11-19 13:38:12 +00:00
" terminal{{{
2018-12-12 09:09:04 +00:00
if has('terminal')
tnoremap <Esc> <C-\><C-n>
endif
2018-09-25 13:54:09 +00:00
"}}}
2018-11-19 13:38:12 +00:00
" git mappings {{{
2018-11-25 19:32:05 +00:00
" also see vim-fugitive plugin section
2018-09-25 13:54:09 +00:00
nnoremap <space>gD :!clear; echo 'git diff'; git diff<CR>
nnoremap <space>ga :!clear; git add %; git status<CR>
nnoremap <space>gA :!clear; git add .; git status<CR>
nnoremap <space>gg :!clear; git add %; git commit -m ''<Left>
2018-11-25 22:00:51 +00:00
nnoremap <space>gP :!clear; echo 'git push'; git push<CR>
2018-09-25 13:54:09 +00:00
2018-11-05 20:12:38 +00:00
"}}}
2018-11-19 13:38:12 +00:00
" netrw {{{
2018-09-25 13:54:09 +00:00
nnoremap <space>ex :Ex<CR>
nnoremap <space>ee :e .<CR>
nnoremap <space>eq :Rex<CR>
2018-11-05 20:12:38 +00:00
"}}}
2018-11-27 21:57:06 +00:00
" movement/navigation{{{
2018-09-25 13:54:09 +00:00
nnoremap <Esc>j :resize -5<CR>
nnoremap <Esc>k :resize +5<CR>
nnoremap <Esc>l :vertical resize +5<CR>
nnoremap <Esc>h :vertical resize -5<CR>
nnoremap <PageUp> :bprevious<CR>
nnoremap <PageDown> :bnext<CR>
2018-11-27 21:57:06 +00:00
" alias for :tjump <cword>
nnoremap <space>tj g<C-]>
2018-12-02 21:31:01 +00:00
" alias for :ptjump <cword>
2018-11-27 21:57:06 +00:00
nnoremap <space>tp <C-w>g}
2018-09-25 13:54:09 +00:00
"}}}
2018-11-19 13:38:12 +00:00
" location list and quickfix mappings {{{
2018-09-25 13:54:09 +00:00
nnoremap <space>lo :botright lwindow<CR>
nnoremap <up> :lprev<CR>zv
nnoremap <down> :lnext<CR>zv
nnoremap <space>lc :lclose<CR>
nnoremap <space>lh :lhistory<CR>
nnoremap <space>lp :lolder<CR>
nnoremap <space>ln :lnewer<CR>
nnoremap <space>qo :botright cwindow<CR>
nnoremap <left> :cprev<CR>zv
nnoremap <right> :cnext<CR>zv
nnoremap <space>qc :cclose<CR>
nnoremap <space>qh :chistory<CR>
nnoremap <space>qp :colder<CR>
nnoremap <space>qn :cnewer<CR>
2018-11-05 20:12:38 +00:00
"}}}
2018-11-19 13:38:12 +00:00
" insert mode mappings {{{
2018-09-25 13:54:09 +00:00
inoremap jkrg <c-o>:reg<cr>
inoremap :w<cr> :w<cr>
inoremap [:w<cr> :w<cr>
inoremap {:w<cr> :w<cr>
2018-11-25 19:32:05 +00:00
" Chain multiple path completions with / key. Selects the first suggestion if
" no current selection. Use ctrl-y to finish completion as normal.
inoremap <expr> / pumvisible()
\ ? len(v:completed_item) ? '<C-Y><C-X><C-F>' : '<C-N><C-Y><C-X><C-F>'
\ : '/'
2018-09-25 13:54:09 +00:00
2018-11-05 20:12:38 +00:00
"}}}
2018-11-19 13:38:12 +00:00
" brace/quotes completion {{{
2019-02-22 21:43:35 +00:00
" inoremap {{ {}<left>
" inoremap {<CR> {<CR>}<C-o>O
" inoremap {; {<CR>};<C-o>O
" inoremap {, {<CR>},<C-o>O
" inoremap {{{ {{}}<Left><Left>
"
" inoremap (( ()<Left>
" inoremap (<CR> (<CR>)<C-o>O
" inoremap (; ();<Left><Left>
" inoremap (, (),<Left><Left>
"
" inoremap [[ []<Left>
" inoremap [<CR> [<CR>]<C-o>O
"
" inoremap "" ""<Left>
" inoremap """ ""
" inoremap "; "";<Left><Left>
" inoremap '' ''<Left>
" inoremap ''' ''
" inoremap '; '';<Left><Left>
" inoremap `` ``<left>
2018-09-25 13:54:09 +00:00
"}}}
2018-11-15 21:25:44 +00:00
"}}}
2018-11-19 13:38:12 +00:00
" working_with_underscores{{{
2018-11-15 21:25:44 +00:00
nnoremap <space>w f_l
nnoremap <space>b hT_
nnoremap <space>e lt_
onoremap u t_
onoremap U f_
2018-09-25 13:54:09 +00:00
"}}}
2018-11-05 20:12:38 +00:00
"----------------------------------------------------------------------------}}}
2018-09-25 13:54:09 +00:00
" #abbreviations {{{
2018-11-05 20:12:38 +00:00
" spelling"{{{
2018-09-25 13:54:09 +00:00
iabbrev adn and
iabbrev waht what
iabbrev tehn then
2018-09-25 14:28:49 +00:00
iabbrev functin function
iabbrev positin position
2018-10-04 18:33:32 +00:00
2018-11-05 20:12:38 +00:00
"}}}
" css{{{
2018-10-04 18:33:32 +00:00
iabbrev pabs; position: absolute;
iabbrev pfix; position: fixed;
iabbrev prel; position: relative;
2018-10-08 08:55:32 +00:00
iabbrev fdr; flex-direction: row;
iabbrev fdc; flex-direction: column;
iabbrev jcc; justify-content: center;
iabbrev aic; align-items: center;
2018-10-04 18:34:44 +00:00
iabbrev t0; top: 0;
iabbrev b0; bottom: 0;
iabbrev l0; left: 0;
iabbrev r0; right: 0;
2018-10-04 18:33:32 +00:00
iabbrev ct'' content-type: '';
2018-09-25 13:54:09 +00:00
"}}}
2018-11-05 20:12:38 +00:00
"----------------------------------------------------------------------------}}}
2018-09-25 13:54:09 +00:00
" #autocommands {{{
2018-12-02 22:33:19 +00:00
" persistent folds {{{
augroup AutoSaveFolds
autocmd!
" autocmd BufWinLeave ?* mkview
autocmd BufWrite ?* mkview
" autocmd BufWinEnter ?* silent loadview
autocmd BufRead ?* silent! loadview
augroup END
2018-09-25 13:54:09 +00:00
2018-12-02 22:33:19 +00:00
" }}}
" Show trailing whitepace and spaces before a tab: {{{
augroup whitespaceerrors
autocmd!
autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/ containedin=ALL
augroup END
2018-09-25 13:54:09 +00:00
2018-12-02 22:33:19 +00:00
" }}}
" automatically reload if color scheme file written {{{
" augroup coloreload
" autocmd!
" autocmd BufWritePost customred256.vim so $MYVIMRC
" augroup end
"
" }}}
" line numbering {{{
augroup linenumbering
autocmd!
autocmd InsertEnter * :set norelativenumber
autocmd InsertLeave * :set number relativenumber
autocmd WinEnter * :set number relativenumber
autocmd WinLeave * set norelativenumber
if exists('##CmdlineEnter')
2018-12-12 09:23:03 +00:00
autocmd CmdlineEnter * :redraw | :set norelativenumber
autocmd CmdlineLeave * :set number relativenumber
endif
2018-12-02 22:33:19 +00:00
augroup END
2018-09-25 13:54:09 +00:00
2018-12-02 22:33:19 +00:00
" }}}
" auto_window_settings {{{
if g:vimrc_auto_window_settings
augroup auto_window_settings
autocmd!
autocmd WinEnter * call SetColorColumn()
autocmd WinEnter * set cursorline | set cursorcolumn
2018-12-12 09:09:04 +00:00
if exists('##CmdLineEnter')
autocmd WinLeave * setlocal colorcolumn=0
autocmd WinLeave * set nocursorline | set nocursorcolumn
endif
2018-12-02 22:33:19 +00:00
augroup END
2018-09-25 13:54:09 +00:00
2018-12-02 22:33:19 +00:00
endif
" }}}
" Automatically reload .vimrc if changed {{{
augroup myvimrc
autocmd!
autocmd BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
augroup END
2018-09-25 13:54:09 +00:00
2018-12-02 22:33:19 +00:00
" }}}
" Open qfix after grepping {{{
" augroup qfixopen
" autocmd!
" autocmd QuickFixCmdPost *grep* botright cwindow
" augroup END
" }}}
" Open quickfix window{{{
augroup QuickFixAutoload
autocmd!
autocmd QuickFixCmdPost [^l]* nested botright cwindow
autocmd QuickFixCmdPost l* nested botright lwindow
augroup END
2018-11-01 09:56:40 +00:00
2018-12-02 22:33:19 +00:00
" }}}
2018-09-25 13:54:09 +00:00
2018-12-02 22:33:19 +00:00
"----------------------------------------------------------------------------}}}
" #statusline {{{
if g:vimrc_enable_statusline
set statusline=%!GetStatus(1)
2018-11-15 21:04:21 +00:00
2018-12-02 23:07:39 +00:00
augroup statusline "{{{
2018-11-15 21:04:21 +00:00
autocmd!
2018-12-02 22:33:19 +00:00
autocmd WinNew,WinEnter * setlocal statusline=%!GetStatus(1)
autocmd WinLeave * setlocal statusline=%!GetStatus(0)
2018-12-02 23:07:39 +00:00
autocmd Filetype qf setlocal statusline=%!GetStatus(1)
autocmd Filetype help setlocal statusline=%!GetStatus(1)
2018-12-02 22:33:19 +00:00
augroup END
2018-11-01 12:21:28 +00:00
"}}}
2018-12-02 22:33:19 +00:00
function! GetStatus(isactive) abort "{{{
" let l:linter = ale#statusline#Count(bufnr(''))
let l:divider = '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - >'
let l:separator = '%#StatusLineSeparator# '
let l:normal = '%#StatusLineNormal#'
let l:active = '%#StatusLineActive#'
let l:linterdash = '%#LinterDash#·'
let l:linterdashactive = '%#LinterDashActive#·'
let l:statusline = l:separator
"buffer number {{{
if a:isactive
let l:statusline .= '%#StatusLineBufferNrActive#'
else
let l:statusline .= '%#StatusLineBufferNr#'
endif
let l:statusline .= ' %n ' . l:separator
"}}}
2018-09-25 13:54:09 +00:00
2018-12-02 22:33:19 +00:00
" file percentage {{{
if a:isactive
let l:statusline .= '%#StatusLinePercentActive#'
let l:statusline .= ' %P %#StatusLineNoiseActive#of %#StatusLineLinecountActive#%L '
else
let l:statusline .= '%#StatusLinePercent#'
let l:statusline .= ' %P %#StatusLineNoise#of %#StatusLineLinecount#%L '
endif"}}}
2018-09-25 13:54:09 +00:00
2018-12-02 22:33:19 +00:00
" non-empty buftype (help, quickfix, etc) {{{
if a:isactive
let l:statusline .= l:active . "%{&buftype == '' ? '' : ' '}%q%h%w%#StatusLineActiveNoText#"
else
let l:statusline .= l:normal . "%{&buftype == '' ? '' : ' '}%q%h%w%#StatusLineNormalNoText#"
endif
let l:statusline .= "%{&buftype == '' ? '' : ' '}%s"
"}}}
2018-09-25 13:54:09 +00:00
2018-12-02 22:33:19 +00:00
" right/left divider {{{
let l:statusline.=l:separator
" modified version
let l:color = 'StatusLineDivMod' . (a:isactive?'Active':'')
let l:statusline .= GetStatusFrag("&modified && mode() != 'i'", l:color, '%<', l:divider)
2018-11-23 11:14:42 +00:00
2018-12-02 22:33:19 +00:00
" unmodified version
let l:color = 'StatusLineDiv' . (a:isactive?'Active':'')
let l:statusline .= GetStatusFrag("!&modified && mode() != 'i'", l:color, '%<', l:divider)
2018-11-23 11:14:42 +00:00
2018-12-02 22:33:19 +00:00
" input mode version
if a:isactive
let l:statusline .= GetStatusFrag("mode() == 'i'", 'StatusLineDivInput', '%<', l:divider)
endif
2018-09-25 13:54:09 +00:00
2018-12-02 22:33:19 +00:00
let l:statusline.= l:separator . '%*%='
"}}}
2018-09-25 13:54:09 +00:00
2018-12-02 22:33:19 +00:00
" file info{{{
if a:isactive == 1
" let l:statusline.=l:active
let l:statusline.='%#StatusLineFileInfo#'
" let l:statusline.=" %{strlen(&ft)?&ft:'none'} "
" let l:statusline.=l:separator . l:active
let l:statusline.='%{strlen(&fenc)?&fenc:&enc}'
" let l:statusline.=l:separator . l:active
let l:statusline.=' %{&fileformat}'
let l:statusline.="%{strlen(expand('%:e')) > 1?' ' . expand('%:e'):''}"
" let l:statusline.=l:separator . l:active
" let l:statusline.=' %{&spelllang} '
let l:statusline .= l:separator
endif
"}}}
2018-11-01 16:37:17 +00:00
2018-12-02 22:33:19 +00:00
" path/filename.extension {{{
if a:isactive
if &readonly
let l:statusline .= '%#StatusLineWarningActive# %r '
let l:statusline .= '%#StatusLineFileReadOnlyActive#'
" let l:statusline.='%#StatusLineDirActive# '
let l:statusline.="%{expand('%:p:h:t')}/"
" let l:statusline.='%#StatusLineFileActive#'
let l:statusline.="%{expand('%:t:r')}"
" let l:statusline.='%#StatusLineDotActive#'
let l:statusline.="%{strlen(expand('%:e'))?'.':''}"
" let l:statusline.='%#StatusLineExtActive#'
let l:statusline.="%{expand('%:e')} "
else
let l:statusline.='%#StatusLineDirActive# '
let l:statusline.="%{expand('%:p:h:t')}/"
let l:statusline.='%#StatusLineFileActive#'
2018-11-01 16:37:17 +00:00
2018-12-02 22:33:19 +00:00
let l:statusline.="%{expand('%:t:r')}"
let l:statusline.='%#StatusLineDotActive#'
let l:statusline.="%{strlen(expand('%:e'))?'.':''}"
let l:statusline.='%#StatusLineExtActive#'
let l:statusline.="%{expand('%:e')} "
endif
2018-11-01 16:37:17 +00:00
else
2018-12-02 22:33:19 +00:00
let l:statusline .= ' %#StatusLineWarning#%r'
let l:statusline.='%#StatusLineDir# '
let l:statusline.="%{fnamemodify(expand('%:p:h'),':~')}/"
let l:statusline.='%#StatusLineFile#'
2018-09-25 13:54:09 +00:00
2018-11-01 16:37:17 +00:00
let l:statusline.="%{expand('%:t:r')}"
2018-09-25 13:54:09 +00:00
2018-12-02 22:33:19 +00:00
let l:statusline.='%#StatusLineDot#'
2018-11-01 16:37:17 +00:00
let l:statusline.="%{strlen(expand('%:e'))?'.':''}"
2018-12-02 22:33:19 +00:00
let l:statusline.='%#StatusLineExt#'
let l:statusline.="%{strlen(expand('%:e'))?expand('%:e'):expand('%:e')} "
endif
"}}}
let l:statusline.='%*' . l:separator
" linter status {{{
if a:isactive
" errors
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('error') == 0?'-':'')}"
let l:statusline .= "%#LinterErrorActive#%{(GetLinterStatus('error') == 0?'':GetLinterStatus('error'))}"
" style errors
let l:statusline .= l:linterdashactive
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('style_error') == 0?'-':'')}"
let l:statusline .= "%#LinterErrorStyleActive#%{(GetLinterStatus('style_error') == 0?'':GetLinterStatus('style_error'))} "
" warnings
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('warning') == 0?'-':'')}"
let l:statusline .= "%#LinterWarningActive#%{(GetLinterStatus('warning') == 0?'':GetLinterStatus('warning'))}"
" style warnings
let l:statusline .= l:linterdashactive
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('style_warning') == 0?'-':'')}"
let l:statusline .= "%#LinterWarningStyleActive#%{(GetLinterStatus('style_warning') == 0?'':GetLinterStatus('style_warning'))} "
" info
let l:statusline .= "%#LinterDashActive#%{(GetLinterStatus('info') == 0?'-':'')}"
let l:statusline .= "%#LinterInfoActive#%{(GetLinterStatus('info') == 0?'':GetLinterStatus('info'))}"
else
" errors
let l:statusline .= "%#LinterDash#%{(GetLinterStatus('error') == 0?'-':'')}"
let l:statusline .= "%#LinterError#%{(GetLinterStatus('error') == 0?'':GetLinterStatus('error'))}"
" style errors
let l:statusline .= l:linterdash
let l:statusline .= "%{(GetLinterStatus('style_error') == 0?'-':'')}"
let l:statusline .= "%#LinterErrorStyle#%{(GetLinterStatus('style_error') == 0?'':GetLinterStatus('style_error'))} "
" warnings
let l:statusline .= "%#LinterDash#%{(GetLinterStatus('warning') == 0?'-':'')}"
let l:statusline .= "%#LinterWarning#%{(GetLinterStatus('warning') == 0?'':GetLinterStatus('warning'))}"
" style warnings
let l:statusline .= l:linterdash
let l:statusline .= "%{(GetLinterStatus('style_warning') == 0?'-':'')}"
let l:statusline .= "%#LinterWarningStyle#%{(GetLinterStatus('style_warning') == 0?'':GetLinterStatus('style_warning'))} "
" info
let l:statusline .= "%#LinterInfo#%{GetLinterStatus('info') == 0 ? '-' : GetLinterStatus('info')}"
2018-11-01 16:37:17 +00:00
endif
2018-09-25 13:54:09 +00:00
"}}}
2018-12-02 22:33:19 +00:00
let l:statusline .= ' ' . l:separator
2018-09-25 13:54:09 +00:00
2018-12-02 22:33:19 +00:00
if exists('gutentags#statusline')
let l:statusline .= '%#StatusLineWarning#%{gutentags#statusline("", "", "☢")}'
endif
2018-11-25 22:00:51 +00:00
2018-12-02 22:33:19 +00:00
return l:statusline
2018-09-25 13:54:09 +00:00
2018-12-02 22:33:19 +00:00
endfunction
"}}}
2018-09-25 13:54:09 +00:00
2018-12-02 22:33:19 +00:00
" highlight groups {{{
hi def link StatusLineSeparator Ignore
hi def link StatusLineNormal StatusLineNC
hi def link StatusLineActive StatusLine
hi def link StatusLineNormalNoText TabLineFill
hi def link StatusLineActiveNoText TabLineFill
hi def link StatusLineNoise StatusLineNormal
hi def link StatusLineNoiseActive StatusLineNormal
hi def link StatusLineBufferNr StatusLineNormal
hi def link StatusLineBufferNrActive StatusLineActive
hi def link StatusLinePercent StatusLineNormal
hi def link StatusLinePercentActive StatusLineActive
hi def link StatusLineLinecount StatusLinePercent
hi def link StatusLineLinecountActive StatusLinePercentActive
hi DivActive ctermbg=darkgray ctermfg=darkgray guibg=#666666 guifg=#666666
hi DivMod ctermbg=darkred ctermfg=darkred guibg=#660000 guifg=#660000
hi DivModActive ctermbg=red ctermfg=red guibg=#aa0000 guifg=#aa0000
hi DivInput ctermbg=darkblue ctermfg=darkblue guibg=#000022 guifg=#000022
hi def link StatusLineDiv TabLineFill
hi def link StatusLineDivActive DivActive
hi def link StatusLineDivMod DivMod
hi def link StatusLineDivModActive DivModActive
hi def link StatusLineDivInput DivInput
hi def link StatusLineFileInfo StatusLineActive
hi def link StatusLineFile StatusLineNormal
hi def link StatusLineFileActive StatusLineActive
hi def link StatusLineDir StatusLineFile
hi def link StatusLineDirActive StatusLineFileActive
hi def link StatusLineDot StatusLineDir
hi def link StatusLineDotActive StatusLineDirActive
hi def link StatusLineExt StatusLineDir
hi def link StatusLineExtActive StatusLineDirActive
hi def link StatusLineFileReadOnlyActive WarningMsg
hi def link StatusLineWarning StatusLineNormal
hi def link StatusLineWarningActive WarningMsg
hi def link LinterDash Normal
hi def link LinterDashActive Normal
hi def link LinterError Normal
hi def link LinterErrorActive ErrorMsg
hi def link LinterErrorStyle Normal
hi def link LinterErrorStyleActive SpellBad
hi def link LinterWarning Normal
hi def link LinterWarningActive SpellCap
hi def link LinterWarningStyle Normal
hi def link LinterWarningStyleActive LinterWarningActive
hi def link LinterInfo Normal
hi def link LinterInfoActive SpellRare
"}}}
2018-11-01 12:21:28 +00:00
2018-12-02 23:07:39 +00:00
else
set statusline=\
set statusline+=[%n]\ \
set statusline+=%p\ of\ %L
set statusline+=%=
set statusline+=%y\
set statusline+=%r\ %m\ %F
set statusline+=\
2018-12-02 22:33:19 +00:00
endif
2018-09-25 13:54:09 +00:00
2018-11-05 20:12:38 +00:00
"----------------------------------------------------------------------------}}}
2018-09-25 13:54:09 +00:00
" #tabline {{{
2018-12-02 22:33:19 +00:00
if exists('+showtabline') && g:vimrc_enable_tabline
2018-09-25 13:54:09 +00:00
" Rename tabs to show tab number.
" based on:
" http://stackoverflow.com/questions/5927952/whats-implementation-of-vims-default-tabline-function
function! MyTabLine() "{{{
let l:customtabline = ''
let l:currenttabnum = tabpagenr()
let l:lasttabnumber = tabpagenr('$')
let l:tabnumber = 1
while l:tabnumber <= l:lasttabnumber
let l:buflist = tabpagebuflist(l:tabnumber)
let l:winnr = tabpagewinnr(l:tabnumber)
if l:lasttabnumber > 1
let l:customtabline .= '%' . l:tabnumber . 'T'
let l:customtabline .= (l:tabnumber == l:currenttabnum ? '%1*' : '%2*')
2018-11-01 09:56:40 +00:00
let l:customtabline .= (l:tabnumber == l:currenttabnum ? '%#TabLineNumSel#' : '%#TabLineNum#')
let l:customtabline .= ' ' . l:tabnumber . ' '
2018-09-25 13:54:09 +00:00
let l:customtabline .= (l:tabnumber == l:currenttabnum ? '%#TabLineItemSel#' : '%#TabLineItem#')
endif
let l:bufnr = l:buflist[l:winnr - 1]
let l:file = bufname(l:bufnr)
let l:buftype = getbufvar(l:bufnr, '&buftype')
if l:buftype ==# 'help'
let l:file = 'help:' . fnamemodify(l:file, ':t:r')
elseif l:buftype ==# 'quickfix'
let l:file = 'quickfix'
elseif l:buftype ==# 'nofile'
if l:file =~# '\/.'
let l:file = substitute(l:file, '.*\/\ze.', '', '')
endif
else
let l:file = fnamemodify(l:file, ':p:t')
endif
if l:file ==# ''
let l:file = "''"
endif
2018-11-01 09:56:40 +00:00
let l:customtabline .= l:file . ' '
2018-09-25 13:54:09 +00:00
let l:tabnumber = l:tabnumber + 1
endwhile
let l:customtabline .= '%T%#TabLineFill#%='
2018-11-25 22:00:51 +00:00
if exists('*gutentags#statusline')
let l:customtabline .= '%#TabLineItemSel# %{gutentags#statusline("[ ", " ☢ ] ")}'
endif
2018-11-15 21:04:21 +00:00
let l:customtabline .= '%#TabLineItem# %{getcwd()}% '
2018-11-25 22:00:51 +00:00
if exists('*fugitive#statusline')
2018-11-18 22:07:16 +00:00
let l:customtabline .= '%#TabLineItem# %{fugitive#statusline()}% '
endif
2018-11-25 22:00:51 +00:00
if exists('*ObsessionStatus')
2018-11-18 22:07:16 +00:00
let l:customtabline .= "%#TabLineItemSel# %{ObsessionStatus(fnamemodify(v:this_session,':t'),'---')} %*"
endif
2018-09-25 13:54:09 +00:00
return l:customtabline
endfunction
"}}}
set showtabline=2
set tabline=%!MyTabLine()
2018-11-01 09:56:40 +00:00
hi def link TabLineItem TabLine
hi def link TabLineItemSel TabLineSel
hi def link TabLineNum TabLine
hi def link TabLineNumSel TabLineSel
2018-12-02 22:33:19 +00:00
endif
2018-11-05 20:12:38 +00:00
"----------------------------------------------------------------------------}}}
2018-09-25 13:54:09 +00:00
2018-12-05 17:26:36 +00:00
runtime vimrc-overrides
2018-12-02 22:33:19 +00:00
"}}}
2018-11-04 16:15:18 +00:00
" vim: set foldmethod=marker: