Skip to content

Instantly share code, notes, and snippets.

@thiagoramos23
Last active November 25, 2020 13:09
Show Gist options
  • Save thiagoramos23/e27f887913430202aa9ac7a4b0fc2806 to your computer and use it in GitHub Desktop.
Save thiagoramos23/e27f887913430202aa9ac7a4b0fc2806 to your computer and use it in GitHub Desktop.
Last vimrc
syntax on
set nocompatible " be iMproved, required
filetype off " required
set clipboard+=unnamed "Yanks go on clipboard instead.
set history=256 "Number of things to remember in history.
set autowrite "Writes on make/shell commands
set ruler "Ruler on
set nu "Line numbers on
set nowrap "Line wrapping off
set timeoutlen=250
set hidden
set confirm
set ts=2 " Tabs are 2 spaces
set bs=2 " Backspace over everything in insert mode
set shiftwidth=2 " Tabs under smart indent
set nocp incsearch
set cinoptions=:0,p0,t0
set cinwords=if,else,while,do,for,switch,case
set formatoptions=tcqr
set cindent
set autoindent
set smartindent
set expandtab
set tabstop=2
set noswapfile
set laststatus=2
set foldmethod=indent
set nofoldenable
set noshowmode
set relativenumber
set hlsearch
set guifont="Inconsolata XL"
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'vim-ruby/vim-ruby'
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-rake'
Plugin 'tpope/vim-commentary'
Plugin 'elixir-editors/vim-elixir'
Plugin 'tpope/vim-bundler'
Plugin 'tpope/vim-rhubarb'
Plugin 'vim-test/vim-test'
Plugin 'tpope/vim-projectionist'
Plugin 'jlanzarotta/bufexplorer'
Plugin 'tpope/vim-fugitive'
Plugin 'morhetz/gruvbox'
Plugin 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plugin 'junegunn/fzf.vim'
Plugin 'stsewd/fzf-checkout.vim'
Plugin 'neoclide/coc.nvim', {'branch': 'release'}
Plugin 'amiralies/coc-elixir', {'do': 'yarn install && yarn prepack'}
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'MattesGroeger/vim-bookmarks'
Plugin 'numkil/ag.nvim'
Plugin 'Yggdroot/indentLine'
Plugin 'easymotion/vim-easymotion'
Plugin 'chaoren/vim-wordmotion'
Plugin 'tveskag/nvim-blame-line'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'andrewradev/splitjoin.vim'
Plugin 'altercation/vim-colors-solarized'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'rizzatti/dash.vim'
Plugin 'joshdick/onedark.vim'
let mapleader=","
let ruby_fold=1
nmap <C-]> :CocCommand explorer --width 80<CR>
nmap <space>e :CocCommand explorer --preset floating<CR>
nnoremap vv :vsp<CR>
nnoremap ss :sp<CR>
nnoremap <silent> <c-h> :TmuxNavigateLeft<cr>
nnoremap <silent> <c-j> :TmuxNavigateDown<cr>
nnoremap <silent> <c-k> :TmuxNavigateUp<cr>
nnoremap <silent> <c-l> :TmuxNavigateRight<cr>
nnoremap <silent> <leader>t :Files<CR>
nnoremap <silent> <leader>tr :Buffers<CR>
nnoremap <silent> <leader>bb :GBranches<CR>
" nvim-blame-line
nnoremap <Leader>gb ::ToggleBlameLine<CR>
" Dash Search word under the cursor
nmap <silent> <leader>d <Plug>DashSearch
" Open and Source .vimrc
nnoremap <leader>ev :vsplit ~/.vimrc<cr>
nnoremap <leader>sv :source ~/.vimrc<cr>
" Abbreviation to write the whole pry command
:abbr pry require 'pry'; binding.pry<ESC><CR>
nnoremap <C-f> :Rg<CR>
" map nohl
nmap <silent> <leader>qq :nohlsearch<CR>
" Remap SplitJoin Plugin
nmap <leader>gs :SplitjoinSplit<cr>
nmap <leader>gj :SplitjoinJoin<cr>
" map % to z
noremap <silent> zz %
" Vim Fugitive and FZF configuration
let g:fzf_commits_log_options = '--graph --color=always
\ --format="%C(yellow)%h%C(red)%d%C(reset)
\ - %C(bold green)(%ar)%C(reset) %s %C(blue)<%an>%C(reset)"'
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
nnoremap <silent> <Leader>c :Commits<CR>
nnoremap <silent> <Leader>bc :BCommits<CR>
" Run Specs
nmap <silent> <leader>rs :TestNearest<CR>
nmap <silent> <leader>rt :TestFile<CR>
nmap <silent> <leader>rr :TestSuite<CR>
nmap <silent> <leader>rl :TestLast<CR>
nmap <silent> <leader>rv :TestVisit<CR>
let test#ruby#rspec#executable="rspec"
let g:rspec_command = "bundle exec rspec {spec}"
let g:rspec_runner = "os_x_iterm2"
" vim-wordmotion
let g:wordmotion_prefix = '<Leader>'
" nnoremap <silent> <leader>q :<c-u>exec 'Tclose'<cr>
" Search and Replace
nnoremap <leader>r yiw:%s/\<<C-r>"\>/<C-r>"/gc<left><left><left>
nnoremap <leader>f yiw:/\<<C-r>"\><left><left><left>
" Plugin 'mg979/vim-visual-multi', {'branch': 'master'} -- TODO: This plugin
" will need to change the key bindings
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
filetype plugin on
" Color Scheme
colorscheme onedark
set background=dark " Setting dark mode
"let g:gruvbox_contrast_light= "hard"
set t_Co=256
let g:test#strategy = "vimterminal"
nnoremap <leader>tl :<c-u>exec v:count.'Tclear'<cr>
nnoremap <leader>q :<c-u>exec v:count.'Tclose'<cr>
command! -nargs=+ Tg :T git <args>
set rtp+=/usr/local/opt/fzf
function FindChar()
let c = nr2char( getchar() )
let match = search('\V' . c)
endfunction
" COC VIM Configuration
" ===================== DO NOT FORGET TO INSTALL SOLARGRAPH =========
" gem install solargraph
"
let g:coc_global_extensions = ['coc-solargraph', 'coc-json']
" Give more space for displaying messages.
set cmdheight=2
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=17
" Don't pass messages to |ins-completion-menu|.
"set shortmess+=c
" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
if has("patch-8.1.1564")
" Recently vim can merge signcolumn and number column into one
set signcolumn=number
else
set signcolumn=yes
endif
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
" inoremap <silent><expr> <c-space> coc#refresh()
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current
" position. Coc only does snippet and additional edit on confirm.
" <cr> could be remapped by other vim plugin, try `:verbose imap <CR>`.
"if exists('*complete_info')
" inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
"else
" inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
"endif
" 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)
" 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 K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
" nmap <leader>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder.
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
" xmap <leader>a <Plug>(coc-codeaction-selected)
" Remap keys for applying codeAction to the current buffer.
" nmap <leader>ac <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
" nmap <leader>qf <Plug>(coc-fix-current)
" Map function and class text objects
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
" xmap if <Plug>(coc-funcobj-i)
" omap if <Plug>(coc-funcobj-i)
" xmap af <Plug>(coc-funcobj-a)
" omap af <Plug>(coc-funcobj-a)
" xmap ic <Plug>(coc-classobj-i)
" omap ic <Plug>(coc-classobj-i)
" xmap ac <Plug>(coc-classobj-a)
" omap ac <Plug>(coc-classobj-a)
" Use CTRL-S for selections ranges.
" Requires 'textDocument/selectionRange' support of LS, ex: coc-tsserver
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocAction('format')
" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
" Add (Neo)Vim's native statusline support.
" NOTE: Please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
" Mappings for CoCList
" Show all diagnostics.
"nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr>
"" Manage extensions.
"nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr>
"" Show commands.
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr>
"" Find symbol of current document.
"nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr>
"" Search workspace symbols.
"nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr>
"" Do default action for next item.
"nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR>
"" Do default action for previous item.
"nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR>
"" Resume latest coc list.
"nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment