Last active
June 12, 2024 23:27
-
-
Save ghomem/816ac97ef7ccd1064e2ffa650b9033e8 to your computer and use it in GitHub Desktop.
vimrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
call plug#begin() | |
" List your plugins here | |
Plug 'preservim/nerdtree' | |
Plug 'ghifarit53/tokyonight-vim' | |
Plug 'itchyny/lightline.vim' | |
Plug 'tpope/vim-fugitive' | |
Plug 'rodjek/vim-puppet' | |
Plug 'iberianpig/tig-explorer.vim' | |
Plug 'mhinz/vim-grepper' | |
call plug#end() | |
" NERDTree | |
" | |
" focus on file if a file is given as an argument, else focus starts on the tree | |
" updates CWD as you open a file | |
" Enter opens the file retaining focus on the tree, sets CWD implicitly | |
" Space expands a directory, sets CWD | |
autocmd StdinReadPre * let s:std_in=1 | |
autocmd VimEnter * NERDTree ~/ | if !argc() == 0 || exists('s:std_in') || !v:this_session == '' | wincmd p | endif | |
autocmd BufEnter * silent! lcd %:p:h | |
autocmd FileType nerdtree nmap <buffer> <CR> go | |
autocmd FileType nerdtree nmap <buffer> <Space> ocd | |
" Vim grepper (results on quickfix window -qf) | |
" | |
" Enter on grep results opens the file retaining focus on the result | |
" q exits the grep results | |
autocmd FileType qf nnoremap <buffer> <CR> <CR><C-W>p | |
autocmd FileType qf nnoremap <buffer> q :x<CR> | |
" Colorscheme | |
set termguicolors | |
let g:tokyonight_style = 'night' " available: night, storm | |
let g:tokyonight_enable_italic = 1 | |
colorscheme tokyonight | |
" Lightline | |
let g:lightline = { | |
\ 'colorscheme': 'wombat', | |
\ 'active': { | |
\ 'left': [ [ 'mode', 'paste' ], | |
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ] | |
\ }, | |
\ 'component_function': { | |
\ 'gitbranch': 'FugitiveHead' | |
\ }, | |
\ } | |
" Key mappings | |
nnoremap <silent> <C-Right> <c-w>l | |
nnoremap <silent> <C-Left> <c-w>h | |
nnoremap <silent> <C-Up> <c-w>k | |
nnoremap <silent> <C-Down> <c-w>j | |
" open tig with current file | |
nnoremap <C-t> :TigOpenCurrentFile<CR> | |
" open tig with Project root path | |
nnoremap <C-y> :TigOpenProjectRootDir<CR> | |
" open tig blame with current file | |
nnoremap <C-b> :TigBlame<CR> | |
" toggle NERDTree to go "full screen", + toggle line numbers | |
nnoremap <F5> :NERDTreeToggle<CR> | |
nnoremap <F6> :set number!<CR> | |
" recursive search with Control+F | |
nnoremap <C-f> :GrepperGrep<Space> | |
" quit the usual way | |
nnoremap :q :qa | |
nnoremap :wq :wqa | |
" Misc | |
" uncomment if you want numbers on by default | |
" set number | |
" terminal opening below + mapping | |
set splitbelow | |
nnoremap <F4> :let $VIM_DIR=expand('%:p:h')<CR>:terminal<CR>cd $VIM_DIR<CR>clear<CR> | |
" this is somehow necessary for remapping to work reliably | |
set notimeout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make sure your system contains the amazing
tig
utility:And now execute as a normal user:
Note that the script that gets executed is this:
https://gist.github.com/ghomem/84549becd122453f27f7278cae19b91a
Now you are ready to use vim with the following shortcuts:
tig
for the current filetig blame
for the current filetig
for the directory of the current fileNote: to move from the terminal to the other windows control + w w must be used. The remaining shortcuts are ignored by the terminal.