Skip to content

Instantly share code, notes, and snippets.

@SpencerAung

SpencerAung/.gitconfig

Last active Jan 6, 2021
Embed
What would you like to do?
Vim and Neovim setup
[credential]
helper = osxkeychain
[core]
editor = nvim
[Alias]
trail = log --all --graph --decorate --oneline
b = branch
c = commit
d = diff
l = log
p = push
s = status
f = "fetch --all"
cp = "!f() { git commit -am $1; git push }; f"
pl = pull
po = "!f() { git pull origin $1; }; f"
co = checkout
nb = "!f() { git checkout -b $1; git push --set-upstream origin $1; }; f"
cam = "!f() { git c -am $1; }; f"
tree = "log --graph --decorate --pretty=oneline --abbrev-commit"
fire = "!f() { git commit -am emergency; git pull; git push -f }"
subupdate = "submodule update --recursive --remote --merge"
show-current = rev-parse --abbrev-ref HEAD
[mergetool "nvim"]
cmd = nvim -f -c \"Gdiffsplit!\" \"$MERGED\"
[merge]
tool = fugitive
[mergetool]
prompt = false
[mergetool "fugitive"]
cmd = nvim -f -c \"Gvdiffsplit!\" \"$MERGED\"
# plugins
set -g @plugin 'tmux-plugins/tmux-resurrect'
# fix key binding
set -g prefix C-b
bind C-b send-prefix
unbind C-a
set -g focus-events on
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'
so ~/.vim/plugins.vim
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab "expand tabs to spaces
" set autochdir
set relativenumber
set number
set autoread
au CursorHold * checktime
" Search down into subfolders
" Provides tab-completion for all file-related tasks
set path+=**
" Display all matching files when we tab complete
set wildmenu
" Ignore node_modules folder
set wildignore+=**/node_modules/**
"##### Color
" set color scheme
" set t_Co=256
set termguicolors
"##### Key mappings
imap jk <Esc>
imap kj <Esc>
" Delete all buffer except current one
nnoremap cb :%bd \| e#<CR>
" Copy content to clipboard
nnoremap <leader>ca ggVG"*y<Esc>
" Add a blank line below
nnoremap al o<Esc>
" Add a blank line above
nnoremap aL O<Esc>
" Open ~/.vimrc in a vsplit
nnoremap <leader>ev :vsplit ~/.vimrc<CR>
" Open ~/.vim/plugins.vim in a vsplit
nnoremap <leader>ep :vsplit ~/.vim/plugins.vim<CR>
" Source .vimrc
nnoremap <leader>sv :source ~/.vimrc<Cr>
echo "Hello, Spencer >^.^<"
" ~/.config/nvim/init.vim
set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
source ~/.vimrc
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'junegunn/vim-plug'
Plug 'editorconfig/editorconfig-vim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'mxw/vim-jsx'
Plug 'pangloss/vim-javascript'
Plug 'dense-analysis/ale'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'airblade/vim-gitgutter'
Plug 'kien/rainbow_parentheses.vim'
Plug 'ntpeters/vim-better-whitespace'
Plug 'tpope/vim-commentary'
Plug 'joegesualdo/jsdoc.vim'
Plug 'tpope/vim-surround'
Plug 'vim-airline/vim-airline'
Plug 'tpope/vim-fugitive'
Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
Plug 'leafgarland/typescript-vim'
Plug 'Quramy/vim-js-pretty-template'
Plug 'tpope/vim-unimpaired'
Plug 'edkolev/tmuxline.vim'
Plug 'vim-airline/vim-airline-themes'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'airblade/vim-rooter'
call plug#end()
" coc
" coc multi cursor
nmap <silent> <C-c> <Plug>(coc-cursors-position)
nmap <silent> <C-d> <Plug>(coc-cursors-word)
nmap <silent> <C-d> <Plug>(coc-cursors-range)
" use normal command like `<leader>xi(`
nmap <leader>x <Plug>(coc-cursors-operator)
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" rename
nmap <leader> rr <Plug>(coc-rename)
nnoremap <leader>prw :CocSearch <C-R>=expand("<cword>")<CR><CR>
" coc -highligh
autocmd CursorHold * silent call CocActionAsync('highlight')
" vim fugitive
nmap <leader>gh : diffget //3<CR>
nmap <leader>gf :diffget //2<CR>
nmap <leader>gs :G<CR>
" ale config
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'javascript': ['prettier', 'eslint'],
\ 'typescript': ['prettier', 'eslint'],
\ 'css': ['prettier'],
\ 'scss': ['prettier']
\}
let g:ale_linters = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'javascript': ['eslint', 'tsserver'],
\ 'typescript': ['eslint', 'tsserver']
\}
let g:ale_typescript_standard_options = '--fix'
let g:ale_typescript_standard_use_global = 1
let g:ale_sign_error = '>>'
let g:ale_sign_warning = '--'
let g:ale_lint_on_save = 1
let g:ale_fix_on_save = 1
" Run ale Linting explicit
let g:ale_linters_explicit = 0
let g:ale_completion_tsserver_autoimport = 1
let g:ale_set_highlights = 0
let g:ale_hover_to_preview = 1
let g:ale_set_balloons = 1
let g:airline#extensions#ale#enabled = 1
highlight NormalFloat ctermbg=17
" NERDTree
let g:NERDTreeShowHidden=1
" open a NERDTree automatically when vim starts up if no files were specified
autocmd StdinReadPre * let s:std_in=1
"autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
" Close vim if the only window left open is a NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" Igonre
let g:NERDTreeIgnore = ['^node_modules']
nmap ,n :NERDTreeFind<CR>
nmap ,m :NERDTreeToggle<CR>
" vim-airline config
let g:airline_powerline_fonts = 0
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline_theme= "wombat"
" tmuxline
let g:tmuxline_powerline_separators = 0
" rainbow_parentheses
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
" vim-javascript
let g:javascript_plugin_jsdoc = 1
" vim-better-whitespace
let g:better_whitespace_enabled=1
let g:strip_whitespace_on_save=1
let g:strip_whitespace_confirm = 0
" git-gutter
let g:gitgutter_highlight_linenrs = 1
set updatetime=100
set signcolumn=yes
highlight SignColumn guibg=#121522 ctermbg=16
highlight GitGutterAdd guifg=#009900 ctermfg=2
highlight GitGutterChange guifg=#bbbb00 ctermfg=3
highlight GitGutterDelete guifg=#ff2222 ctermfg=1
" function! GitStatus()
" let [a,m,r] = GitGutterGetHunkSummary()
" return printf('+%d ~%d -%d', a, m, r)
" endfunction
" set statusline+=%{GitStatus()}
nmap ghs <Plug>(GitGutterStageHunk)
nmap ghu <Plug>(GitGutterUndoHunk)
nmap ghp <Plug>(GitGutterPreviewHunk)
omap ih <Plug>(GitGutterTextObjectInnerPending)
omap ah <Plug>(GitGutterTextObjectOuterPending)
xmap ih <Plug>(GitGutterTextObjectInnerVisual)
xmap ah <Plug>(GitGutterTextObjectOuterVisual)
nmap ]h <Plug>(GitGutterNextHunk)
nmap [h <Plug>(GitGutterPrevHunk)
" fzf
fun! FzfOmniFiles()
let is_git = system('git status')
if v:shell_error
:Files
else
:GitFiles
endif
endfun
nnoremap <C-g>b :Buffers<CR>
nnoremap <C-g>g :Ag<CR>
nnoremap <leader><leader> :Commands<CR>
nnoremap <C-p> :call FzfOmniFiles()<CR>
" vim-rooter
let g:rooter_manual_only = 1
#!/bin/bash
# install oh-my-zsh!
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install tmux
brew install python
brew install neovim
brew install the_silver_searcher
# install tmux plugin manager
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
# if needed, install these
pip3 install --user pynvim
pip3 install --user --upgrade pynv0im
# git config
brew install git
git config --global user.name "username"
git config --global user.email "emailaddress"
# save git credential
git config --global credential.helper osxkeychain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.