Skip to content

Instantly share code, notes, and snippets.

@TomPretty TomPretty/init.vim
Created Oct 9, 2019

Embed
What would you like to do?
Neovim init file
let mapleader=','
set textwidth=79
set tabstop=2
set expandtab
set shiftwidth=2
set autoindent
set smartindent
filetype on
filetype plugin on
filetype indent on
call plug#begin('~/.local/share/nvim/plugged')
" navigation
Plug 'scrooloose/nerdtree'
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim'
Plug 'jremmen/vim-ripgrep'
" autocompletion
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'deoplete-plugins/deoplete-jedi'
" syntax checking
Plug 'dense-analysis/ale'
" editing
Plug 'scrooloose/nerdcommenter'
Plug 'tpope/vim-surround'
Plug 'jiangmiao/auto-pairs'
" lang
Plug 'sheerun/vim-polyglot'
" 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'
" snippets
Plug 'mattn/emmet-vim'
" colours
Plug 'morhetz/gruvbox'
call plug#end()
" some basics
set number relativenumber
" sane splitting
set splitbelow
set splitright
" better navigation
map <c-h> <c-w>h
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
" escape the escape!
inoremap jk <esc>
" better move lines
nnoremap ∆ :m .+1<CR>==
nnoremap ˚ :m .-2<CR>==
inoremap<Esc>:m .+1<CR>==gi
inoremap ˚ <Esc>:m .-2<CR>==gi
vnoremap ∆ :m '>+1<CR>gv=gv
vnoremap ˚ :m '<-2<CR>gv=gv
" clear search
map <leader><space> :noh<cr>
" insert lines in normal mode
nmap <s-enter> O<esc>
nmap <cr> o<esc>
" colours
set termguicolors
colorscheme gruvbox
" neovim {{{
let g:python_host_prog = '/Users/tpretty/.pyenv/versions/neovim2/bin/python'
let g:python3_host_prog = '/Users/tpretty/.pyenv/versions/neovim3/bin/python'
" }}}
" deoplete {{{
let g:deoplete#enable_at_startup = 1
" }}}
" fzf {{{
nnoremap <silent> <C-z> :FZF<CR>
" }}}
" nerdcommenter {{{
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
" Enable NERDCommenterToggle to check all selected lines is commented or not
let g:NERDToggleCheckAllLines = 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']}
let g:ale_linters = {
\ 'javascript': ['eslint'],
\ 'svelte': ['eslint'],
\ 'vue': ['eslint'],
\ }
let g:ale_fixers = {
\ 'javascript': ['prettier'],
\ 'svelte': ['prettier'],
\ 'markdown': ['prettier'],
\ 'vue': ['eslint'],
\ }
" }}}
" nerdtree {{{
map <C-n> :NERDTreeToggle<CR>
" }}}
" ripgrep {{{
let g:rg_derive_root = 1
let g:rg_highlight = 1
" }}}
" goyo {{{
function! s:goyo_enter()
if executable('tmux') && strlen($TMUX)
silent !tmux set status off
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
endif
set noshowmode
set noshowcmd
set scrolloff=999
Limelight
endfunction
function! s:goyo_leave()
if executable('tmux') && strlen($TMUX)
silent !tmux set status on
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
endif
set showmode
set showcmd
set scrolloff=5
Limelight!
endfunction
" autocmd! User GoyoEnter nested call <SID>goyo_enter()
" autocmd! User GoyoLeave nested call <SID>goyo_leave()
autocmd! User GoyoEnter Limelight
autocmd! User GoyoLeave Limelight!
nmap <leader>g :Goyo<cr>
" }}}
" vimtex {{{
let g:vimtex_view_method='skim'
" }}}
" markdown-preview {{{
nmap <C-s> <Plug>MarkdownPreview
nmap <M-s> <Plug>MarkdownPreviewStop
nmap <C-p> <Plug>MarkdownPreviewToggle
" }}}
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.