diff --git a/vim/lightline.vim b/vim/lightline.vim new file mode 100644 index 0000000..0c8101e --- /dev/null +++ b/vim/lightline.vim @@ -0,0 +1,129 @@ +"" lightline +let g:lightline = { + \ 'colorscheme': 'solarized', + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ], ['ctrlpmark'] ], + \ 'right': [ [ 'syntastic', 'lineinfo' ], ['percent'], [ 'fileformat', 'fileencoding', 'filetype' ] ] + \ }, + \ 'component_function': { + \ 'fugitive': 'LightLineFugitive', + \ 'filename': 'LightLineFilename', + \ 'fileformat': 'LightLineFileformat', + \ 'filetype': 'LightLineFiletype', + \ 'fileencoding': 'LightLineFileencoding', + \ 'mode': 'LightLineMode', + \ 'ctrlpmark': 'CtrlPMark', + \ }, + \ 'component_expand': { + \ 'syntastic': 'SyntasticStatuslineFlag', + \ }, + \ 'component_type': { + \ 'syntastic': 'error', + \ }, + \ 'subseparator': { 'left': '|', 'right': '|' } + \ } + +function! LightLineModified() + return &ft =~ 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-' +endfunction + +function! LightLineReadonly() + return &ft !~? 'help' && &readonly ? 'RO' : '' +endfunction + +function! LightLineFilename() + let fname = expand('%:t') + return fname == 'ControlP' ? g:lightline.ctrlp_item : + \ fname == '__Tagbar__' ? g:lightline.fname : + \ fname =~ '__Gundo\|NERD_tree' ? '' : + \ &ft == 'vimfiler' ? vimfiler#get_status_string() : + \ &ft == 'unite' ? unite#get_status_string() : + \ &ft == 'vimshell' ? vimshell#get_status_string() : + \ ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') . + \ ('' != fname ? fname : '[No Name]') . + \ ('' != LightLineModified() ? ' ' . LightLineModified() : '') +endfunction + +function! LightLineFugitive() + try + if expand('%:t') !~? 'Tagbar\|Gundo\|NERD' && &ft !~? 'vimfiler' && exists('*fugitive#head') + let mark = '' " edit here for cool mark + let _ = fugitive#head() + return strlen(_) ? mark._ : '' + endif + catch + endtry + return '' +endfunction + +function! LightLineFileformat() + return winwidth(0) > 70 ? &fileformat : '' +endfunction + +function! LightLineFiletype() + return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : '' +endfunction + +function! LightLineFileencoding() + return winwidth(0) > 70 ? (strlen(&fenc) ? &fenc : &enc) : '' +endfunction + +function! LightLineMode() + let fname = expand('%:t') + return fname == '__Tagbar__' ? 'Tagbar' : + \ fname == 'ControlP' ? 'CtrlP' : + \ fname == '__Gundo__' ? 'Gundo' : + \ fname == '__Gundo_Preview__' ? 'Gundo Preview' : + \ fname =~ 'NERD_tree' ? 'NERDTree' : + \ &ft == 'unite' ? 'Unite' : + \ &ft == 'vimfiler' ? 'VimFiler' : + \ &ft == 'vimshell' ? 'VimShell' : + \ winwidth(0) > 60 ? lightline#mode() : '' +endfunction + +function! CtrlPMark() + if expand('%:t') =~ 'ControlP' + call lightline#link('iR'[g:lightline.ctrlp_regex]) + return lightline#concatenate([g:lightline.ctrlp_prev, g:lightline.ctrlp_item + \ , g:lightline.ctrlp_next], 0) + else + return '' + endif +endfunction + +let g:ctrlp_status_func = { + \ 'main': 'CtrlPStatusFunc_1', + \ 'prog': 'CtrlPStatusFunc_2', + \ } + +function! CtrlPStatusFunc_1(focus, byfname, regex, prev, item, next, marked) + let g:lightline.ctrlp_regex = a:regex + let g:lightline.ctrlp_prev = a:prev + let g:lightline.ctrlp_item = a:item + let g:lightline.ctrlp_next = a:next + return lightline#statusline(0) +endfunction + +function! CtrlPStatusFunc_2(str) + return lightline#statusline(0) +endfunction + +let g:tagbar_status_func = 'TagbarStatusFunc' + +function! TagbarStatusFunc(current, sort, fname, ...) abort + let g:lightline.fname = a:fname + return lightline#statusline(0) +endfunction + +augroup AutoSyntastic + autocmd! + autocmd BufWritePost *.c,*.cpp,*.js,*.py call s:syntastic() +augroup END +function! s:syntastic() + SyntasticCheck + call lightline#update() +endfunction + +let g:unite_force_overwrite_statusline = 0 +let g:vimfiler_force_overwrite_statusline = 0 +let g:vimshell_force_overwrite_statusline = 0 diff --git a/vimrc b/vimrc index 3bc463f..3449871 100644 --- a/vimrc +++ b/vimrc @@ -11,6 +11,7 @@ Plug 'L9' Plug 'unimpaired.vim' Plug 'surround.vim' Plug 'Align' +Plug 'Raimondi/delimitMate' Plug 'editorconfig/editorconfig-vim' @@ -45,22 +46,16 @@ Plug 'itchyny/lightline.vim' Plug 'chriskempson/base16-vim' -Plug 'Raimondi/delimitMate' +Plug 'pangloss/vim-javascript', { 'for': 'javascript' } +Plug 'marijnh/tern_for_vim', { 'do': 'npm install', 'for': 'javascript' } +Plug 'mtscout6/syntastic-local-eslint.vim', { 'for': 'javascript' } +Plug 'mxw/vim-jsx', { 'for': 'javascript.jsx' } -Plug 'pangloss/vim-javascript' -Plug 'marijnh/tern_for_vim', { 'do': 'npm install', 'for': 'javascript'} -Plug 'mustache/vim-mustache-handlebars' -Plug 'mtscout6/syntastic-local-eslint.vim' -"Plug 'mxw/vim-jsx' - -Plug 'suan/vim-instant-markdown' -Plug 'xuhdev/vim-latex-live-preview' +Plug 'suan/vim-instant-markdown', { 'for': 'markdown' } +Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' } call plug#end() -"" reload when vim config changes -autocmd! bufwritepost .vimrc source % - "" enable local .vimrc set exrc " Enable use of directory-specific .vimrc set secure " Only run autocommands owned by me @@ -89,9 +84,14 @@ let g:session_directory = "~/.vim/session" let g:session_autoload = "no" let g:session_autosave = "no" let g:session_command_aliases = 1 + "" Mouse set mouse=a +"" Use modeline overrides +set modeline +set modelines=10 + "" Visual settings syntax enable set cursorline @@ -112,10 +112,6 @@ if has("gui_running") set guioptions -=r endif -"" Use modeline overrides -set modeline -set modelines=10 - set title set titleold="Terminal" set titlestring=%F @@ -271,139 +267,14 @@ set undoreload=10000 let g:syntastic_javascript_checkers = ['eslint'] let g:syntastic_always_populate_loc_list = 1 -let g:syntastic_auto_loc_list = 0 +let g:syntastic_auto_loc_list = 0 let g:syntastic_check_on_open = 1 let g:syntastic_check_on_wq = 0 "" lightline -let g:lightline = { - \ 'colorscheme': 'solarized', - \ 'active': { - \ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ], ['ctrlpmark'] ], - \ 'right': [ [ 'syntastic', 'lineinfo' ], ['percent'], [ 'fileformat', 'fileencoding', 'filetype' ] ] - \ }, - \ 'component_function': { - \ 'fugitive': 'LightLineFugitive', - \ 'filename': 'LightLineFilename', - \ 'fileformat': 'LightLineFileformat', - \ 'filetype': 'LightLineFiletype', - \ 'fileencoding': 'LightLineFileencoding', - \ 'mode': 'LightLineMode', - \ 'ctrlpmark': 'CtrlPMark', - \ }, - \ 'component_expand': { - \ 'syntastic': 'SyntasticStatuslineFlag', - \ }, - \ 'component_type': { - \ 'syntastic': 'error', - \ }, - \ 'subseparator': { 'left': '|', 'right': '|' } - \ } - -function! LightLineModified() - return &ft =~ 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-' -endfunction - -function! LightLineReadonly() - return &ft !~? 'help' && &readonly ? 'RO' : '' -endfunction - -function! LightLineFilename() - let fname = expand('%:t') - return fname == 'ControlP' ? g:lightline.ctrlp_item : - \ fname == '__Tagbar__' ? g:lightline.fname : - \ fname =~ '__Gundo\|NERD_tree' ? '' : - \ &ft == 'vimfiler' ? vimfiler#get_status_string() : - \ &ft == 'unite' ? unite#get_status_string() : - \ &ft == 'vimshell' ? vimshell#get_status_string() : - \ ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') . - \ ('' != fname ? fname : '[No Name]') . - \ ('' != LightLineModified() ? ' ' . LightLineModified() : '') -endfunction - -function! LightLineFugitive() - try - if expand('%:t') !~? 'Tagbar\|Gundo\|NERD' && &ft !~? 'vimfiler' && exists('*fugitive#head') - let mark = '' " edit here for cool mark - let _ = fugitive#head() - return strlen(_) ? mark._ : '' - endif - catch - endtry - return '' -endfunction - -function! LightLineFileformat() - return winwidth(0) > 70 ? &fileformat : '' -endfunction - -function! LightLineFiletype() - return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : '' -endfunction - -function! LightLineFileencoding() - return winwidth(0) > 70 ? (strlen(&fenc) ? &fenc : &enc) : '' -endfunction - -function! LightLineMode() - let fname = expand('%:t') - return fname == '__Tagbar__' ? 'Tagbar' : - \ fname == 'ControlP' ? 'CtrlP' : - \ fname == '__Gundo__' ? 'Gundo' : - \ fname == '__Gundo_Preview__' ? 'Gundo Preview' : - \ fname =~ 'NERD_tree' ? 'NERDTree' : - \ &ft == 'unite' ? 'Unite' : - \ &ft == 'vimfiler' ? 'VimFiler' : - \ &ft == 'vimshell' ? 'VimShell' : - \ winwidth(0) > 60 ? lightline#mode() : '' -endfunction - -function! CtrlPMark() - if expand('%:t') =~ 'ControlP' - call lightline#link('iR'[g:lightline.ctrlp_regex]) - return lightline#concatenate([g:lightline.ctrlp_prev, g:lightline.ctrlp_item - \ , g:lightline.ctrlp_next], 0) - else - return '' - endif -endfunction - -let g:ctrlp_status_func = { - \ 'main': 'CtrlPStatusFunc_1', - \ 'prog': 'CtrlPStatusFunc_2', - \ } - -function! CtrlPStatusFunc_1(focus, byfname, regex, prev, item, next, marked) - let g:lightline.ctrlp_regex = a:regex - let g:lightline.ctrlp_prev = a:prev - let g:lightline.ctrlp_item = a:item - let g:lightline.ctrlp_next = a:next - return lightline#statusline(0) -endfunction - -function! CtrlPStatusFunc_2(str) - return lightline#statusline(0) -endfunction - -let g:tagbar_status_func = 'TagbarStatusFunc' - -function! TagbarStatusFunc(current, sort, fname, ...) abort - let g:lightline.fname = a:fname - return lightline#statusline(0) -endfunction - -augroup AutoSyntastic - autocmd! - autocmd BufWritePost *.c,*.cpp,*.js,*.py call s:syntastic() -augroup END -function! s:syntastic() - SyntasticCheck - call lightline#update() -endfunction - -let g:unite_force_overwrite_statusline = 0 -let g:vimfiler_force_overwrite_statusline = 0 -let g:vimshell_force_overwrite_statusline = 0 +if filereadable(expand("~/.vim/lightline.vim")) + source ~/.vim/lightline.vim +endif "" NERDTree configuration nmap n :NERDTreeToggle @@ -440,7 +311,7 @@ let g:UltiSnipsJumpForwardTrigger="" let g:tex_flavor = "latex" let g:livepreview_previewer = 'zathura' -" JSX +" JSX " let g:jsx_ext_required = 0 " Allow JSX in normal JS files " @@ -470,4 +341,7 @@ au FileType javascript map r :TernRename au BufRead,BufNewFile *.json set ft=json "" Mustache -au BufRead,BufNewFile *.template set filetype=html syntax=mustache +au BufRead,BufNewFile *.template set filetype=html.mustache syntax=mustache + +"" always open help in vertical split +au FileType help wincmd L