From a07ae4a5994380a1a5f40823ce40ac8fd4e6644a Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 9 Mar 2020 12:37:02 +0100 Subject: Added vimrc fold marker --- .gitconfig | 2 +- .vimrc | 94 ++++++++++++++++++++++++++++++++++++++++++++------------------ grep.vim | 9 ++++++ 3 files changed, 77 insertions(+), 28 deletions(-) diff --git a/.gitconfig b/.gitconfig index 577206f..2aa7aac 100644 --- a/.gitconfig +++ b/.gitconfig @@ -2,7 +2,7 @@ name = Charles email = sircharlesaze@gmail.com [credential] - helper = cache + helper = store username = HappyTramp [log] decorate = full diff --git a/.vimrc b/.vimrc index 7a329af..ec90935 100644 --- a/.vimrc +++ b/.vimrc @@ -2,10 +2,15 @@ " vimrc " """""""""" -" load pluggins +" load pluggins {{{ source $HOME/dotfiles/.pluggins.vim +" }}} -" common +""""""""""" +" options " +""""""""""" + +" common {{{ let mapleader = ' ' " set leader key to space let maplocalleader = '-' " set file local leader key to backslash set nocompatible " not compatible with vi @@ -21,61 +26,77 @@ set scrolloff=2 " line padding when scrolling set textwidth=89 " when line wrap occurs set encoding=utf-8 " utf-8 encoding filetype plugin indent on " allow to add specific rules for certain type of file +" }}} -" browse list with tab +" browse list with tab {{{ set wildmode=longest,list,full set wildmenu " tab to cycle through completion options set path+=** " recursive :find +"}}} -" intuitif split opening +" intuitif split opening {{{ set splitbelow set splitright set fcs+=vert:\ " no split separator +" }}} -" tab +" tab {{{ set expandtab " tab to space set tabstop=4 " tab size set shiftwidth=4 set smarttab set autoindent set smartindent +" }}} -" file search +" file search {{{ set ignorecase " case insensitive set smartcase set hlsearch " match highlight set incsearch +" }}} -" status +" status {{{ set laststatus=2 " always a statusline (all window) set showcmd " show current partial command in the bottom right set noshowmode " dont show current mode (i.e --INSERT--) +" }}} -" fold +" fold {{{ set foldmethod=indent " create fold based on the text indent +" }}} -" ctrlp pluggin +" ctrlp pluggin {{{ " directory to ignore when searching in file tree set wildignore=*/tmp/*,*.o,*.so,*.swp,*.zip,*/node_modules/*,*/vendor/*,.bundle/*,bin/*,.git/* " ctrlp ignore all stuff in the .gitignore let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard'] +" }}} + +""""""""""""""" +" colorscheme " +""""""""""""""" -" colorscheme +" one {{{ let g:onedark_terminal_italics=1 colorscheme onedark let g:lightline = {} let g:lightline.colorscheme = 'one' " lightline theme to onedark +" }}} + """""""""""" " mappings " """""""""""" -" split navigation +" split navigation {{{ nnoremap nnoremap nnoremap nnoremap +" }}} +" common {{{ " 'Y' yank to the end of the line noremap Y y$ " solves annoying delay went exiting insert mode @@ -98,35 +119,54 @@ nnoremap ) 10j " tag nagigation nnoremap ] nnoremap t -" buffer navigation +" }}} + +" buffer navigation {{{ nnoremap n :bn nnoremap p :bp nnoremap :b# nnoremap l :ls -" file manipulation with leader -nnoremap w :w -nnoremap x :x -" open vimrc in split +" }}} + +" vimrc {{{ nnoremap rc :vsplit $MYVIMRC -" source vimrc nnoremap src :source $MYVIMRC -" file toggle -nnoremap z zi +" }}} + +" c {{{ " create c function body from prototype nnoremap gcf A{} " put semicolon at the end of line nnoremap ; mqA;`q - -" grep -" nnoremap gw :silent grep -R .:copen -" nnoremap gW :silent execute "grep! -R " . shellescape(expand("")) . " .":copen -" nnoremap gn :cnext -" nnoremap gp :cprevious - - +" quickfix window toggle +" }}} + +" quickfix window toggle {{{ +nnoremap q :call QuickfixToggle() +let g:quickfix_is_open = 0 +if !exists('*QuickfixToggle') + function QuickfixToggle() + if g:quickfix_is_open + cclose + let g:quickfix_is_open = 0 + else + copen + let g:quickfix_is_open = 1 + endif + endfunction +endif +" }}} + +" hook {{{ " remove trailing white space on save autocmd BufWritePre * %s/\s\+$//e " initialise buf for fold toggle autocmd BufReadPre * :normal zMzi +" }}} + +" filetype {{{ " real tab in c file for school projects autocmd Filetype c setlocal noexpandtab +" vim fold method to marker +autocmd Filetype vim setlocal foldmethod=marker +" }}} diff --git a/grep.vim b/grep.vim index 3b80fa1..625dfa1 100644 --- a/grep.vim +++ b/grep.vim @@ -13,6 +13,15 @@ function! s:GrepOp(type) endif silent execute "grep! -R " . shellescape(@@) . " ." + silent redraw! + let g:quickfix_is_open = 1 copen let @@ = saved endfunction + + +" nnoremap gw :silent grep -R .:copen +" nnoremap gW :silent execute "grep! -R " . shellescape(expand("")) . " .":copen + +nnoremap gn :cnext +nnoremap gp :cprevious -- cgit