Skip to content

Instantly share code, notes, and snippets.

@suhdonghwi
Last active November 3, 2018 00:43
Show Gist options
  • Save suhdonghwi/939084defb0dab3cfbebdbd8e409b3a1 to your computer and use it in GitHub Desktop.
Save suhdonghwi/939084defb0dab3cfbebdbd8e409b3a1 to your computer and use it in GitHub Desktop.
dotfiles
indent-size: 4
line-length: 80
force-trailing-newline: true
# Set previx key to C-a
set-option -g prefix C-a
bind-key C-a send-prefix
# Remove ESC key delay
set -sg escape-time 0
# Turn mouse mode on
set -g mouse on
# Smart pane switching with awareness of Vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"
bind-key -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
bind-key -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
bind-key -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
bind-key -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
bind-key -n C-\ if-shell "$is_vim" "send-keys C-\\" "select-pane -l"
bind-key -T copy-mode-vi C-h select-pane -L
bind-key -T copy-mode-vi C-j select-pane -D
bind-key -T copy-mode-vi C-k select-pane -U
bind-key -T copy-mode-vi C-l select-pane -R
bind-key -T copy-mode-vi C-\ select-pane -l
# Load tmuxline.vim snapshot file
source-file .tmux_seoul256
""""""""""""""""""""""""""""""""""""""""""
" General
""""""""""""""""""""""""""""""""""""""""""
" Set how many lines of history neovim has to remember
set history=500
" Set to auto read when a file is changed from the outside
set autoread
" Set leader key to <SPC>
let mapleader=" "
""""""""""""""""""""""""""""""""""""""""""
" Plugins
""""""""""""""""""""""""""""""""""""""""""
call plug#begin('~/.local/share/nvim/plugged')
Plug 'mhinz/vim-startify'
Plug 'neovimhaskell/haskell-vim'
Plug 'dkasak/gruvbox'
Plug 'tpope/vim-fugitive'
Plug 'mhinz/vim-signify'
Plug 'itchyny/lightline.vim'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'sbdchd/neoformat'
Plug 'scrooloose/nerdtree'
Plug 'christoomey/vim-tmux-navigator'
Plug 'edkolev/tmuxline.vim'
Plug 'farmergreg/vim-lastplace'
Plug 'machakann/vim-sandwich'
Plug 'Raimondi/delimitMate'
Plug 'justinmk/vim-sneak'
Plug 'markonm/traces.vim'
call plug#end()
""""""""""""""""""""""""""""""""""""""""""
" Plugin: vim-fugitive
""""""""""""""""""""""""""""""""""""""""""
nnoremap <Leader>gs :Gstatus<CR>
nnoremap <Leader>gc :Gcommit<CR>
nnoremap <Leader>g :Gpush<CR>
""""""""""""""""""""""""""""""""""""""""""
" Plugin: lightline.vim
""""""""""""""""""""""""""""""""""""""""""
let g:lightline = {
\ 'colorscheme': 'seoul256',
\ 'active': {
\ 'left':[ [ 'mode', 'paste' ],
\ [ 'gitbranch', 'readonly', 'filename', 'modified' ]
\ ]
\ },
\ 'component_function': {
\ 'gitbranch': 'LightlineFugitive',
\ },
\ 'separator': { 'left': "\uE0B0", 'right': "\uE0B2" },
\ 'subseparator': { 'left': "\uE0B1", 'right': "\uE0B3" },
\ }
function! LightlineFugitive()
if exists("*fugitive#head")
let branch = fugitive#head()
return strlen(branch) ? ' '.branch : ''
endif
return ''
endfunction
" Turn showmode(-- INSERT --) off
set noshowmode
""""""""""""""""""""""""""""""""""""""""""
" Plugin: NERDTree
""""""""""""""""""""""""""""""""""""""""""
nnoremap <silent> <leader>tn :NERDTreeToggle<CR>
""""""""""""""""""""""""""""""""""""""""""
" Plugin: fzf.vim
""""""""""""""""""""""""""""""""""""""""""
" Customize fzf colors to match your color scheme
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
nnoremap <silent> <leader>F :Files<CR>
nnoremap <silent> <leader>f :GFiles<CR>
""""""""""""""""""""""""""""""""""""""""""
" Plugin: neoformat
""""""""""""""""""""""""""""""""""""""""""
let g:neoformat_haskell_brittany = {
\ 'exe': 'brittany',
\ 'args': ['--indent 4'],
\ }
let g:neoformat_enabled_haskell = ['brittany']
" Auto-format when saved file
au BufWritePre * try | undojoin | Neoformat | catch /^Vim\%((\a\+)\)\=:E790/ | endtry
""""""""""""""""""""""""""""""""""""""""""
" Plugin: vim-tmux-navigator
""""""""""""""""""""""""""""""""""""""""""
let g:tmux_navigator_save_on_switch = 2
""""""""""""""""""""""""""""""""""""""""""
" Plugin: vim-sneak
""""""""""""""""""""""""""""""""""""""""""
map f <Plug>Sneak_s
map F <Plug>Sneak_S
let g:sneak#label = 1
""""""""""""""""""""""""""""""""""""""""""
" Neovim user interface
""""""""""""""""""""""""""""""""""""""""""
" Set 7 lines to the cursor - when moving vertically using j/k
set so=7
" Turn on the Wild menu
set wildmenu
set wildmode=list:longest,full
" Always show current position
set ruler
" Ignore case when searching
set ignorecase
" When searching try to be smart about cases
set smartcase
" Highlight search results
set hlsearch
" Make search act like search in modern browsers
set incsearch
" Don't redraw while executing macros
set lazyredraw
" For regular expression turn magic on
set magic
" Show matching brackets when text indicator is over them
set showmatch
" Set how many tenths of a second to blink when matching brackets
set mat=2
" No annoying sound on errors
set noerrorbells
set novisualbell
set tm=500
" Turn on line numbers
set nu
" Make ESC key work in Terminal mode
tnoremap <Esc> <C-\><C-n>
""""""""""""""""""""""""""""""""""""""""""
" Colors & Fonts
""""""""""""""""""""""""""""""""""""""""""
" Enable syntax highlighting
syntax enable
" Set gruvbox colorscheme
colorscheme gruvbox
" Set dark background
set background=dark
""""""""""""""""""""""""""""""""""""""""""
" Files, backups and undo
""""""""""""""""""""""""""""""""""""""""""
" Turn backup off set nobackup
set nowb
set noswapfile
""""""""""""""""""""""""""""""""""""""""""
" Text, tab and indent related
""""""""""""""""""""""""""""""""""""""""""
" Use spaces instead of tabs
set expandtab
" Be smart when using tabs
set smarttab
" 1 tab == 4 spaces
set shiftwidth=4
set tabstop=4
" Turn on auto indent
set ai
" Turn on smart indent
set si
" Wrap lines
set wrap
""""""""""""""""""""""""""""""""""""""""""
" Visual mode related
""""""""""""""""""""""""""""""""""""""""""
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
""""""""""""""""""""""""""""""""""""""""""
" Status line
""""""""""""""""""""""""""""""""""""""""""
" Always show the status line
set laststatus=2
""""""""""""""""""""""""""""""""""""""""""
" Helper functions
""""""""""""""""""""""""""""""""""""""""""
function! VisualSelection(direction, extra_filter) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", "\\/.*'$^~[]")
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'gv'
call CmdLine("Ack '" . l:pattern . "' " )
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment