aboutsummaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorAdam Hovorka <[email protected]>2018-10-07 09:54:18 -0600
committerAdam Hovorka <[email protected]>2018-10-07 09:54:18 -0600
commit87c73b77964b582900c50308eddd9518948eb895 (patch)
tree1d9d7aefa188dd9d21f11d93821f4e560f45b723 /base
parente97f406a99008f3a73209eb749b0a1382eb5c6dc (diff)
Customize vim statusline
Diffstat (limited to 'base')
-rw-r--r--base/vim/autoload/gitbranch.vim59
-rw-r--r--base/vim/plugin/gitbranch.vim23
-rw-r--r--base/vimrc49
-rw-r--r--base/zsh/aliases.zsh3
4 files changed, 122 insertions, 12 deletions
diff --git a/base/vim/autoload/gitbranch.vim b/base/vim/autoload/gitbranch.vim
new file mode 100644
index 0000000..58f6dd8
--- /dev/null
+++ b/base/vim/autoload/gitbranch.vim
@@ -0,0 +1,59 @@
+" =============================================================================
+" Filename: autoload/gitbranch.vim
+" Author: itchyny
+" License: MIT License
+" Last Change: 2015/02/26 00:34:03.
+" =============================================================================
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+function! gitbranch#name() abort
+ if get(b:, 'gitbranch_pwd', '') !=# expand('%:p:h') || !has_key(b:, 'gitbranch_path')
+ call gitbranch#detect(expand('%:p:h'))
+ endif
+ if has_key(b:, 'gitbranch_path') && filereadable(b:gitbranch_path)
+ let branch = get(readfile(b:gitbranch_path), 0, '')
+ if branch =~# '^ref: '
+ return substitute(branch, '^ref: \%(refs/\%(heads/\|remotes/\|tags/\)\=\)\=', '', '')
+ elseif branch =~# '^\x\{20\}'
+ return branch[:6]
+ endif
+ endif
+ return ''
+endfunction
+
+function! gitbranch#dir(path) abort
+ let path = a:path
+ let prev = ''
+ while path !=# prev
+ let dir = path . '/.git'
+ let type = getftype(dir)
+ if type ==# 'dir' && isdirectory(dir.'/objects') && isdirectory(dir.'/refs') && getfsize(dir.'/HEAD') > 10
+ return dir
+ elseif type ==# 'file'
+ let reldir = get(readfile(dir), 0, '')
+ if reldir =~# '^gitdir: '
+ return simplify(path . '/' . reldir[8:])
+ endif
+ endif
+ let prev = path
+ let path = fnamemodify(path, ':h')
+ endwhile
+ return ''
+endfunction
+
+function! gitbranch#detect(path) abort
+ unlet! b:gitbranch_path
+ let b:gitbranch_pwd = expand('%:p:h')
+ let dir = gitbranch#dir(a:path)
+ if dir !=# ''
+ let path = dir . '/HEAD'
+ if filereadable(path)
+ let b:gitbranch_path = path
+ endif
+ endif
+endfunction
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
diff --git a/base/vim/plugin/gitbranch.vim b/base/vim/plugin/gitbranch.vim
new file mode 100644
index 0000000..a6f776a
--- /dev/null
+++ b/base/vim/plugin/gitbranch.vim
@@ -0,0 +1,23 @@
+" =============================================================================
+" Filename: plugin/gitbranch.vim
+" Author: itchyny
+" License: MIT License
+" Last Change: 2015/05/12 08:16:47.
+" =============================================================================
+
+if exists('g:loaded_gitbranch') || v:version < 700
+ finish
+endif
+let g:loaded_gitbranch = 1
+
+let s:save_cpo = &cpo
+set cpo&vim
+
+augroup GitBranch
+ autocmd!
+ autocmd BufNewFile,BufReadPost * call gitbranch#detect(expand('<amatch>:p:h'))
+ autocmd BufEnter * call gitbranch#detect(expand('%:p:h'))
+augroup END
+
+let &cpo = s:save_cpo
+unlet s:save_cpo
diff --git a/base/vimrc b/base/vimrc
index befd96e..0d3871c 100644
--- a/base/vimrc
+++ b/base/vimrc
@@ -61,14 +61,10 @@ set wrap
"set textwidth=79
"set formatoptions=tqrn1
set colorcolumn=85
-set ruler
set number
set relativenumber
-set laststatus=2
-set shortmess=aoOstTWAI
set cursorline
-"set showmode
-set showcmd
+set shortmess=aoOstTWAI
set title " change the terminal's title
set scrolloff=3
@@ -88,6 +84,38 @@ set ttyfast
hi ColorColumn ctermbg=18
hi Folded ctermbg=0 ctermfg=12
+" Statusline ====----
+function! StatusGitInfo()
+ let git = gitbranch#name()
+ if git != ''
+ return ' '.git.' '
+ else
+ return ''
+endfunction
+
+"set ruler
+set showmode
+set showcmd
+set laststatus=2
+set statusline=
+"set statusline+=\ S%{strftime('%R',\ getftime(expand('%')))} " Time when last saved
+set statusline+=%1*\ %2*%<\ " Cut at start
+set statusline+=%3*%f " Path
+set statusline+=%{&modified?'\ +':''} " Modified
+set statusline+=%{&ro?'\ ':''} " Read only
+set statusline+=%{&paste?'\ P':''} " Paste mode
+"set statusline+=[%n%H%M%R%W]\ " flags and buf no
+set statusline+=%4*%=%3*\ " Section break
+set statusline+=%{&ff=='unix'?'':&ff\ } " Line ending
+set statusline+=%l\ %c\ %P\ " Line column percent
+set statusline+=%2*%1*%{StatusGitInfo()}\ " Git branch
+" ^Vue0b0
+
+hi User1 ctermfg=020 ctermbg=019
+hi User2 ctermfg=019 ctermbg=018
+hi User3 ctermfg=020 ctermbg=018
+hi User4 ctermfg=018 ctermbg=000
+
" Stop using arrow keys ====----
" noremap <up> <nop>
" noremap <down> <nop>
@@ -138,13 +166,13 @@ nnoremap <leader>q gqip
nnoremap <leader>vp `[V`]
nnoremap <leader>h :syntax sync fromstart<CR>
nnoremap <leader>l :nohlsearch<cr>:diffupdate<cr>:syntax sync fromstart<cr><c-l>
-nnoremap <leader>l :nohlsearch<cr>:diffupdate<cr>:syntax sync fromstart<cr><c-l>
nnoremap [<space> :<c-u>put! =repeat(nr2char(10), v:count1)<cr>'[
nnoremap ]<space> :<c-u>put =repeat(nr2char(10), v:count1)<cr>
noremap <leader>y "+y
noremap <leader>yy "+Y
noremap <leader>p :set paste<CR>:put +<CR>:set nopaste<CR>
+vnoremap p "_dP
noremap <silent> + :s/^\s*/&\/\//<CR>:noh<CR>
noremap <silent> - :s/^\(\s*\)\/\//\1/<CR>:noh<CR>
@@ -152,7 +180,9 @@ noremap <silent> - :s/^\(\s*\)\/\//\1/<CR>:noh<CR>
vnoremap Q gq
nnoremap Q gqap
-cnoremap w!! w !sudo tee % >/dev/null
+cnoremap w!! %!sudo tee % >/dev/null
+cnoremap <c-n> <down>
+cnoremap <c-p> <up>
" helper function to toggle hex mode
function! ToggleHex()
@@ -231,9 +261,6 @@ au BufNewFile,BufRead * call SetLocalOptions(bufname("%"))
" To move elsewhere ====----
au BufNewFile,BufRead *.less set filetype=less
autocmd! BufWritePost $MYVIMRC source $MYVIMRC
-packadd! matchit
-cnoremap <c-n> <down>
-cnoremap <c-p> <up>
autocmd! BufRead,BufNewFile *.md set filetype=markdown
autocmd! BufRead,BufNewFile *.md set spell
-vnoremap p "_dP
+packadd! matchit
diff --git a/base/zsh/aliases.zsh b/base/zsh/aliases.zsh
index b0c73ca..8784e86 100644
--- a/base/zsh/aliases.zsh
+++ b/base/zsh/aliases.zsh
@@ -27,9 +27,10 @@ alias cp="cp -i"
alias mv="mv -i"
# GIT
-alias gs='git status --short'
+alias gits='git status --short'
alias gp='git push'
alias ga='git add'
+alias gco='git checkout'
alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
# POWER