Skip to content

Instantly share code, notes, and snippets.

@dsevero
Last active January 20, 2021 02:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsevero/7c1b4291bcf48d05bdf19796e8ab8259 to your computer and use it in GitHub Desktop.
Save dsevero/7c1b4291bcf48d05bdf19796e8ab8259 to your computer and use it in GitHub Desktop.
Init file for nvim and vim
call plug#begin()
Plug 'lervag/vimtex'
Plug 'manicmaniac/coconut.vim'
Plug 'goerz/jupytext.vim'
Plug 'skanehira/preview-markdown.vim'
call plug#end()
tnoremap <Esc> <C-\><C-n>
tnoremap <C-A> pwd\|xclip -selection clipboard<CR><C-\><C-n>:cd <C-r>+<CR>i
vnoremap <C-c> "+y
set number
let g:python_host_prog = '/home/dsevero/miniconda3/envs/nvim-py2718/bin/python'
let g:python3_host_prog = '/home/dsevero/miniconda3/envs/nvim-py373/bin/python'
set shell=/usr/bin/zsh
let g:tex_flavor = 'latex'
set undofile
" TEMPORARY PYTHON HIGHLIGHTING FOR JUPYTER BOOK
" Source: https://vim.fandom.com/wiki/Different_syntax_highlighting_within_regions_of_a_file
function! TextEnableCodeSnip(filetype,start,end,textSnipHl) abort
let ft=toupper(a:filetype)
let group='textGroup'.ft
if exists('b:current_syntax')
let s:current_syntax=b:current_syntax
" Remove current syntax definition, as some syntax files (e.g. cpp.vim)
" do nothing if b:current_syntax is defined.
unlet b:current_syntax
endif
execute 'syntax include @'.group.' syntax/'.a:filetype.'.vim'
try
execute 'syntax include @'.group.' after/syntax/'.a:filetype.'.vim'
catch
endtry
if exists('s:current_syntax')
let b:current_syntax=s:current_syntax
else
unlet b:current_syntax
endif
execute 'syntax region textSnip'.ft.'
\ matchgroup='.a:textSnipHl.'
\ keepend
\ start="'.a:start.'" end="'.a:end.'"
\ contains=@'.group
endfunction
au BufReadPost,BufNewFile *.md
\ call TextEnableCodeSnip('python', '```{code-cell} python', '```', 'python') |
\ call TextEnableCodeSnip('coconut', '```{code-cell} coconut', '```', 'coconut') |
\ call TextEnableCodeSnip('tex', '```{math}', '```', 'tex') |
\ call TextEnableCodeSnip('yaml', '---', '---', 'yaml')
set list
set listchars=tab:␉·,trail:␠,nbsp:⎵
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
:set number relativenumber
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
augroup END
" spell languages
set spelllang=en,cjk
terminal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment