Skip to content

Instantly share code, notes, and snippets.

@nsmaciej
Last active August 19, 2020 11:51
Show Gist options
  • Save nsmaciej/4be265c483b83e4b1a827223a01b6e78 to your computer and use it in GitHub Desktop.
Save nsmaciej/4be265c483b83e4b1a827223a01b6e78 to your computer and use it in GitHub Desktop.
Configs
function! SetIndention(width) abort
let &l:tabstop=a:width
let &l:shiftwidth=a:width
let &l:softtabstop=a:width
endfunction
filetype plugin indent on
set nowrap
set hidden
set showcmd
set showmode
set belloff=all
set autoindent
set nobackup
set confirm
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set autoread
set ruler
set backspace=2
set wildmenu
set scrolloff=8
set ignorecase "Needed for smart case
set smartcase
set number
set relativenumber
syntax on
" Change cursor shape in insert mode
let &t_SI = "\e[6 q"
let &t_EI = "\e[2 q"
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-commentary'
Plug 'ambv/black', { 'for': 'python' }
Plug 'justinmk/vim-sneak'
Plug 'eraserhd/parinfer-rust', {'do': 'cargo build --release'}
Plug 'junegunn/rainbow_parentheses.vim', { 'for': ['scheme', 'lisp'] }
Plug 'michaeljsmith/vim-indent-object'
Plug 'machakann/vim-highlightedyank'
Plug 'JamshedVesuna/vim-markdown-preview'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
call plug#end()
let g:highlightedyank_highlight_duration = 200
" Python stuff
autocmd BufWritePre *.py execute ':Black'
" Lisp stuff
let g:sexp_enable_insert_mode_mappings = 0
autocmd FileType scheme,lisp RainbowParentheses
autocmd FileType scheme,lisp call SetIndention(2)
autocmd FileType scheme,lisp inoremap <buffer> [ (
autocmd FileType scheme,lisp inoremap <buffer> ] )
autocmd FileType scheme,lisp inoremap <buffer> ( [
autocmd FileType scheme,lisp inoremap <buffer> ) ]
" Switch parinfer mode with <space>
let g:parinfer_mode = "indent"
function! SwitchParinferMode() abort
let g:parinfer_mode = g:parinfer_mode == "paren" ? "indent" : "paren"
echo "Now in '" . g:parinfer_mode . "' mode"
endfunction
" TODO: Figure out how to conceal the lambda properly
nmap <space> :call SwitchParinferMode()<CR>
# Paths
# macOS path helper.
[[ -f /etc/profile ]] && . /etc/profile
export PATH=$PATH:~/.cargo/bin
export PATH="/usr/local/sbin:$PATH"
export PATH="/usr/local/opt/ruby/bin:$PATH"
export PATH="/usr/local/lib/ruby/gems/2.7.0/bin:$PATH"
export PATH=$PATH:"/Applications/Sublime\ Merge.app/Contents/SharedSupport/bin"
# Welcome fortune.
fo() {
echo
fortune -s -n 400 computers linuxcookie | while read line; do
echo -e " \033[30;1m$line\033[0m"
done
echo
}
[[ "$TERM_PROGRAM" != "vscode" ]] && fo
# cd magic
cd() {
if (( $# == 0 )); then
builtin cd ~/Home
else
builtin cd "$@"
fi
}
[[ "$PWD" == "$HOME" ]] && cd
# ZSH Options
unsetopt BEEP
setopt AUTO_PUSHD
setopt PROMPT_SUBST
export PROMPT=" %2F%#%f "
[[ "$TERM_PROGRAM" != "iTerm.app" ]] && export RPROMPT="%~"
export HOMEBREW_NO_ANALYTICS=1
export EDITOR="vim"
autoload -U select-word-style
select-word-style shell
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle :compinstall filename '/Users/maciej/.zshrc'
autoload -Uz compinit
compinit
# Folder shortcuts
alias gt='cd ~/Home/Temp'
alias gtt='cd /tmp'
alias gw='cd ~/Home/Workspace'
_pick_folder() {
local -r project="$(ls "$1" | fzf -i --height=20 --reverse --query="$2" --select-1)"
cd "$1/$project"
}
alias gp="_pick_folder $HOME/Home/Projects/"
alias gs="_pick_folder $HOME/Home/Scripts/"
alias gc="_pick_folder $HOME/Home/Contests/"
# Alises.
alias py='python3.8 -q'
alias rs='cargo'
alias v=vim
alias zshrc="v ~/.zshrc; source ~/.zshrc"
alias l="exa --group-directories-first -Gh"
alias ll="exa --group-directories-first -Gl"
alias lla="exa --group-directories-first -Gla"
rc() {
local -r result="${1%.*}"
clang++ -Wall -Wextra -O2 "$1" -o "$result" && ./$result
}
c() {
if (( $# == 0 )); then
code .
else
code -n "$@"
fi
}
# macOS
ma() {
open x-man-page://$1
}
alias sm='smerge .'
alias of='open .'
alias off='open -a Forklift .'
alias h='htop'
# Git
alias gcam="git commit -a -m"
alias gl="git log --oneline --branches --graph"
alias gd="git diff"
# Fzf.
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
source ~/.iterm2_shell_integration.zsh
# SSH
alias woo='ssh wcsf'
alias mtt="ssh -q -t maciej -- tmux -CC -u new -A -s iterm; echo"
alias wtt="ssh -q -t wcsf -- tmux -CC -u new -A -s iterm; echo"
alias wt="ssh -qt wcsf --"
alias w="ssh -q wcsf --"
# HTTPpie
alias reds='https --headers --all --follow'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment