Skip to content

Instantly share code, notes, and snippets.

@TomPretty

TomPretty/init.vim

Created Jun 17, 2020
Embed
What would you like to do?
let mapleader=','
let maplocalleader='\\'
set textwidth=79
set tabstop=2
set expandtab
set shiftwidth=2
set autoindent
set smartindent
filetype on
filetype plugin on
filetype indent on
" vim-plug plugins {{{
call plug#begin('~/.local/share/nvim/plugged')
" writting plugins
Plug 'junegunn/vader.vim'
Plug '~/code/vim-plugins/vim-todo-lists'
" git
Plug 'tpope/vim-fugitive'
" system
Plug 'tpope/vim-eunuch'
" navigation
Plug 'scrooloose/nerdtree'
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim'
Plug 'jremmen/vim-ripgrep'
Plug 'ludovicchabant/vim-gutentags'
" tmux
Plug 'christoomey/vim-tmux-navigator'
Plug 'christoomey/vim-tmux-runner'
" autocompletion
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'deoplete-plugins/deoplete-jedi'
" linter/fixer
Plug 'dense-analysis/ale'
" editing
Plug 'scrooloose/nerdcommenter'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'jiangmiao/auto-pairs'
Plug 'tmhedberg/SimpylFold'
Plug 'machakann/vim-highlightedyank'
Plug 'mattn/emmet-vim'
" slime
Plug 'jpalardy/vim-slime'
" lang
Plug 'sheerun/vim-polyglot'
Plug 'davidbalbert/vim-io'
"" ruby
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-bundler'
Plug 'kana/vim-textobj-user'
Plug 'nelstrom/vim-textobj-rubyblock'
" testing
Plug 'janko/vim-test'
" Writing
Plug 'reedes/vim-pencil'
Plug 'junegunn/goyo.vim'
Plug 'junegunn/limelight.vim'
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
Plug 'lervag/vimtex'
" colours
Plug 'morhetz/gruvbox'
call plug#end()
" }}}
" vimscript file settings {{{
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
" }}}
" {{{ basic settings
set number relativenumber
" sane splitting
set splitbelow
set splitright
" better navigation
nnoremap <c-h> <c-w>h
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-l> <c-w>l
" escape!
inoremap jk <esc>
" search
nnoremap <leader><space> :noh<cr>
nnoremap / /\v
" insert lines in normal mode
nnoremap <cr> o<esc>
" code folding
set foldmethod=indent
set foldlevel=99
nnoremap <space> za
" visualize substitution
set inccommand=nosplit
" copy and paste to clipboard
set clipboard=unnamed
" colours
set termguicolors
colorscheme gruvbox
" }}}
" leader commands {{{
" vimrc
nnoremap <leader>rc :tabe $MYVIMRC<cr>
nnoremap <leader>rs :source $MYVIMRC<cr>
" plug
nnoremap <leader>pi :PlugInstall<cr>
" shell scripting
inoremap ,sh #!/usr/bin/env
" bundle
nnoremap <leader>bu :Bundle<cr>
" rails
nnoremap <leader>vs :AV<cr>
nnoremap <leader>vm :Vmodel<cr>
nnoremap <leader>em :Emodel
nnoremap <leader>ec :Econtroller
nnoremap <leader>ev :Eview
nnoremap <leader>eh :Ehelper
iabbrev %< <% %><left><left><left>
iabbrev =< <%= %><left><left><left>
" git
nnoremap <leader>gs :Gstatus<cr>
nnoremap <leader>gc :Gcommit<cr>
nnoremap <leader>gd :Gdiff<cr>
" yell/whisper
inoremap <c-u> <esc>g~iwea
nnoremap <leader>vp :execute "rightbelow vsplit" bufname("#")<cr>
" trailing whitespace
nnoremap <leader>w :match Error /\v\s+$/<cr>
nnoremap <leader>W :match none<cr>
" }}}
" neovim {{{
let g:python_host_prog = '/Users/tpretty/.virtualenvs/neovim/bin/python'
let g:python3_host_prog = '/Users/tpretty/.virtualenvs/neovim3/bin/python'
" }}}
" nerdtree {{{
map <silent><c-n> :NERDTreeToggle<cr>
let g:NERDTreeWinPos = "right"
" }}}
" fzf {{{
nnoremap <silent> <c-z> :FZF<cr>
" }}}
" ripgrep {{{
let g:rg_derive_root = 1
let g:rg_highlight = 1
" }}}
" gutentags {{{
let g:gutentags_ctags_tagfile = '.git/tags'
" }}}
" deoplete {{{
let g:deoplete#enable_at_startup = 1
" }}}
" ale {{{
let g:ale_lint_on_save = 1
let g:ale_fix_on_save = 1
let g:ale_linters_explicit = 1
let g:ale_linter_aliases = {
\ 'svelte': ['css', 'javascript'],
\ 'javascriptreact': 'javascript',
\ }
let g:ale_linters = {
\ 'python': ['flake8'],
\ 'javascript': ['eslint'],
\ 'html': ['prettier'],
\ 'svelte': ['eslint'],
\ 'vue': ['eslint'],
\ }
let g:ale_fixers = {
\ 'python': ['isort', 'black'],
\ 'javascript': ['prettier'],
\ 'html': ['prettier'],
\ 'svelte': ['prettier'],
\ 'markdown': ['prettier'],
\ 'vue': ['eslint'],
\ }
nnoremap ]r :ALENextWrap<CR>
nnoremap [r :ALEPreviousWrap<CR>
" }}}
" nerdcommenter {{{
let g:NERDSpaceDelims = 1
let g:NERDCompactSexyComs = 1
let g:NERDDefaultAlign = 'left'
let g:NERDCommentEmptyLines = 1
let g:NERDTrimTrailingWhitespace = 1
let g:NERDToggleCheckAllLines = 1
" }}}
" vtr {{{
nnoremap <leader>va :VtrAttachToPane<cr>
nnoremap <leader>vc :VtrSendCommandToRunner<cr>
nnoremap <leader>vd :VtrSendCtrlD<cr>
nnoremap <leader>osr :VtrOpenRunner {'orientation': 'h', 'percentage': 50}<CR>
nnoremap <leader>irb :VtrOpenRunner {'orientation': 'h', 'percentage': 50, 'cmd': 'irb'}<cr>
noremap <c-f> :VtrSendLinesToRunner<cr>
"}}}
" vim-test {{{
nnoremap <silent> <Leader>t :TestFile<CR>
nnoremap <silent> <Leader>s :TestNearest<CR>
nnoremap <silent> <Leader>l :TestLast<CR>
nnoremap <silent> <Leader>a :TestSuite<CR>
let test#ruby#rspec#executable = 'rspec'
let test#python#runner = 'pytest'
" }}}
" vim-markdown {{{
let g:vim_markdown_auto_insert_bullets = 0
" }}}
" TODO: remap these into a ftplugin using localleader
" markdown-preview {{{
nmap <C-s> <Plug>MarkdownPreview
nmap <M-s> <Plug>MarkdownPreviewStop
nmap <C-p> <Plug>MarkdownPreviewToggle
" }}}
" vim-slime {{{
let g:slime_target = "tmux"
let g:slime_default_config = {"socket_name": "default", "target_pane": "1"}
" }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.