Mercurial > dotfiles
changeset 379:58410650ce36
Add lightline and remove old scratch. Customize Vim settings.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 25 Feb 2017 21:31:02 -0800 |
parents | 5ae26582454e |
children | 52ea57ca22e1 |
files | .hgsub .hgsubstate vim/bundle/scratch/plugin/scratch.vim vim/vimrc |
diffstat | 4 files changed, 81 insertions(+), 214 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgsub Sat Feb 25 21:22:12 2017 -0800 +++ b/.hgsub Sat Feb 25 21:31:02 2017 -0800 @@ -32,6 +32,7 @@ vim/bundle/python-pep8-indent = [git]https://github.com/hynek/vim-python-pep8-indent.git vim/bundle/ctrlp-py-matcher = [git]https://github.com/ludovicchabant/ctrlp-py-matcher.git vim/bundle/todo.txt = [git]https://github.com/freitass/todo.txt-vim.git +vim/bundle/lightline = [git]https://github.com/itchyny/lightline.vim.git vim/bundle/gutentags = https://bitbucket.org/ludovicchabant/vim-gutentags vim/bundle/lawrencium = https://bitbucket.org/ludovicchabant/vim-lawrencium
--- a/.hgsubstate Sat Feb 25 21:22:12 2017 -0800 +++ b/.hgsubstate Sat Feb 25 21:31:02 2017 -0800 @@ -26,6 +26,7 @@ 8a8f0ed97c1751d304cf5b7241f2fe27b0e61f81 vim/bundle/jinja c9169233d45ae2f0fefa0feb9ee816a87c6b05c8 vim/bundle/lawrencium 6e818d5614d5fc18d95a48c92b89e6db39f9e3d6 vim/bundle/less +a63a00d548fd20457a4f31d31fb9c8fe8a7ebc2a vim/bundle/lightline 1633535197ad9757ac7f107e03b4d08e7d45d03d vim/bundle/linediff 3c2215bfed1de1251927fbc94b2631ca27c2958f vim/bundle/markdown 281701021c5001332a862da80175bf585d24e2e8 vim/bundle/nerdtree
--- a/vim/bundle/scratch/plugin/scratch.vim Sat Feb 25 21:22:12 2017 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -" File: scratch.vim -" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com) -" Version: 1.0 -" Last Modified: June 3, 2003 -" -" Overview -" -------- -" You can use the scratch plugin to create a temporary scratch buffer to store -" and edit text that will be discarded when you quit/exit vim. The contents -" of the scratch buffer are not saved/stored in a file. -" -" Installation -" ------------ -" 1. Copy the scratch.vim plugin to the $HOME/.vim/plugin directory. Refer to -" the following Vim help topics for more information about Vim plugins: -" -" :help add-plugin -" :help add-global-plugin -" :help runtimepath -" -" 2. Restart Vim. -" -" Usage -" ----- -" You can use the following command to open/edit the scratch buffer: -" -" :Scratch -" -" To open the scratch buffer in a new split window, use the following command: -" -" :Sscratch -" -" When you close the scratch buffer window, the buffer will retain the -" contents. You can again edit the scratch buffer by openeing it using one of -" the above commands. There is no need to save the scatch buffer. -" -" When you quit/exit Vim, the contents of the scratch buffer will be lost. -" You will not be prompted to save the contents of the modified scratch -" buffer. -" -" You can have only one scratch buffer open in a single Vim instance. If the -" current buffer has unsaved modifications, then the scratch buffer will be -" opened in a new window -" -" ****************** Do not modify after this line ************************ -if exists('loaded_scratch') || &cp - finish -endif -let loaded_scratch=1 - -" Scratch buffer name -let ScratchBufferName = "__Scratch__" - -" ScratchBufferOpen -" Open the scratch buffer -function! s:ScratchBufferOpen(new_win) - let split_win = a:new_win - - " If the current buffer is modified then open the scratch buffer in a new - " window - if !split_win && &modified - let split_win = 1 - endif - - " Check whether the scratch buffer is already created - let scr_bufnum = bufnr(g:ScratchBufferName) - if scr_bufnum == -1 - " open a new scratch buffer - if split_win - exe "new " . g:ScratchBufferName - else - exe "edit " . g:ScratchBufferName - endif - else - " Scratch buffer is already created. Check whether it is open - " in one of the windows - let scr_winnum = bufwinnr(scr_bufnum) - if scr_winnum != -1 - " Jump to the window which has the scratch buffer if we are not - " already in that window - if winnr() != scr_winnum - exe scr_winnum . "wincmd w" - endif - else - " Create a new scratch buffer - if split_win - exe "split +buffer" . scr_bufnum - else - exe "buffer " . scr_bufnum - endif - endif - endif -endfunction - -" ScratchMarkBuffer -" Mark a buffer as scratch -function! s:ScratchMarkBuffer() - setlocal buftype=nofile - setlocal bufhidden=hide - setlocal noswapfile - setlocal buflisted -endfunction - -autocmd BufNewFile __Scratch__ call s:ScratchMarkBuffer() - -" Command to edit the scratch buffer in the current window -command! -nargs=0 Scratch call s:ScratchBufferOpen(0) -" Command to open the scratch buffer in a new split window -command! -nargs=0 Sscratch call s:ScratchBufferOpen(1) -
--- a/vim/vimrc Sat Feb 25 21:22:12 2017 -0800 +++ b/vim/vimrc Sat Feb 25 21:31:02 2017 -0800 @@ -359,18 +359,81 @@ " }}} +" Lightline {{{ +let g:lightline = { + \'colorscheme': 'solarized', + \'active': { + \ 'left': [ ['mode', 'paste'], + \ ['fugitive', 'lawrencium', 'readonly', 'filename'], + \ ['ctrlpmark'] ], + \ 'right': [ ['lineinfo'], + \ ['percent'], + \ ['fileformat', 'fileencoding', 'filetype'], + \ ['gutentags', 'syntastic', 'ycm_errs', 'ycm_warns'] ] + \ }, + \'component_function': { + \ 'fugitive': '_LightlineFugitive', + \ 'lawrencium': '_LightlineLawrencium', + \ 'ctrlpmark': '_LightlineCtrlPMark', + \ }, + \'component_expand': { + \ 'syntastic': '_LightlineSyntastic', + \ 'ycm_errs': '_LightlineYcmErrors', + \ 'ycm_warns': '_LightlineYcmWarnings', + \ 'gutentags': '_LightlineGutentags', + \ }, + \'component_type': { + \ 'syntastic': 'error', + \ 'ycm_errs': 'error', + \ 'ycm_warns': 'warning', + \ 'gutentags': 'warning', + \ }, + \} + +function! _LightlineFugitive() + return fugitive#head() +endfunction + +function! _LightlineLawrencium() + return lawrencium#statusline() +endfunction + +function! _LightlineCtrlPMark() + if expand('%:t') =~ 'ControlP' && has_key(g:lightline, 'ctrlp_item') + call lightline#link('iR'[g:lightline.ctrlp_regex]) + return lightline#concatenate( + \['WAT?', g:lightline.ctrlp_prev, + \ g:lightline.ctrlp_item, + \ g:lightline.ctrlp_next], + \0) + else + return '' + endif +endfunction + +function! _LightlineGutentags() + return gutentags#statusline() +endfunction + +function! _LightlineSyntastic() + return SyntasticStatuslineFlag() +endfunction + +function! _LightlineYcmErrors() + let l:cnt = youcompleteme#GetErrorCount() + return l:cnt > 0 ? string(l:cnt) : '' +endfunction + +function! _LightlineYcmWarnings() + let l:cnt = youcompleteme#GetWarningCount() + return l:cnt > 0 ? string(l:cnt) : '' +endfunction +" }}} + " }}} " File-Specific Settings {{{ -" Automatically change the current working directory based on a project -" I'm in. -augroup VimRCAutoCWD - au! - autocmd BufReadPost * call s:SetProjectRootCwd(1) - autocmd BufEnter * call s:SetProjectRootCwd(0) -augroup END - augroup VimRCFileType_markdown au! autocmd FileType text,markdown setlocal textwidth=80 @@ -428,8 +491,6 @@ noremap <C-Tab> :tabnext<cr> noremap <C-S-Tab> :tabprevious<cr> nnoremap <leader>t :tabnew<cr> -nnoremap <C-t> :tabnew<cr> -nnoremap <C-w> :tabclose<cr> " Window navigation nnoremap <C-up> :wincmd k<cr> @@ -479,7 +540,7 @@ nnoremap <silent> <C-p> :CtrlP<cr> nnoremap <silent> <C-o> :CtrlPBuffer<cr> nnoremap <silent> <C-u> :CtrlPTag<cr> -nnoremap <silent> <C-y> :CtrlPQuickfix<cr> +nnoremap <silent> <C-y> :CtrlPBufTag<cr> nnoremap <silent> <Tab> :CtrlPMRUFiles<cr> nnoremap <silent> <F8> :CtrlPBookmarkDir<cr> @@ -546,6 +607,13 @@ nnoremap n nzvzz nnoremap N Nzvzz +" YCM mappings. +nnoremap <Leader>jj :YcmCompleter GoToImprecise<cr> +nnoremap <Leader>jd :YcmCompleter GoToDefinition<cr> +nnoremap <Leader>jh :YcmCompleter GoToDeclaration<cr> +nnoremap <Leader>ji :YcmCompleter GoToInclude<cr> +nnoremap <Leader>jc :YcmCompleter GetDoc<cr> + " }}} " Folding {{{ @@ -572,43 +640,6 @@ " }}} -" Status Line {{{ - -set statusline=%f " Path. -set statusline+=%m " Modified flag. -set statusline+=%r " Readonly flag. -set statusline+=%w " Preview window flag. - -set statusline+=\ " Space. - -set statusline+=%#redbar# " Highlight the following as a warning. -set statusline+=%{SyntasticStatuslineFlag()} " Syntastic errors. -set statusline+=%* " Reset highlighting. - -set statusline+=%= " Right align. - -" Tag file generation indicator. -set statusline+=%{gutentags#statusline('[TAGS]')} -set statusline+=\ " Space. - -" Mercurial information. -set statusline+=%{lawrencium#statusline('[',']')} -set statusline+=\ " Space. - -" File format, encoding and type. Ex: "(unix/utf-8/python)" -set statusline+=( -set statusline+=%{&ff} " Format (unix/DOS). -set statusline+=/ -set statusline+=%{strlen(&fenc)?&fenc:&enc} " Encoding (utf-8). -set statusline+=/ -set statusline+=%{&ft} " Type (python). -set statusline+=) - -" Line and column position and counts. -set statusline+=\ (%l\/%L,%03c) - -" }}} - " Functions {{{ function! s:ToggleSpellCheck() abort @@ -630,62 +661,6 @@ call cursor(l, c) endfunction -function! s:FindProjectRoot(cur, marker) abort - let l:cur = a:cur - let l:previous_cur = '' - let l:slash = '/' - if has('win32') - let l:slash = '\' - endif - while l:cur != l:previous_cur - let l:marker_path = l:cur . l:slash . a:marker - if glob(l:marker_path) != '' - return fnamemodify(l:cur, ':p') - endif - let l:previous_cur = l:cur - let l:cur = fnamemodify(l:cur, ':h') - endwhile - return '' -endfunction - -function! s:SetProjectRootCwd(recompute) abort - if a:recompute != 1 && exists('b:ludo_workdir') - execute 'lcd!' fnameescape(b:ludo_workdir) - return - endif - - let l:cur_file_dir = expand('%:p:h', 1) - if l:cur_file_dir =~ '\v^(\w+:)?(//|\\\\)' - " Don't do shit on filenames coming from the network or something. - return - endif - let l:found_root = 0 - let l:root = '' - let l:markers = [] - if exists('g:ctrlp_root_markers') - let l:markers += g:ctrlp_root_markers - endif - let l:markers += ['.git', '.hg', '.svn', '.bzr', '_darcs'] - let l:unique_markers = [] - for marker in l:markers - if index(l:unique_markers, marker) < 0 - call add(l:unique_markers, marker) - endif - endfor - " Find the project root closest to the current file. - for marker in l:unique_markers - let l:proj_root = s:FindProjectRoot(l:cur_file_dir, marker) - if l:proj_root != '' && len(l:proj_root) > len(l:root) - let l:root = l:proj_root - let l:found_root = 1 - endif - endfor - if l:found_root - let b:ludo_workdir = l:root - execute 'lcd!' fnameescape(l:root) - endif -endfunction - function! s:ToggleNERDTree() abort NERDTreeToggle endfunction