Skip to content

Instantly share code, notes, and snippets.

@Awlexus
Created July 4, 2019 19:10
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 Awlexus/4c1bfbf1d1df85cd02d6f2d6102265db to your computer and use it in GitHub Desktop.
Save Awlexus/4c1bfbf1d1df85cd02d6f2d6102265db to your computer and use it in GitHub Desktop.
my (neo)vimrc
let mapleader =","
call plug#begin('~/.config/nvim/plugged')
Plug 'tpope/vim-surround'
Plug 'scrooloose/nerdtree'
Plug 'junegunn/goyo.vim'
Plug 'PotatoesMaster/i3-vim-syntax'
Plug 'jreybert/vimagit'
" Plug 'LukeSmithxyz/vimling'
Plug 'kien/ctrlp.vim'
Plug 'vimwiki/vimwiki'
Plug 'bling/vim-airline'
Plug 'tpope/vim-commentary'
Plug 'sheerun/vim-polyglot'
Plug 'slashmili/alchemist.vim'
Plug 'mhinz/vim-mix-format'
Plug 'airblade/vim-gitgutter'
Plug 'mattn/emmet-vim'
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'anned20/vimsence'
Plug 'janko/vim-test'
Plug 'andyl/vim-textobj-elixir'
Plug 'kana/vim-textobj-user'
call plug#end()
set bg=light
set mouse=a
set nohlsearch
set clipboard=unnamedplus
" Some basics:
set nocompatible
filetype plugin on
syntax on
set encoding=utf-8
set number relativenumber
" Save create parent dir if it doesn't exist
augroup Mkdir
autocmd!
autocmd BufWritePre *
\ if !isdirectory(expand("<afile>:p:h")) |
\ call mkdir(expand("<afile>:p:h"), "p") |
\ endif
augroup END
" Nerdtree helper
nnoremap <leader>p :NERDTreeFind <c-R>%<Enter>
" Enable autocompletion:
" set wildmode=longest,list,full
let g:deoplete#enable_at_startup = 1
" Disables automatic commenting on newline:
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
autocmd BufWritePost ~/.vimrc source %
" Goyo plugin makes text more readable when writing prose:
map <leader>f :Goyo \| set bg=light \| set linebreak<CR>
" Splits open at the bottom and right, which is non-retarded, unlike vim defaults.
set splitbelow splitright
" Nerd tree
map <C-n> :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" ctrlp:
set wildignore+=*/node_modules/*,*/deps/*,*/tmp/*
" emmet:
let g:user_emmet_leader_key='<Tab>'
let g:user_emmet_install_global = 0
autocmd FileType html,css,eelixir EmmetInstall
" Shortcutting split navigation, saving a keypress:
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" Replace all is aliased to S.
nnoremap S :%s//g<Left><Left>
" Runs a script that cleans out tex build files whenever I close out of a .tex file.
autocmd VimLeave *.tex !texclear %
" Ensure files are read as what I want:
let g:vimwiki_ext2syntax = {'.Rmd': 'markdown', '.rmd': 'markdown','.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'}
let g:vimwiki_list = [{'path': '~/vimwiki', 'syntax': 'markdown', 'ext': '.md'}]
autocmd BufRead,BufNewFile /tmp/calcurse*,~/.calcurse/notes/* set filetype=markdown
autocmd BufRead,BufNewFile *.ms,*.me,*.mom,*.man set filetype=groff
autocmd BufRead,BufNewFile *.tex set filetype=tex
" Enable Goyo by default for mutt writting
" Goyo's width will be the line limit in mutt.
autocmd BufRead,BufNewFile /tmp/neomutt* let g:goyo_width=80
autocmd BufRead,BufNewFile /tmp/neomutt* :Goyo \| set bg=light
" Automatically deletes all trailing whitespace on save.
autocmd BufWritePre * %s/\s\+$//e
" Run xrdb whenever Xdefaults or Xresources are updated.
autocmd BufWritePost ~/.Xresources,~/.Xdefaults !xrdb %
" Navigating with guides
inoremap <leader><leader> <Esc>/<++><Enter>"_c4l
vnoremap <leader><leader> <Esc>/<++><Enter>"_c4l
map <leader><leader> <Esc>/<++><Enter>"_c4l
" Elixir
autocmd FileType elixir,eelixir inoremap ,defmod<space> defmodule do<Enter><++><Enter>end<esc>?defmodule?e<Enter>a<space>
autocmd FileType elixir,eelixir inoremap ,def<space> def do<Enter><++><Enter>end<esc>?def?e<Enter>a<space>
autocmd FileType elixir,eelixir inoremap ,defp<space> defp do<Enter><++><Enter>end<esc>?defp?e<Enter>a<space>
autocmd FileType elixir,eelixir inoremap ,defmacro<space> defmacro do<Enter><++><Enter>end<esc>?defmacro?e<Enter>a<space>
autocmd FileType elixir,eelixir inoremap ,defmacrop<space> defmacrop do<Enter><++><Enter>end<esc>?defmacrop?e<Enter>a<space>
autocmd FileType elixir,eelixir inoremap ,ok<space> {:ok, }<space><++><esc>2bi
autocmd FileType elixir,eelixir inoremap ,error<space> {:error, }<space><++><esc>2bi
autocmd FileType elixir,eelixir inoremap ,call<space> def handle_call() do<Enter><++><Enter>end<esc>?handle_call(?e<Enter>a
autocmd FileType elixir,eelixir inoremap ,cast<space> def handle_cast() do<Enter><++><Enter>end<esc>?handle_cast(?e<Enter>a
autocmd FileType elixir,eelixir inoremap ,case<space> case do<Enter><++><Enter>end<esc>2kea<space>
" autocmd FileType elixir set fdm=indent
" autocmd FileType elixir set foldlevelstart=99
autocmd FileType elixir set sw=2
autocmd FileType yaml set sw=2
autocmd FileType yaml set ts=2
let g:mix_format_on_save=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment