Skip to content

Instantly share code, notes, and snippets.

@jli
Created July 10, 2020 15:02
Show Gist options
  • Save jli/1a9fd1f6a72d5f9fa69e114e59057735 to your computer and use it in GitHub Desktop.
Save jli/1a9fd1f6a72d5f9fa69e114e59057735 to your computer and use it in GitHub Desktop.
basic neovim config
" .config/nvim/init.vim
syntax on
""" basics
set ignorecase
set smartcase
set shiftwidth=2
set expandtab
set scrolloff=5
set sidescrolloff=5
set splitbelow
set splitright
" makes gitgutter work much faster
set updatetime=250
""" plugins
" install:
" sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
call plug#begin('~/.vim/plugged')
Plug 'airblade/vim-gitgutter'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'machakann/vim-highlightedyank'
Plug 'reedes/vim-pencil'
Plug 'tpope/vim-surround'
" bizarre fold behavior. ugh.
"Plug 'plasticboy/vim-markdown'
" too slow. ugh.
"Plug 'gabrielelana/vim-markdown'
call plug#end()
highlight SignColumn ctermbg=black
highlight GitGutterAdd guifg=#009900 ctermfg=2 ctermbg=black
highlight GitGutterChange guifg=#bbbb00 ctermfg=3 ctermbg=black
highlight GitGutterDelete guifg=#ff2222 ctermfg=1 ctermbg=black
let g:highlightedyank_highlight_duration = 175
" https://github.com/reedes/vim-pencil#initializing-by-file-type
augroup pencil
autocmd!
autocmd FileType markdown,mkd call pencil#init()
autocmd FileType text call pencil#init()
augroup END
let g:pencil#wrapModeDefault = 'soft'
let g:pencil#conceallevel = 0
" needed to make 'x' work normally: https://github.com/reedes/vim-pencil/issues/76
let g:pencil#cursorwrap = 0
" too slow. disabled.
" let g:markdown_enable_spell_checking = 0
" pretty buggy. doesn't work when next to other puncuation, etc.
" let g:markdown_enable_conceal = 1
" no way to enable folding but don't fold by default..? maybe in vim options.
" wow totally insane performance hit.
" let g:markdown_enable_folding = 0
""" note taking
" TODO: limit this to just markdown files
highlight WikiLink ctermfg=lightblue cterm=underline
2match WikiLink /\[\[[^\]]*\]\]/
let g:markdown_folding = 1
set foldlevel=1
""" keybindings
" <c-l> clear highlight
" https://github.com/tpope/vim-sensible/blob/master/plugin/sensible.vim
nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
" fzf bindings
map <M-p> :Files<CR>
map <M-b> :Buffers<CR>
" probably not necessary..?
map <M-S-p> :GFiles<CR>
" insert date and time stamps
" http://www.cplusplus.com/reference/ctime/strftime/
nnoremap <C-s>d "=strftime("%F")<CR>P
inoremap <C-s>d <C-R>=strftime("%F")<CR>
nnoremap <C-s>t "=strftime("%T")<CR>P
inoremap <C-s>t <C-R>=strftime("%T")<CR>
nnoremap <C-s>D "=strftime("%F %T")<CR>P
inoremap <C-s>D <C-R>=strftime("%F %T")<CR>
" gf opens file if doesn't exist
map gf :e <cfile><CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment