Skip to content

Instantly share code, notes, and snippets.

@jdhao
Last active September 12, 2019 09:56
Show Gist options
  • Save jdhao/bdb3f49d886fc09873a493ae33fb82b4 to your computer and use it in GitHub Desktop.
Save jdhao/bdb3f49d886fc09873a493ae33fb82b4 to your computer and use it in GitHub Desktop.
Filetype plugins for Neovim
nnoremap <F9> :w <CR> :!g++ -Wall -std=c++11 % -o %<&&./%<<CR>
" Automatically save current file and execute it when pressing the <F9> key
" it is useful for small script
nnoremap <buffer> <F9> :execute 'w !python' shellescape(@%, 1)<CR>
" Only use the following character pairs for tex file
if &runtimepath =~? 'auto-pairs'
let b:AutoPairs = AutoPairsDefine({'<' : '>'})
let b:AutoPairs = {'(':')', '[':']', '{':'}', '<':'>'}
endif
set textwidth=79
" Disable inserting comment leader after hitting o or O
set formatoptions-=o
" Disable inserting comment leader after hitting <Enter> in insert mode
set formatoptions-=r
" Set the folding related options for vim script. Setting folding option
" in modeline is annoying in that the modeline get executed each time the
" window focus is lost (see http://tinyurl.com/yyqyyhnc)
set foldmethod=expr foldlevel=0 foldlevelstart=-1
\ foldexpr=utils#VimFolds(v:lnum) foldtext=utils#MyFoldText()
" Use :help command for keyword when pressing `K` in vim file,
" see `:h K` and https://bre.is/wC3Ih-26u
set keywordprg=:help
" Only define following variable if Auto-pairs plugin is used
if &runtimepath =~? 'auto-pairs'
let b:AutoPairs = AutoPairsDefine({'<' : '>'})
" Do not use `"` for vim script since `"` is also used for comment
let b:AutoPairs = {'(':')', '[':']', '{':'}', "'":"'", "`":"`", '<':'>'}
endif
@jdhao
Copy link
Author

jdhao commented Sep 12, 2019

These filetype plugins should be placed under stdpath('config')/after/ftplugin (the output of stdpath('config') is where Neovim read its configuration file).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment