Skip to content

Instantly share code, notes, and snippets.

@ramontayag
Created June 19, 2020 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramontayag/44abbb19ab728c3219cdc550b51cd140 to your computer and use it in GitHub Desktop.
Save ramontayag/44abbb19ab728c3219cdc550b51cd140 to your computer and use it in GitHub Desktop.
" at ~/.config/nvim/init.vim
call plug#begin(stdpath('data') . '/plugged')
"" Gruvbox theme.
Plug 'gruvbox-community/gruvbox'
Plug 'airblade/vim-gitgutter' " show + / - changes if git repo
Plug 'AndrewRadev/splitjoin.vim' " expand/collapse blocks
Plug 'davidhalter/jedi-vim'
Plug 'dhruvasagar/vim-table-mode' " format markdown tables
Plug 'easymotion/vim-easymotion' " move more easily within a file
Plug 'godlygeek/tabular' " align text
Plug 'itchyny/lightline.vim'
Plug 'janko/vim-test'
Plug 'jgdavey/vim-blockle' " convert {} to do/end and back
Plug 'jiangmiao/auto-pairs' " add matching ), }, ], etc
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'metakirby5/codi.vim' " Numi in vim!
Plug 'mileszs/ack.vim'
Plug 'nelstrom/vim-visual-star-search' " search visual select with * or #
Plug 'pbrisbin/vim-mkdir'
Plug 'posva/vim-vue'
Plug 'ramontayag/vim-copy-filename'
Plug 'scrooloose/nerdtree'
Plug 'skwp/greplace.vim'
Plug 'slim-template/vim-slim'
Plug 'terryma/vim-multiple-cursors'
Plug 'tmsvg/pear-tree'
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-bundler'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-dotenv'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-markdown'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-surround'
Plug 'vim-scripts/YankRing.vim'
Plug 'Yggdroot/indentLine'
" " Text objects
" " Commented because I couldn't get it to work
" Plug 'kana/vim-textobj-user'
" Plug 'nelstrom/vim-textobj-rubyblock' " Ruby block text objects
" Plug 'chrisbra/matchit' " required by vim-textobj-rubyblock
" === Ultisnips
" https://github.com/sirver/UltiSnips
" Track the engine.
Plug 'SirVer/ultisnips'
" Snippets are separated from the engine. Add this if you want them:
Plug 'honza/vim-snippets'
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
endif
let g:deoplete#enable_at_startup = 1
call plug#end()
" =======================
" set hidden
" This means that the buffer of the old file will only be hidden when you
" switch to the new file.
" https://stackoverflow.com/a/2732336
" =======================
set hidden
" " Install vim-textobj-rubyblock
" runtime macros/matchit.vim
" set nocompatible
" if has("autocmd")
" filetype indent plugin on
" endif
" -----------------------------------------------------------------------------
" Color settings
" -----------------------------------------------------------------------------
" Mostly from https://github.com/nickjj/dotfiles/blob/master/.vimrc
colorscheme gruvbox
" For Gruvbox to look correct in terminal Vim you'll want to source a palette
" script that comes with the Gruvbox plugin.
"
" Add this to your ~/.profile file:
" source "$HOME/.local/share/nvim/plugged/gruvbox/gruvbox_256palette.sh"
" Gruvbox comes with both a dark and light theme.
set background=dark
" Gruvbox has 'hard', 'medium' (default) and 'soft' contrast options.
let g:gruvbox_contrast_light='hard'
" This needs to come last, otherwise the colors aren't correct.
syntax on
" deoplete setup
let g:deoplete#enable_at_startup = 1
" Fix the ultra disgusting visual selection colors of gruvbox (thanks @romainl).
if (&background == 'dark')
hi Visual cterm=NONE ctermfg=NONE ctermbg=237 guibg=#3a3a3a
else
hi Visual cterm=NONE ctermfg=NONE ctermbg=223 guibg=#ffd7af
endif
" -----------------------------------------------------------------------------
" Uncategorized settings
" -----------------------------------------------------------------------------
" Set leader to be ,
let mapleader = ","
" Use `ag` with :Ack
" https://github.com/ggreer/the_silver_searcher#vim
if executable('ag')
let g:ackprg = 'ag --nogroup --nocolor --column'
endif
function! SetSystemClipboard(content)
if system('uname -r') =~ "Microsoft"
call system('clip.exe ', a:content)
elseif system('uname') =~ "Darwin"
call system("pbcopy", a:content)
else
echo "System clipboard not set"
endif
endfunction
" Copy yank to System clipboard
" https://vi.stackexchange.com/a/20231
augroup Yank
autocmd!
autocmd TextYankPost * :call SetSystemClipboard(@")
augroup END
" Open NERDTree with ctrl+\ and show current file
" https://stackoverflow.com/a/7692315
nmap <C-\> :NERDTreeFind<CR>
" NERDTree ignores
let NERDTreeIgnore=['\.DS_Store', '\~$', '\.swp']
" NERDTree shows hidden files
let NERDTreeShowHidden=1
" Move around with ctrl+ direction keys
noremap <C-J> <C-W>w
noremap <C-K> <C-W>W
noremap <C-L> <C-W>l
noremap <C-H> <C-W>h
" Highlight with the mouse
set mouse=a
" Relative line numbers, hybrid style
" https://jeffkreeftmeijer.com/vim-number/
set number
set relativenumber
" Keep cursor vertically center as much as possible
set so=999
" Make relativenumbers dark gray
" https://vim.fandom.com/wiki/Display_line_numbers
highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE
" clear search with //
" <silent> so it does not look like :nohlsearch was typed
nnoremap <silent> // :nohlsearch<CR>
" Open YankRing with <leader>yr
" <silent> so it does not look like :YRShow was typed
nnoremap <silent> <leader>yr :YRShow<CR>
" Open FZF with <leader>t
" <silent> so it does not look like :Files was typed
noremap <silent> <leader>t <Esc><Esc>:Files<CR>
" Show hidden files like .env in CtrlP
" https://medium.com/@jimeno0/search-in-files-and-content-in-vim-neovim-8c1bf74ad5e9
let g:ctrlp_show_hidden = 1
" Split vertically with vv
noremap vv <C-W>v
" Split horizontally with ss
noremap ss <C-W>s
" Resize with <C-W>=
" https://stackoverflow.com/questions/4368690/how-to-increase-the-vertical-split-window-size-in-vim/4368859#4368859
nnoremap <silent> <C-W>= :winc =<CR>
" leader cro to copy relative path
nmap <leader>cro :CopyRelativePath<CR>
" leader cl to copy relative path with line
nmap <leader>crl :CopyRelativePathAndLine<CR>
" Editor options based on file type
function SetCodeOptions()
set colorcolumn=80
highlight ColorColumn ctermbg=DarkGrey
set nowrap
endfunction
autocmd Filetype js,ruby,vim call SetCodeOptions()
" Could not get C-6 to work in WSL, but C-Shift-6 with the ff line does:
" https://github.com/onivim/oni/issues/2002#issuecomment-377692042
noremap <C-6> <C-^>
" Do not convert spaces to tabs as you type
" https://stackoverflow.com/questions/69998/tabs-and-spaces-in-vim
set expandtab
" 'Tabs' are 2 spaces large
set softtabstop=2
set shiftwidth=2
" Remove delay from escape / ctrl+[
" If used with tmux, see other tmux related config:
" set -s escape-time 0
" https://www.johnhawthorn.com/2012/09/vi-escape-delays/
set timeoutlen=1000 ttimeoutlen=10
" Toggle indentation line
nnoremap <leader>ig :IndentLinesToggle<CR>
" Define hook in copy-filepath that allows for custom actions
function! CopyFilepathPost(content)
" copy to system clipboard as well
call SetSystemClipboard(a:content)
endfunction
" For conceal markers.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
" Show hidden files in fzf
" https://github.com/junegunn/fzf/issues/337#issuecomment-136389913
" but ignore some things
let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git --ignore node_modules -g ""'
" C-s to open the matching spec / definition in vertical split
nmap <C-s> :AV<CR>
" Find with C-f
" https://www.youtube.com/watch?v=UM4ks_jWwfU
map <C-f> <Esc><Esc>:Files<CR>
" Ag word or visual selection via <leader>ag
" https://github.com/junegunn/fzf.vim/issues/50#issuecomment-161676378
nnoremap <silent> <leader>ag :Ag <C-R><C-W><CR>
" ======================================= "
" Ultisnips config
" ======================================= "
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" ======================================= "
" Show whitespace
" ======================================= "
set list
" ======================================= "
" Remove all trailing whitespace on save
" https://vim.fandom.com/wiki/Remove_unwanted_spaces
" ======================================= "
autocmd BufWritePre * %s/\s\+$//e
" ======================================= "
" Custom commands to make fugitive easier
" ======================================= "
command! Gpsu :!git push origin --set-upstream $(git rev-parse --abbrev-ref HEAD)
" ======================
" SplitJoin config
" ======================
let g:splitjoin_split_mapping = ''
let g:splitjoin_join_mapping = ''
nmap <Leader>sj :SplitjoinSplit<cr>
nmap <Leader>sk :SplitjoinJoin<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment