Created
May 1, 2023 16:56
-
-
Save leandronsp/64b4b18472a07c3a30a99ea4515ceabe to your computer and use it in GitHub Desktop.
My dotfiles as of 1st May 2023' (Neovim + Tmux)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Mostly stolen from Yan Pritzer's most excellent Yadr (github.com/skwp/dotfiles) | |
" Use Vim settings, rather then Vi settings (much better!). | |
" This must be first, because it changes other options as a side effect. | |
set nocompatible | |
set encoding=utf-8 | |
" ================ General Config ==================== | |
" | |
" | |
set foldmethod=manual | |
set number "Line numbers are good | |
set backspace=indent,eol,start "Allow backspace in insert mode | |
set history=1000 "Store lots of :cmdline history | |
set showcmd "Show incomplete cmds down the bottom | |
set showmode "Show current mode down the bottom | |
set gcr=a:blinkon0 "Disable cursor blink | |
set visualbell "No sounds | |
set autoread "Reload files changed outside vim | |
"set clipboard=unnamed | |
set mouse=a | |
" This makes vim act like all other editors, buffers can | |
" exist in the background without being in a window. | |
" http://items.sjbach.com/319/configuring-vim-right | |
set hidden | |
"turn on syntax highlighting | |
syntax on | |
" The mapleader has to be set before vundle starts loading all | |
" the plugins. | |
let mapleader = ';' | |
" ================ Turn Off Swap Files ============== | |
set noswapfile | |
set nobackup | |
set nowb | |
" ================ Persistent Undo ================== | |
" Keep undo history across sessions, by storing in file. | |
" Only works all the time. | |
if has('persistent_undo') | |
silent !mkdir ~/.config/nvim/backups > /dev/null 2>&1 | |
set undodir=~/.config/nvim/backups | |
set undofile | |
endif | |
" ================ Indentation ====================== | |
set autoindent | |
set smartindent | |
set smarttab | |
set shiftwidth=2 | |
set softtabstop=2 | |
set tabstop=2 | |
set expandtab | |
" Auto indent pasted text | |
nnoremap p p=`]<C-o> | |
nnoremap P P=`]<C-o> | |
" Fix paste in Vim | |
" https://stackoverflow.com/questions/1587178/paste-in-vim-without-moving-the-cursor | |
noremap p p`[ | |
noremap P P`[ | |
" ~/.local/share/nvim/plugged | |
call plug#begin() | |
" Theme | |
Plug 'morhetz/gruvbox' | |
"Plug 'jacoborus/tender.vim' | |
" Misc plugins | |
Plug 'vim-airline/vim-airline' | |
Plug 'vim-airline/vim-airline-themes' | |
Plug 'preservim/tagbar' | |
Plug 'ryanoasis/vim-devicons' | |
Plug 'johnstef99/vim-nerdtree-syntax-highlight' | |
Plug 'preservim/nerdtree' | |
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } | |
Plug 'junegunn/fzf.vim' | |
Plug 'mhinz/vim-startify' | |
Plug 'stephpy/vim-yaml' | |
Plug 'tpope/vim-surround' " Surrounding ysw( | |
Plug 'tpope/vim-commentary' " gcc & gc | |
Plug 'andymass/vim-matchup' | |
Plug 'itchyny/lightline.vim' | |
Plug 'mengelbrecht/lightline-bufferline' | |
Plug 'wakatime/vim-wakatime' | |
Plug 'tpope/vim-dispatch' | |
Plug 'hashivim/vim-terraform' | |
" HTML/CSS | |
Plug 'mattn/emmet-vim' | |
Plug 'ap/vim-css-color' | |
" JSON/YAML | |
Plug 'elzr/vim-json' | |
Plug 'stephpy/vim-yaml' | |
" CoC | |
Plug 'neoclide/coc.nvim' | |
Plug 'jacoborus/tender.vim' | |
" JS/TS | |
Plug 'pangloss/vim-javascript' | |
Plug 'leafgarland/typescript-vim' | |
" Ruby | |
Plug 'tpope/vim-endwise' | |
Plug 'tpope/vim-rails' | |
Plug 'vim-ruby/vim-ruby' | |
" Elixir | |
Plug 'elixir-editors/vim-elixir' | |
" Haskell | |
Plug 'neovimhaskell/haskell-vim' | |
" Testing | |
Plug 'janko/vim-test' | |
Plug 'victormours/vim-rspec' | |
Plug 'pgr0ss/vimux-ruby-test' | |
" Tmux | |
Plug 'benmills/vimux' | |
call plug#end() | |
"" Configure Gruvbox as the default colorscheme | |
syntax enable | |
let g:gruvbox_contrast_light=1 | |
let g:gruvbox_italic=1 | |
colorscheme gruvbox | |
set background=dark | |
if (has("termguicolors")) | |
set termguicolors | |
endif | |
if has("gui_running") | |
"tell the term has 256 colors | |
set t_Co=256 | |
end | |
"" Set the syntax highlight for Ruby files | |
"au BufRead,BufNewFile *.rb set filetype=ruby | |
set ruler | |
set textwidth=200 | |
set colorcolumn=80 | |
" Better search | |
set hlsearch | |
set incsearch | |
set nowrap "Don't wrap lines | |
"set linebreak "Wrap lines at convenient points | |
" Wildignore for search | |
set wildignore+=.keep,*.beam,*.class,*.jar,*.sql,*/vendor/bundle/*,*/target/*,*/coverage/*,*/yacat-repos/*,*/tmp/*,*/log/*,*/_site/*,*/node_modules/*,*/dist/*,*/deps/*,*/__snapshots__/*,*/cypress/data/* | |
" RipGrep | |
if executable('rg') | |
set grepprg=rg\ --vimgrep\ --no-heading | |
set grepformat=%f:%l:%m | |
endif | |
autocmd BufReadPre,FileReadPre *.md :set wrap | |
" Enable filetype plugins for vim-textobj-rubyblock | |
if has("autocmd") | |
filetype indent plugin on | |
endif | |
autocmd FocusLost * silent! wa " Automatically save file | |
set scrolloff=5 " Keep 5 lines below and above the cursor | |
"set cursorline | |
set laststatus=2 | |
set showmatch | |
set formatoptions-=cro " Disable continuation of comments when pasting text | |
autocmd VimResized * wincmd = " Automatically resize splits when resizing window | |
" FileTypes configuration | |
autocmd FileType ruby setlocal expandtab sw=2 ts=2 sts=2 | |
autocmd FileType eruby setlocal expandtab sw=2 ts=2 sts=2 | |
autocmd FileType xml setlocal equalprg=xmllint\ --format\ --recover\ -\ 2>/dev/null | |
autocmd FileType gitcommit set colorcolumn=73 textwidth=72 | |
autocmd BufWritePre * :%s/\s\+$//e | |
autocmd BufWritePost * silent! !ctags . & | |
" Devicons | |
let g:webdevicons_enable = 1 | |
let g:webdevicons_enable_nerdtree = 1 | |
" Tree configuration | |
let g:netrw_banner = 0 | |
let g:netrw_liststyle = 3 | |
let g:NERDTreeHijackNetrw = 0 | |
let g:NERDTreeWinSize=40 | |
let g:NERDTreeStatusline = '%#NonText#' | |
let g:NERDTreeMinimalMenu=1 | |
" Tagbar Config | |
noremap <C-k> :TagbarToggle<CR> | |
" NERDTree Config | |
let NERDTreeMouseMode=2 | |
augroup MouseInNERDTreeOnly | |
autocmd! | |
autocmd BufEnter NERD_tree_* set mouse=a | |
autocmd BufLeave NERD_tree_* set mouse= | |
augroup END | |
"let NERDTreeQuitOnOpen = 1 | |
let NERDTreeAutoDeleteBuffer = 1 | |
let NERDTreeIgnore=['\.o$', '\~$', 'node_modules', 'cypress/data', 'dist', 'tags'] | |
autocmd StdinReadPre * let s:std_in=1 | |
" Prevent opening file inside NERDTree | |
au BufEnter * if bufname('#') =~ 'NERD_tree' && bufname('%') !~ 'NERD_tree' && winnr('$') > 1 | b# | exe "normal! \<c-w>\<c-w>" | :blast | endif | |
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | |
" NERDTree keybindings | |
nnoremap <silent> <leader>n :NERDTreeToggle<CR> | |
nnoremap <silent> <leader>k :NERDTreeFind<CR> | |
" Tabs Config | |
" Go to tab by number | |
noremap <leader>1 1gt | |
noremap <leader>2 2gt | |
noremap <leader>3 3gt | |
noremap <leader>4 4gt | |
noremap <leader>5 5gt | |
noremap <leader>6 6gt | |
noremap <leader>7 7gt | |
noremap <leader>8 8gt | |
noremap <leader>9 9gt | |
noremap <leader>0 :tablast<cr> | |
noremap <leader>x :tabclose<cr> | |
" Go to last active tab | |
au TabLeave * let g:lasttab = tabpagenr() | |
nnoremap <silent> <leader>b :exe "tabn ".g:lasttab<cr> | |
vnoremap <silent> <leader>b :exe "tabn ".g:lasttab<cr> | |
" Customize Fzf | |
function! s:build_quickfix_list(lines) | |
call setqflist(map(copy(a:lines), '{ "filename": v:val }')) | |
copen | |
cc | |
endfunction | |
let g:fzf_action = { | |
\ 'ctrl-q': function('s:build_quickfix_list'), | |
\ 'ctrl-t': 'tab split', | |
\ 'ctrl-x': 'split', | |
\ 'ctrl-v': 'vsplit' } | |
" [Tags] Command to generate tags file | |
let g:fzf_tags_command = 'ctags -R' | |
let $FZF_DEFAULT_OPTS = '--bind ctrl-a:select-all' | |
let rgignore = '**/node_modules/*,**/.git/*,**/vendor/assets/*,**/vendor/bundle/*,**/public/assets/*,**/public/packs/*,**/public/fonts/*,*.sql,*.csv,*.log,**/.keep,*.json' | |
function! RipgrepFzf(query, fullscreen) | |
let command_fmt = 'rg --column --line-number --hidden --follow --no-heading --color=always --smart-case --glob "!{rgignore}" -- %s || true' | |
let initial_command = printf(command_fmt, shellescape(a:query)) | |
let reload_command = printf(command_fmt, '{q}') | |
let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]} | |
call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen) | |
endfunction | |
command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0) | |
command! -bang -nargs=? -complete=dir Files | |
\ call fzf#run(fzf#wrap({'source': 'rg --files --hidden --follow', 'down': '40%'})) | |
nnoremap <silent> <C-p> :Files<CR> | |
nnoremap <silent> <C-i> :Buffers<CR> | |
nnoremap <silent> <C-f> :RG<CR> | |
" CoC configuration | |
let g:coc_global_extensions = ['coc-solargraph', 'coc-elixir', 'coc-json', 'coc-yaml', 'coc-html'] | |
inoremap <expr> <cr> coc#pum#visible() ? coc#pum#confirm() : "\<CR>" | |
" use <tab> to trigger completion and navigate to the next complete item | |
function! CheckBackspace() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~# '\s' | |
endfunction | |
inoremap <expr> <Tab> coc#pum#visible() ? coc#pum#next(1) : "\<Tab>" | |
inoremap <expr> <S-Tab> coc#pum#visible() ? coc#pum#prev(1) : "\<S-Tab>" | |
inoremap <silent><expr> <Tab> | |
\ coc#pum#visible() ? coc#pum#next(1) : | |
\ CheckBackspace() ? "\<Tab>" : | |
\ coc#refresh() | |
" Lightline configuration | |
let g:lightline = { | |
\ 'colorscheme': 'powerline', | |
\ 'active': { | |
\ 'left': [ [ 'mode', 'paste' ], | |
\ [ 'readonly', 'absolutepath', 'modified' ] ], | |
\ 'right': [ [ 'lineinfo' ], [ 'percent' ] ] | |
\ }, | |
\ } | |
let g:lightline.component = { 'close': '' } | |
" Quickfix window bindings | |
nnoremap <leader>cn :cnext<CR> | |
nnoremap <leader>cp :cprevious<CR> | |
nnoremap <leader>cc :ccl<CR> | |
" Rspec configuration | |
let test#ruby#rspec#executable = 'bundle exec rspec' | |
let test#ruby#use_spring_binstub = 1 | |
map <silent> <leader>tf :TestFile -strategy=vimux<CR> | |
map <silent> <leader>tn :TestNearest -strategy=vimux<CR> | |
map <silent> <leader>tl :TestLast -strategy=vimux<CR> | |
map <silent> <leader>ta :TestSuite -strategy=vimux<CR> | |
" Vimux | |
noremap <leader>aa :call VimuxRunCommand("clear; bundle exec rake test")<CR> | |
noremap <leader>ai :call VimuxRunCommand("clear; bundle exec ruby -r ./test/test_helper " . bufname("%"))<CR> | |
noremap <leader>ae :call VimuxRunCommand("clear; bundle exec rake e2e")<CR> | |
noremap <leader>rc :call VimuxRunCommand("clear; cargo check")<CR> | |
noremap <leader>rr :call VimuxRunCommand("clear; cargo run")<CR> | |
noremap <leader>rt :call VimuxRunCommand("clear; cargo test")<CR> | |
" Misc | |
"nnoremap <leader> <expr> gb '`[' . strpart(getregtype(), 0, 1) . '`]' | |
nnoremap <leader>r :source %<CR> | |
nnoremap <leader>pi :PlugInstall<CR> | |
noremap <leader>q :q<CR> | |
noremap <leader>w :w<CR> | |
noremap <leader>qq :qa!<CR> | |
noremap <leader>z :nohl<CR> | |
noremap <leader>sp :set paste<CR> | |
noremap <leader>snp :set nopaste<CR> | |
nmap <silent> <C-s> :w<CR> | |
imap <silent> <C-s> <Esc>:w<CR> | |
" Copy from clipboard | |
nnoremap <C-y> "+y | |
vnoremap <C-y> "+y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set -g history-limit 100000 | |
setw -g mode-keys vi | |
set-window-option -g mode-keys vi | |
set -g pane-border-status off | |
set -g pane-border-format "#{pane_index} #{pane_current_command}" | |
set -g pane-active-border-style fg=yellow | |
set -g default-terminal "xterm-256color" | |
bind-key b send-prefix | |
set -g prefix C-b | |
unbind-key C-h | |
bind-key C-b send-prefix | |
set -g status-left '[#S] ' | |
set -g status-right '' | |
bind c new-window -c "#{pane_current_path}" | |
bind '"' split-window -c "#{pane_current_path}" | |
bind % split-window -h -c "#{pane_current_path}" | |
bind h select-pane -L | |
bind j select-pane -D | |
bind k select-pane -U | |
bind l select-pane -R | |
bind -r H resize-pane -L 7 | |
bind -r J resize-pane -D 7 | |
bind -r K resize-pane -U 7 | |
bind -r L resize-pane -R 7 | |
#bind \ copy-mode | |
########################### | |
# Colors | |
########################### | |
# color status bar | |
set -g status-bg yellow | |
set -g status-fg black | |
# highlight current window | |
set-window-option -g window-status-current-style bg=black,fg=yellow | |
set -g mouse on | |
# Patch for OS X pbpaste and pbcopy under tmux. | |
set-option -g default-command "which reattach-to-user-namespace > /dev/null && reattach-to-user-namespace -l $SHELL || $SHELL" | |
# Setup 'v' to begin selection as in Vim | |
bind-key -T copy-mode-vi v send-keys -X begin-selection | |
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" | |
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle | |
# # Update default binding of `Enter` to also use copy-pipe | |
unbind-key -T copy-mode-vi Enter | |
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" | |
# vi: set ft=tmux : |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment