Skip to content

Instantly share code, notes, and snippets.

@giulioungaretti
Created March 29, 2016 07:56
Show Gist options
  • Save giulioungaretti/9c78eef867731a80fbe4 to your computer and use it in GitHub Desktop.
Save giulioungaretti/9c78eef867731a80fbe4 to your computer and use it in GitHub Desktop.
vimdc sever
" {{{
set nocompatible " be iMproved, required
" grab os name
let s:uname = system("uname -s")
call plug#begin('~/.vim/plugged')
"}}}
" --------------------------------------------------------------------- Plugs
" {{{
if s:uname == "Darwin\n"
"Mac specific plug ins
" search in osx dictionary
Plug 'jonhiggs/MacDict.vim'
Plug 'rizzatti/dash.vim'
:nmap <silent> <leader>d <Plug>DashSearch
" search in osx dictionary
" this should make it work with osx/tmux/madness
set clipboard+=unnamed
endif
if s:uname == "Linux\n"
" Do linux stuff here
set clipboard=unnamedplus
" sync vim clipboard to x clipboard
autocmd VimLeave * call system("xsel -ib", getreg('+'))
" look up documentation
Plug 'KabbAmine/zeavim.vim'
:nmap <silent> <leader>d <Plug>Zeavim " <leader>z (NORMAL mode)
:vmap <silent> <leader>d<Plug>ZVVisSelection " <leader>z (VISUAL mode)
endif
" -------------------------------------------------------------------- Visual
"{{{
" turn on syntax highlight
syntax on
" show grammar on gitcommit
autocmd FileType gitcommit setlocal spell
" show curret line
set cursorline
"remove ugly ass split separator
set fillchars=""
set laststatus=0
" visual autocomplete for command menu
set wildmenu
" redraw only when we need to
set lazyredraw
" theme {{{
set background=light
colorscheme PaperColor
set noshowmode
function! Light()
set background=light
if exists(':AirlineRefresh')
:AirlineRefresh
endif
endfunction
function! Dark()
set background=dark
if exists(':AirlineRefresh')
:AirlineRefresh
endif
endfunction
"" map functions to bgl and bgd
map <silent><leader>bgl :call Light()<cr>
map <silent><leader>bgd :call Dark()<cr>
"}}}
set mousehide "Hide when characters are typed
" color of the current line number
nnoremap <silent><leader>oo :set relativenumber!<cr>
"}}}
" ------------------------------------------------------------------ Settings
"{{{
au VimLeave * :!clear
" vim-sensible
set autoindent
set backspace=indent,eol,start
set complete-=i
set smarttab
set nrformats-=octal
" use bash as shell
set shell=/bin/sh
" Don't use Ex mode, use Q for formatting
map Q gq
" zero msec timeout http://www.johnhawthorn.com/2012/09/vi-escape-delays/
set timeoutlen=1000 ttimeoutlen=0
"Extend word designators
set iskeyword-=. " '.' is an end of word designator
set iskeyword-=_ " '_' is an end of word designator
set iskeyword-=- " '_' is an end of word designator
" no backup and swap files.
set nobackup
set noswapfile
" special mode line at end of file
set modelines=1
" md files as markdown
autocmd BufRead,BufNew *.md set filetype=markdown
" highlight as you type
set incsearch
" highlight matching [{()}]
set showmatch
" smart case when searching
set ignorecase
set smartcase
" better mouse interaction is no mouse integration
set mouse=""
"folding
set foldenable " enable folding
set foldnestmax=10 " max 10 nested fold allowed
set foldmethod=syntax " fold based on indent level
"reload on save
autocmd! bufwritepost .vimrc source %
autocmd! bufwritepost vimrc source %
" scroll the view port faster
nnoremap <C-e> 3<C-e>
nnoremap <C-y> 3<C-y>"
"}}}
"-------------------------------------------------------------------- Aliases
"{{{
" bare vim
" run os command and get results in quickfix window.
command -nargs=+ Run :cexpr system('<args>') | copen
command! -nargs=+ SS :bufdo vimgrepadd <f-args> % | copen
" leader
map <space> <leader>
" redo last colon command
nmap @@ @:
" Toggle paste mode.
function! TogglePasteMode()
if &paste
set nopaste
else
set paste
endif
endfunction
nnoremap <leader>p :call TogglePasteMode()<CR>
" move to right
inoremap l; <Esc>la
" fullscreen
function! Fullscreen()
let line = line(".")+0
tabedit %
call cursor(line,0 )
endfunction
function! Minimze()
let line = line(".")+0
tabclose
call cursor(line,0 )
endfunction
"
" tabs shortcuts
map <leader>tn :tabnew<CR>
nnoremap <silent><C-W>m :call Fullscreen() <CR>
nnoremap <silent><C-W>c :call Minimze() <CR>
"jk/kj to to esc
inoremap jk <Esc>
inoremap kj <Esc>
" Move visual block
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
" merge line below
" merge and split
nnoremap M mzJ`z
" Split line (sister to [M]merge lines above)
" The normal use of S is covered by cc, so don't worry about shadowing it.
nnoremap S i<cr><esc>^mwgk:silent! s/\v +$//<cr>:noh<cr>`w
" split right and below instead of default opposite
set splitbelow
set splitright
" folds
nnoremap <silent> z1 :set foldlevel=1<CR>
nnoremap <silent> z2 :set foldlevel=2<CR>
nnoremap <silent> z3 :set foldlevel=3<CR>
nnoremap <silent> z4 :set foldlevel=4<CR>
nnoremap <silent> z5 :set foldlevel=5<CR>
nnoremap <silent> z5 :set foldlevel=6<CR>
nnoremap <silent> z5 :set foldlevel=7<CR>
" turn on and off spell checking.
map <F10> :setlocal spell! spelllang=en_us<CR>
"buffers
" nice maximize split and go back to normal layout
nnoremap <silent><C-W><C-d> :bnext<CR>
nnoremap <silent><C-W><C-a> :bprevious<CR>
" If the current buffer has never been saved, it will have no name,
" call the file browser to save it, otherwise just save it.
command -nargs=0 -bar Update if &modified
\| if empty(bufname('%'))
\| browse confirm write
\| else
\| confirm write
\| endif
\|endif
nnoremap <silent> <leader>w :<C-u>Update<CR>
nnoremap <silent> <leader>q :q<CR>
nnoremap <C-q> :bd <CR>
"}}}
"--------------------------------------------------------------- common typos
"{{{
command! Q q
command! Qq q
command! W w
command! Ww w
command! Qa qa
command! Wa wa
command! Wq wq
command! Wqa wqa
"}}}
" vim: foldmethod=marker sw=4 ts=4 sts=4 et tw=78
#-------~---~----------~----------~----
# Misc settings
#-------~---~----------~----------~----
# {{{
set -g prefix C-f
unbind C-b
# fix color weridness.
set-option -gw utf8 on
set-option -gw xterm-keys on
# use send-prefix to pass C-a through to application
bind C-a send-prefix
# shorten command delay super duper short
set -sg escape-time 0
# reload ~/.tmux.conf using PREFIX r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# status bar on demand
bind-key C-s set -g status
#set keybindings to vi style in copy mode
setw -g mode-keys vi
#sane copy keybindings
# Setup 'v' to begin selection as in Vim
bind-key -t vi-copy v begin-selection
bind-key -t vi-copy 'v' begin-selection
bind-key -t vi-copy 'y' copy-selection
bind ] paste-buffer
# aggressive resize
setw -g aggressive-resize on
# Look good
set -g default-terminal "screen-256color"
set -g set-titles on
set -g set-titles-string 'tmux: #T'
setw -g clock-mode-colour colour13
setw -g clock-mode-style 12
# set insanely long history of panes
set-option -g history-limit 3000
# }}}
#-------~---~----------~----------~----
# WINDOWS & PANES
#-------~---~----------~----------~----
# {{{
# set window and pane index to 1 (0 by default)
set-option -g base-index 1
setw -g pane-base-index 1
# active pane border color
set -g pane-active-border-fg colour11
# idle pane border color
set -g pane-border-fg colour235
# dakr bg
bind -r c-d set -g pane-border-fg colour235
# light bg
bind -r c-b set -g pane-border-fg colour255
set -g display-panes-colour white
set -g display-panes-time 1100
setw -g monitor-activity on
# http://visibletrap.blogspot.dk/2014/05/tmux-open-new-panewindow-base-on.html
# open panes in the same directory
bind % split-window -h -c "#{pane_current_path}"
bind '"' split-window -c "#{pane_current_path}"
# and use c-h and c-l to cycle through panes
bind -r c-h previous-window
bind -r c-l next-window
# send input to all panes
bind a set synchronize-panes
# resize panes using standard vim mapping bind
bind -r < resize-pane -L 2
bind -r > resize-pane -R 2
bind -r - resize-pane -D 2
bind -r + resize-pane -U 2
## split and join panes
#merge
bind-key m command-prompt -p "join pane from:" "join-pane -s '%%'"
#breakk
bind-key b command-prompt -p "send pane to:" "join-pane -t '%%'"
# }}}
#-------~---~----------~----------~----
# STATUS & MESSAGE
#-------~---~----------~----------~----
# {{{
#### COLOUR
tm_color_active=colour1
tm_color_inactive=colour11
tm_color_feature=colour4
tm_color_music=colour2
# message text
set-option -g message-bg default
set-option -g message-fg $tm_color_active
#set -g status-justify right
set -g status-bg default
set -g status-fg default
set -g status-interval 5
set -g status-utf8 on
setw -g window-status-fg magenta
setw -g window-status-attr none
setw -g window-status-current-fg white
setw -g window-status-current-bg black
setw -g window-status-current-attr bold
setw -g window-status-activity-attr none
# active window title colors
set-window-option -g window-status-current-fg $tm_color_active
set-window-option -g window-status-current-bg default
set-window-option -g window-status-current-format "#[bold]#W"
# default window title colors
set-window-option -g window-status-fg default
set-window-option -g window-status-bg default
set -g window-status-format "#I#W"
#status
set -g status-left '#[fg=colour6][#S:#I]'
set -g status-left-length 80
set -g status-right-length 900
set -g status-left-fg black
set -g status-right "#[fg=colour2] #(~/.tmux_status/current_track.sh) #[fg=colour3]#[fg=colour4] ✉ #(~/.tmux_status/mailcount_apple_mail.script) #(~/.tmux_status/battery -t)#[fg=colour15,bg=colour0] %H:%M %a-%d-%h "
# }}}
#-------~---~----------~----------~----
# follow new nvim --HEAD
#-------~---~----------~----------~----
# {{{
# change cursor shape for nvim
# Smart pane switching with awareness of vim splits
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
bind -n C-H if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind -n C-J if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind -n C-K if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind -n C-L if-shell "$is_vim" "send-keys C-l" "select-pane -R"
# vim: foldmethod=marker:foldlevel=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment