Skip to content

Instantly share code, notes, and snippets.

@coindegen
Last active July 20, 2022 00:31
Show Gist options
  • Save coindegen/fd9c5e99dfea40bdc1787d5a051a19fa to your computer and use it in GitHub Desktop.
Save coindegen/fd9c5e99dfea40bdc1787d5a051a19fa to your computer and use it in GitHub Desktop.
vimrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
test -r /home/jplew/.opam/opam-init/init.sh && . /home/jplew/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true
# Set CLICOLOR if you want Ansi Colors in iTerm2
export CLICOLOR=1
#
# Set colors to match iTerm2 Terminal Colors
export TERM=xterm-256color
parse_git_branch() {
git branch 2> /dev/null | sed -e "/^[^*]/d" -e "s/* \(.*\)/\1/"
}
export PS1="\[$(tput bold)\]\[$(tput setaf 4)\][ \[$(tput setaf 3)\]!\!\[$(tput setaf 2)\] \w\[$(tput setaf 4)\] ] \n[ \[$(tput setaf 5)\]\$(parse_git_branch)\[$(tput setaf 4)\] ] \\$ \[$(tput setaf 7)\]\[$(tput sgr0)\] \[$(tput bold)\]"
#export DISPLAY=:0.0
#export DISPLAY=:0
#export DISPLAY="`grep nameserver /etc/resolv.conf | sed 's/nameserver //'`:0"
#export DISPLAY="`sed -n 's/nameserver //p' /etc/resolv.conf`:0"
#export DISPLAY=$(ip route|awk '/^default/{print $3}'):0.0
#export DISPLAY=$(route.exe print | grep 0.0.0.0 | head -1 | awk '{print $4}'):0.0
# WSL 2 specific settings.
if grep -q "microsoft" /proc/version &>/dev/null; then
# Requires: https://sourceforge.net/projects/vcxsrv/ (or alternative)
export DISPLAY="$(/sbin/ip route | awk '/default/ { print $3 }'):0"
# Allows your gpg passphrase prompt to spawn (useful for signing commits).
export GPG_TTY=$(tty)
fi
"
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
"
" -----------------------------------------------------------------------------
" Plugins
" -----------------------------------------------------------------------------
" Specify a directory for plugins.
call plug#begin('~/.vim/plugged')
" Fuzzy search
Plug 'ctrlpvim/ctrlp.vim'
" Improve text objects
Plug 'wellle/targets.vim'
" Add camelcasemotion
Plug 'bkad/CamelCaseMotion'
" Plug 'chaoren/vim-wordmotion'
" Help with surround syntax
Plug 'tpope/vim-surround'
" Status line
Plug 'itchyny/lightline.vim'
" File explorer
Plug 'preservim/nerdtree'
" Auto-close parentheses
Plug 'cohama/lexima.vim'
" Improved syntax highlighting
Plug 'sheerun/vim-polyglot'
" spaceduck color scheme
Plug 'pineapplegiant/spaceduck'
" Navigate and manipulate files in a tree view.
"Plug 'lambdalisue/fern.vim'
"Plug 'lambdalisue/fern-mapping-mark-children.vim'
" Briefly highlight which text was yanked.
" Plug 'machakann/vim-highlightedyank'
" Highlight which character to jump to when using horizontal movement keys.
Plug 'unblevable/quick-scope'
" Modify * to also work with visual selections.
Plug 'nelstrom/vim-visual-star-search'
" Automatically clear search highlights after you move your cursor.
Plug 'haya14busa/is.vim'
" Handle multi-file find and replace.
Plug 'mhinz/vim-grepper'
" Toggle comments in various ways.
Plug 'tpope/vim-commentary'
" Automatically set 'shiftwidth' + 'expandtab' (indention) based on file type.
Plug 'tpope/vim-sleuth'
" A number of useful motions for the quickfix list, pasting and more.
Plug 'tpope/vim-unimpaired'
" Show git file changes in the gutter.
" Plug 'mhinz/vim-signify'
" A git wrapper.
Plug 'tpope/vim-fugitive'
" Dim paragraphs above and below the active paragraph.
Plug 'junegunn/limelight.vim'
" Distraction free writing by removing UI elements and centering everything.
"Plug 'junegunn/goyo.vim'
" A bunch of useful language related snippets (ultisnips is the engine).
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
" Automatically show Vim's complete menu while typing.
" Plug 'vim-scripts/AutoComplPop'
" Run test suites for various languages.
"Plug 'janko/vim-test'
" Languages and file types.
Plug 'cakebaker/scss-syntax.vim'
Plug 'chrisbra/csv.vim'
Plug 'ekalinin/dockerfile.vim'
Plug 'godlygeek/tabular' | Plug 'tpope/vim-markdown'
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
Plug 'lifepillar/pgsql.vim'
Plug 'othree/html5.vim'
Plug 'pangloss/vim-javascript'
Plug 'leafgarland/typescript-vim'
Plug 'MaxMEllon/vim-jsx-pretty'
Plug 'peitalin/vim-jsx-typescript'
Plug 'jparise/vim-graphql'
Plug 'stephpy/vim-yaml'
Plug 'tmux-plugins/vim-tmux'
"Plug 'tpope/vim-git'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
let g:coc_global_extensions = [
\ 'coc-tsserver'
\ ]
if isdirectory('./node_modules') && isdirectory('./node_modules/prettier')
let g:coc_global_extensions += ['coc-prettier']
endif
if isdirectory('./node_modules') && isdirectory('./node_modules/eslint')
let g:coc_global_extensions += ['coc-eslint']
endif
call plug#end()
let g:lexima_enable_basic_rules=1
let g:camelcasemotion_key = '<leader>'
omap <leader>iw <Plug>CamelCaseMotion_iw
xmap <leader>iw <Plug>CamelCaseMotion_iw
omap <leader>ib <Plug>CamelCaseMotion_ib
xmap <leader>ib <Plug>CamelCaseMotion_ib
omap <leader>ie <Plug>CamelCaseMotion_ie
xmap <leader>ie <Plug>CamelCaseMotion_ie
nnoremap <silent> K :call CocAction('doHover')<CR>
nmap <silent> gh :call CocAction('doHover')<CR>
nmap <leader>do <Plug>(coc-codeaction)
nmap <leader>rn <Plug>(coc-rename)
" 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)
"
" 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)
filetype plugin indent on
" aspacing over everything in insert mode
set backspace=indent,eol,start
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
" set backup " keep a backup file
endif
set history=100 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
"map Q gq
"
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Enable 24-bit true colors if your terminal supports it.
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
set t_Co=256
endif
" colorscheme ir_black
let g:lightline = {
\ 'colorscheme': 'spaceduck',
\ 'component': {
\ 'filename': '%F',
\ },
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'readonly', 'filename', 'modified' ] ],
\ 'right': [ [ 'lineinfo' ],
\ [ 'percent' ]
\ ]
\ },
\ }
colorscheme spaceduck
" set guifont=Menlo:h16
" highlights the line you're currently editing
set cursorline
" set cursorcolumn
"enable omnicompletion
set omnifunc=syntaxcomplete#Complete
" Reference chart of values:
" Ps = 0 -> blinking block.
" Ps = 1 -> blinking block (default).
" Ps = 2 -> steady block.
" Ps = 3 -> blinking underline.
" Ps = 4 -> steady underline.
" Ps = 5 -> blinking bar (xterm).
" Ps = 6 -> steady bar (xterm).
" let &t_SI = '\e[6 q'
" let &t_EI = '\e[2 q'
" highlight Cursor guifg=steelblue guibg=steelblue
" highlight iCursor guifg=black guibg=steelblue
set guicursor=n-v-c:block-Cursor
set guicursor+=i:ver100-iCursor
" set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait10
" if has("autocmd")
" au VimEnter,InsertLeave * silent execute '!echo -ne "\e[2 q"' | redraw!
" au InsertEnter,InsertChange *
" \ if v:insertmode == 'i' |
" \ silent execute '!echo -ne "\e[6 q"' | redraw! |
" \ elseif v:insertmode == 'r' |
" \ silent execute '!echo -ne "\e[4 q"' | redraw! |
" \ endif
" au VimLeave * silent execute '!echo -ne "\e[ q"' | redraw!
" endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
endif " has("autocmd")
" always set autoindenting on
set autoindent
"set smartindent
set cindent
"set html (xml) indentation to four spaces
"
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
set clipboard=unnamedplus,unnamed
set number
"from http://vim.wikia.com/wiki/Remove_swap_and_backup_files_from_your_working_directory
set backupdir=./.bak,.,/tmp
set directory=.,./.bak,/tmp
set autochdir
set iskeyword-=_
" set list!
"from Vimcasts
"set listchars=tab:▸\ ,eol:¬
set listchars=eol:¬,tab:▸-,trail:◇,extends:>,precedes:<
set scrolloff=3
set hidden
set ignorecase
set infercase
"proper PHP tab settings according to PEAR
set expandtab
set shiftwidth=2
set softtabstop=2
set tabstop=2
" sets diffsplit to vsplit by default
" set diffopt+=vertical
" from Vimcasts.org
"
" Set tabstop, softtabstop and shiftwidth to the same value
command! -nargs=* Stab call Stab()
function! Stab()
let l:tabstop = 1 * input('set tabstop = softtabstop = shiftwidth = ')
if l:tabstop > 0
let &l:sts = l:tabstop
let &l:ts = l:tabstop
let &l:sw = l:tabstop
endif
call SummarizeTabs()
endfunction
function! SummarizeTabs()
try
echohl ModeMsg
echon 'tabstop='.&l:ts
echon ' shiftwidth='.&l:sw
echon ' softtabstop='.&l:sts
if &l:et
echon ' expandtab'
else
echon ' noexpandtab'
endif
finally
echohl None
endtry
endfunction
"
"" search for visually selected text, forwards or backwards.
vnoremap <silent> * :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy/<C-R><C-R>=substitute(
\escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
vnoremap <silent> # :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy?<C-R><C-R>=substitute(
\escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
" REMAPPINGS
"Reload the ctags file, refresh ctags
nnoremap <f5> :!ctags -R<CR>
" select last pasted selection
map <Leader>v '[v']
"from Vim for PHP Programmers
"paste and indent
" nnoremap <Esc>p p'[v']=
" nnoremap <Esc>P P'[v']=
map <S-CR> O<Esc>
map <CR> o<Esc>
"smart comment inline PHP
" map <Leader>p :s/\(php\ \)/\1\/\/ /g<CR>
"smart uncomment inline PHP
" map <Leader>u :s/\(php\ \)\/\/\ \?/\1/g<CR>
"wrap this section with a comment. (requires a comment one line above the
"block)
" map <Leader>c '<k\c Y'>p/\a
" forward delete
"inoremap <C-d> <Esc>lxi
"
"
"
"
" close buffer but leave window open. Kill window.
nmap <C-W>! <Plug>Kwbd
nmap <Leader>6 <C-^>
"
"Insert Completion shortcuts
"inoremap ^F ^X^F
"Use space to scroll page forward or backwards
nmap <Space> <C-D>
nmap <S-Space> <C-U>
" Toggle search highlighting
nmap <leader>s :set hlsearch!<CR>
" Shortcut to rapidly toggle `set list` (show invisibles))
nmap <leader>l :set list!<CR>
" Speed up buffer switching (from VimCasts.org)
map <C-k> <C-W>k
map <C-j> <C-W>j
map <C-h> <C-W>h
map <C-l> <C-W>l
"
" Indentation remappings
nmap <D-[> <<
nmap <D-]> >>
vmap <D-[> <gv
vmap <D-]> >gv
inoremap <D-]> >>i
inoremap <D-[> <<i
map Y y$
nnoremap <silent> [b :bprevious<CR>
nnoremap <silent> ]b :bnext<CR>
nnoremap <silent> [B :bfirst<CR>
nnoremap <silent> ]B :blast<CR>
"Expansion of the Active File Directory (from Practical Vim p. 95)
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
"increment and decrement 10 units at a time
nmap <C-D-.> 10<C-a>
nmap <C-D-,> 10<C-x>
" replace default paste function, which overwrites the previous buffer with
" the pasted-over text. This keeps the register contents the same.
xnoremap p pgvy
" soft wrap text
command! -nargs=* Wrap set wrap linebreak
"command! -nargs=* Wrap set wrap linebreak nolist
"
nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <C-n> :NERDTree<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>"
" Ctrl-P
set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux
set wildignore+=node_modules/*
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows
" let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
let g:ctrlp_custom_ignore = {
\ 'dir': 'node_modules/.*',
\ 'file': '\v\.(exe|so|dll)$',
\ 'link': 'some_bad_symbolic_links',
\ }
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']
autocmd QuickFixCmdPost [^l]* nested cwindow
autocmd QuickFixCmdPost l* nested lwindow
let g:typescript_compiler_binary = 'tsc'
let g:typescript_compiler_options = ''
autocmd FileType typescript :set makeprg='tsc'
@coindegen
Copy link
Author

# Improve colors
#set -g default-terminal 'screen-256color'

# Enable color support inside of tmux.
set -g default-terminal "xterm-256color"
set -ga terminal-overrides ",*256col*:Tc"

# soften status bar color from harsh green to light gray
set -g status-bg '#3D550C'
set -g status-fg '#eeeeee'

# Set scrollback buffer to 10000
set -g history-limit 10000

# switch panes
setw -g mode-keys vi
bind -r h select-pane -L
bind -r j select-pane -D
bind -r k select-pane -U
bind -r l select-pane -R
bind-key -r C-h select-window -t :-
bind-key -r C-l select-window -t :+
bind -n C-h select-pane -L
bind -n C-j select-pane -D
bind -n C-k select-pane -U
bind -n C-l select-pane -R

# Enable full mouse support.
set -g mouse on

# shortcuts to edit tmux config
bind-key r source-file ~/.tmux.conf \; display-message "~/.tmux.conf reloaded"
bind-key M split-window -h "vim ~/.tmux.conf"

# clipboard support
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard"
#bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -sel clip -i'
#bind -t vi-copy y copy-pipe "xclip -sel clip -i"
#bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xsel -i --clipboard"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment