Skip to content

Instantly share code, notes, and snippets.

@mmacphail
Created August 25, 2020 21:37
Show Gist options
  • Save mmacphail/d2b7ec36569e0b57b1ceda0911b254a3 to your computer and use it in GitHub Desktop.
Save mmacphail/d2b7ec36569e0b57b1ceda0911b254a3 to your computer and use it in GitHub Desktop.
WSL2 .vimrc
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'itchyny/lightline.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'airblade/vim-gitgutter'
Plugin 'alvan/vim-closetag'
Plugin 'tpope/vim-surround'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'Chiel92/vim-autoformat'
Plugin 'bling/vim-bufferline'
Plugin 'mg979/vim-visual-multi'
" 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
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" Requiered for lightline.vim plugin to work
" See https://github.com/itchyny/lightline.vim
set laststatus=2
" Config for closetag plugin
" See https://github.com/alvan/vim-closetag
" filenames like *.xml, *.html, *.xhtml, ...
" These are the file extensions where this plugin is enabled.
"
let g:closetag_filenames = '*.xml,*.html,*.xhtml,*.phtml'
" filenames like *.xml, *.xhtml, ...
" This will make the list of non-closing tags self-closing in the specified files.
"
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx'
" filetypes like xml, html, xhtml, ...
" These are the file types where this plugin is enabled.
"
let g:closetag_filetypes = 'xml,html,xhtml,phtml'
" filetypes like xml, xhtml, ...
" This will make the list of non-closing tags self-closing in the specified files.
"
let g:closetag_xhtml_filetypes = 'xhtml,jsx'
" integer value [0|1]
" This will make the list of non-closing tags case-sensitive (e.g. `<Link>` will be closed while `<link>` won't.)
"
let g:closetag_emptyTags_caseSensitive = 1
" dict
" Disables auto-close if not in a "valid" region (based on filetype)
"
let g:closetag_regions = {
\ 'typescript.tsx': 'jsxRegion,tsxRegion',
\ 'javascript.jsx': 'jsxRegion',
\ }
" Shortcut for closing tags, default is '>'
"
let g:closetag_shortcut = '>'
" Add > at current position without closing the current tag, default is ''
"
let g:closetag_close_shortcut = '<leader>>'
" Configure python executable
" Set autformat shortcut to F3
" Disable autoformat
" See https://github.com/Chiel92/vim-autoformat
let g:python3_host_prog = '/usr/bin/python3'
noremap <F3> :Autoformat<CR>
let g:autoformat_autoindent = 0
let g:autoformat_retab = 0
let g:autoformat_remove_trailing_spaces = 0
" Sets the line number
" See https://www.cyberciti.biz/faq/vi-show-line-numbers/
set number
" Options for handling tabs and spacing
" " See
" https://stackoverflow.com/questions/2054627/how-do-i-change-tab-size-in-vim/40008101
" " Also https://tedlogan.com/techblog3.html
autocmd Filetype xml setlocal softtabstop=4
autocmd Filetype xml setlocal shiftwidth=4
autocmd Filetype xml setlocal expandtab
autocmd Filetype java setlocal softtabstop=4
autocmd Filetype java setlocal shiftwidth=4
autocmd Filetype java setlocal expandtab
autocmd Filetype yml setlocal softtabstop=2
autocmd Filetype yml setlocal shiftwidth=2
autocmd Filetype yml setlocal expandtab
autocmd Filetype yaml setlocal softtabstop=2
autocmd Filetype yaml setlocal shiftwidth=2
autocmd Filetype yaml setlocal expandtab
autocmd Filetype json setlocal softtabstop=2
autocmd Filetype json setlocal shiftwidth=2
autocmd Filetype json setlocal expandtab
" Allow copying from xclip easily
" F7 to copy current buffer to clipboard
" Shift + F7 to paste current buffer content
" See https://vim.fandom.com/wiki/GNU/Linux_clipboard_copy/paste_with_xclip
" And https://vim.fandom.com/wiki/Get_the_name_of_the_current_file
" And https://unix.stackexchange.com/questions/22494/copy-file-to-xclip-and-paste-to-firefox
nnoremap <F7> :w !xclip -sel clip < %:p<CR><CR>
nnoremap <S-F7> :r!xclip -o<CR>
" Open Vexplore
nnoremap <F2> :Vexplore<CR>
" Make Vexplore open in previous window
" To go to previous buffer, use ctrl + o
let g:netrw_browse_split = 4
" Size of netrw: 25%
" See https://shapeshed.com/vim-netrw/
let g:netrw_winsize = 25
" Close explorer
" See https://stackoverflow.com/questions/27691792/vim-quit-close-netrw-without-selecting-any-file
function! s:close_explorer_buffers()
for i in range(1, bufnr('$'))
if getbufvar(i, '&filetype') == "netrw"
silent exe 'bdelete! ' . i
endif
endfor
endfunction
nnoremap <C-e><C-x> :call <sid>close_explorer_buffers()<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment