Factor notes into plugin
This commit is contained in:
parent
d645160b4b
commit
c3f3999e02
4 changed files with 75 additions and 167 deletions
|
@ -1,78 +1,3 @@
|
||||||
snippet note "Note Front Matter" b
|
|
||||||
---
|
|
||||||
title: "${1:Title}"
|
|
||||||
author: "${2:Max Bucknell}"
|
|
||||||
date: "${3:`date "+%A, %e, %B %Y"`}"
|
|
||||||
format:
|
|
||||||
html:
|
|
||||||
embed-resources: true
|
|
||||||
html-math-method: katex
|
|
||||||
mainfont: Lato
|
|
||||||
monofont: Input
|
|
||||||
theme:
|
|
||||||
light: flatly
|
|
||||||
dark: darkly
|
|
||||||
pdf:
|
|
||||||
documentclass: article
|
|
||||||
mainfont: Lato
|
|
||||||
monofont: Input
|
|
||||||
geometry:
|
|
||||||
- top=30mm
|
|
||||||
- left=20mm
|
|
||||||
- heightrounded
|
|
||||||
number-sections: true
|
|
||||||
---
|
|
||||||
|
|
||||||
# $1
|
|
||||||
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet :::n "Callout: Note" b
|
|
||||||
::: {.callout-note}
|
|
||||||
${0:${VISUAL:text...}}
|
|
||||||
:::
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet :::t "Callout: Tip" b
|
|
||||||
::: {.callout-tip}
|
|
||||||
${0:${VISUAL:text...}}
|
|
||||||
:::
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet :::w "Callout: Warning" b
|
|
||||||
::: {.callout-warning}
|
|
||||||
${0:${VISUAL:text...}}
|
|
||||||
:::
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet :::i "Callout: Important" b
|
|
||||||
::: {.callout-important}
|
|
||||||
${0:${VISUAL:text...}}
|
|
||||||
:::
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet `r "R Code Block" b
|
|
||||||
\`\`\`{r}
|
|
||||||
${1:#| output: ${2:false}}
|
|
||||||
${0:${VISUAL:# code...}}
|
|
||||||
\`\`\`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet `py "Python Code Block" b
|
|
||||||
\`\`\`{python}
|
|
||||||
${1:#| output: ${2:false}}
|
|
||||||
${0:${VISUAL:# code...}}
|
|
||||||
\`\`\`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet `ju "Julia Code Block" b
|
|
||||||
\`\`\`{julia}
|
|
||||||
${1:#| output: ${2:false}}
|
|
||||||
${0:${VISUAL:# code...}}
|
|
||||||
\`\`\`
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet todo "Make a To-Do List!" b
|
snippet todo "Make a To-Do List!" b
|
||||||
- [ ] ${0:What would you like to do..?}
|
- [ ] ${0:What would you like to do..?}
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
syn region quartoCalloutNote start=":::\s\+{\.callout-note\s*" end=":::$" keepend
|
|
||||||
syn region quartoCalloutWarning start=":::\s\+{\.callout-warning\s*" end=":::$" keepend
|
|
||||||
syn region quartoCalloutImportant start=":::\s\+{\.callout-important\s*" end=":::$" keepend
|
|
||||||
syn region quartoCalloutTip start=":::\s\+{\.callout-tip\s*" end=":::$" keepend
|
|
||||||
syn region quartoCalloutCaution start=":::\s\+{\.callout-caution\s*" end=":::$" keepend
|
|
|
@ -29,34 +29,36 @@ let s:is_dark=(&background == 'dark')
|
||||||
|
|
||||||
" \ 'mpwb_green': '#20A92E',
|
" \ 'mpwb_green': '#20A92E',
|
||||||
call extend(v:colornames, {
|
call extend(v:colornames, {
|
||||||
\ 'mpwb_fg': '#201C22',
|
\ 'mpwb_light': '#e7e3e9',
|
||||||
\ 'mpwb_bg': '#E7E3E9',
|
\ 'mpwb_dark': '#201c22',
|
||||||
\ 'mpwb_tintbg': '#FCF7FE',
|
\ 'mpwb_fg': '#201c22',
|
||||||
\ 'mpwb_red': '#AD1C22',
|
\ 'mpwb_bg': '#e7e3e9',
|
||||||
\ 'mpwb_orange': '#AF5F27',
|
\ 'mpwb_tintbg': '#fcf7fe',
|
||||||
\ 'mpwb_yellow': '#AD9622',
|
\ 'mpwb_red': '#ad1c22',
|
||||||
\ 'mpwb_green': '#20A951',
|
\ 'mpwb_orange': '#af5f27',
|
||||||
\ 'mpwb_cyan': '#20A9AE',
|
\ 'mpwb_yellow': '#ad9622',
|
||||||
\ 'mpwb_blue': '#2059AF',
|
\ 'mpwb_green': '#20a951',
|
||||||
\ 'mpwb_purple': '#721CAF',
|
\ 'mpwb_cyan': '#20a9ae',
|
||||||
\ 'mpwb_magenta': '#AB177B',
|
\ 'mpwb_blue': '#2059af',
|
||||||
\ 'mpwb_callout_note': '#CCD7E8',
|
\ 'mpwb_purple': '#721caf',
|
||||||
\ 'mpwb_callout_tip': '#D2E8CC',
|
\ 'mpwb_magenta': '#ab177b',
|
||||||
\ 'mpwb_callout_important': '#E8CCCC',
|
\ 'mpwb_callout_note': '#ccd7e8',
|
||||||
\ 'mpwb_callout_warning': '#E8E3CC',
|
\ 'mpwb_callout_tip': '#d2e8cc',
|
||||||
|
\ 'mpwb_callout_important': '#e8cccc',
|
||||||
|
\ 'mpwb_callout_warning': '#e8e3cc',
|
||||||
\ 'mpwb_cursorline': '#c6c2c8'
|
\ 'mpwb_cursorline': '#c6c2c8'
|
||||||
\ }, 'force')
|
\ }, 'force')
|
||||||
|
|
||||||
if s:is_dark
|
if s:is_dark
|
||||||
call extend(v:colornames, {
|
call extend(v:colornames, {
|
||||||
\ 'mpwb_fg': '#E7E3E9',
|
\ 'mpwb_fg': '#e7e3e9',
|
||||||
\ 'mpwb_bg': '#201C22',
|
\ 'mpwb_bg': '#201c22',
|
||||||
\ 'mpwb_tintbg': '#3B3440',
|
\ 'mpwb_tintbg': '#3b3440',
|
||||||
\ 'mpwb_callout_note': '#002A68',
|
\ 'mpwb_callout_note': '#002a68',
|
||||||
\ 'mpwb_callout_tip': '#156800',
|
\ 'mpwb_callout_tip': '#156800',
|
||||||
\ 'mpwb_callout_important': '#680000',
|
\ 'mpwb_callout_important': '#680000',
|
||||||
\ 'mpwb_callout_warning': '#685700',
|
\ 'mpwb_callout_warning': '#685700',
|
||||||
\ 'mpwb_cursorline': '#29242C',
|
\ 'mpwb_cursorline': '#29242c',
|
||||||
\ }, 'force')
|
\ }, 'force')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -91,9 +93,13 @@ hi! link MatchParen Search
|
||||||
|
|
||||||
" Chrome is purple
|
" Chrome is purple
|
||||||
hi VertSplit guifg=mpwb_purple cterm=NONE
|
hi VertSplit guifg=mpwb_purple cterm=NONE
|
||||||
hi StatusLine guifg=mpwb_purple cterm=bold
|
hi StatusLine guibg=mpwb_light guifg=mpwb_purple
|
||||||
hi StatusLineNC guifg=mpwb_purple cterm=NONE
|
hi StatusLineNC guifg=mpwb_purple cterm=NONE
|
||||||
|
|
||||||
|
hi TabLine guifg=mpwb_purple guibg=mpwb_bg
|
||||||
|
hi TabLineFill guibg=mpwb_bg guifg=mpwb_purple cterm=underline
|
||||||
|
hi TabLinesel guibg=mpwb_purple guifg=mpwb_light
|
||||||
|
|
||||||
hi Visual guibg=mpwb_fg guifg=mpwb_bg
|
hi Visual guibg=mpwb_fg guifg=mpwb_bg
|
||||||
|
|
||||||
hi LineNr cterm=NONE guifg=mpwb_purple
|
hi LineNr cterm=NONE guifg=mpwb_purple
|
||||||
|
@ -121,7 +127,7 @@ hi LspSigActiveParameter cterm=bold guifg=mpwb_bg guibg=mpwb_purple
|
||||||
hi pandocBlockQuote cterm=NONE guifg=mpwb_fg
|
hi pandocBlockQuote cterm=NONE guifg=mpwb_fg
|
||||||
hi link elixirUnusedVariable Normal
|
hi link elixirUnusedVariable Normal
|
||||||
|
|
||||||
" Notes in Quarto
|
" Notes
|
||||||
|
|
||||||
hi Title cterm=bold guifg=mpwb_fg
|
hi Title cterm=bold guifg=mpwb_fg
|
||||||
hi link pandocAtxHeaderMark Title
|
hi link pandocAtxHeaderMark Title
|
||||||
|
@ -131,9 +137,9 @@ hi link pandocDelimitedCodeBlockLanguage Normal
|
||||||
hi pandocBlockQuote cterm=italic
|
hi pandocBlockQuote cterm=italic
|
||||||
hi pandocHRule guibg=mpwb_tintbg
|
hi pandocHRule guibg=mpwb_tintbg
|
||||||
|
|
||||||
hi quartoCalloutNote guibg=mpwb_callout_note
|
hi mbnCalloutNote guibg=mpwb_callout_note
|
||||||
hi quartoCalloutWarning guibg=mpwb_callout_warning
|
hi mbnCalloutWarning guibg=mpwb_callout_warning
|
||||||
hi quartoCalloutImportant guibg=mpwb_callout_important
|
hi mbnCalloutImportant guibg=mpwb_callout_important
|
||||||
hi quartoCalloutTip guibg=mpwb_callout_tip
|
hi mbnCalloutTip guibg=mpwb_callout_tip
|
||||||
hi quartoCalloutCaution guibg=mpwb_callout_warning
|
hi mbnCalloutCaution guibg=mpwb_callout_warning
|
||||||
|
|
||||||
|
|
|
@ -19,13 +19,11 @@ Plug 'tpope/vim-fugitive'
|
||||||
Plug 'tpope/vim-repeat'
|
Plug 'tpope/vim-repeat'
|
||||||
Plug 'tpope/vim-surround'
|
Plug 'tpope/vim-surround'
|
||||||
|
|
||||||
|
Plug 'arthurxavierx/vim-caser'
|
||||||
|
|
||||||
Plug '/opt/homebrew/opt/fzf'
|
Plug '/opt/homebrew/opt/fzf'
|
||||||
Plug 'junegunn/fzf.vim'
|
Plug 'junegunn/fzf.vim'
|
||||||
|
|
||||||
Plug 'SirVer/ultisnips'
|
|
||||||
Plug 'dense-analysis/ale'
|
|
||||||
Plug 'prabirshrestha/asyncomplete.vim'
|
|
||||||
|
|
||||||
Plug 'vim-pandoc/vim-pandoc-syntax'
|
Plug 'vim-pandoc/vim-pandoc-syntax'
|
||||||
Plug 'quarto-dev/quarto-vim'
|
Plug 'quarto-dev/quarto-vim'
|
||||||
|
|
||||||
|
@ -35,6 +33,12 @@ Plug 'elixir-editors/vim-elixir'
|
||||||
|
|
||||||
Plug 'bullets-vim/bullets.vim'
|
Plug 'bullets-vim/bullets.vim'
|
||||||
|
|
||||||
|
Plug 'maxbucknell/vim-mbnotes'
|
||||||
|
|
||||||
|
Plug 'SirVer/ultisnips'
|
||||||
|
Plug 'dense-analysis/ale'
|
||||||
|
Plug 'prabirshrestha/asyncomplete.vim'
|
||||||
|
|
||||||
plug#end()
|
plug#end()
|
||||||
|
|
||||||
# Language config
|
# Language config
|
||||||
|
@ -251,11 +255,23 @@ enddef
|
||||||
|
|
||||||
# Notes config
|
# Notes config
|
||||||
|
|
||||||
|
g:mbnotes_dir = $HOME .. "/Dropbox (Maestral)/Notes"
|
||||||
|
g:mbnotes_out_dir = g:mbnotes_dir .. "/_output"
|
||||||
|
g:mbnotes_open_daily_on_startup = true
|
||||||
|
g:mbnotes_renderer_show = true
|
||||||
|
g:mbnotes_renderer_close_on_end = true
|
||||||
|
|
||||||
|
nnoremap <leader>t :MBNotesDaily<cr>
|
||||||
|
nnoremap <leader>n :MBNotes<cr>
|
||||||
|
nnoremap <c-n> :MBNotesNew<cr>
|
||||||
|
nnoremap <c-x> :MBNotesNewSplit<cr>
|
||||||
|
nnoremap <c-v> :vertical MBNotesNewSplit<cr>
|
||||||
|
|
||||||
g:markdown_fenced_languages = ['r', 'elixir', 'python', 'html', 'rust']
|
g:markdown_fenced_languages = ['r', 'elixir', 'python', 'html', 'rust']
|
||||||
g:pandoc#syntax#codeblocks#embeds#langs = ['r', 'elixir', 'python', 'html', 'rust']
|
g:pandoc#syntax#codeblocks#embeds#langs = ['r', 'elixir', 'python', 'html', 'rust']
|
||||||
|
|
||||||
# Enable bullets.vim in Quarto files
|
# Enable bullets.vim in Quarto files
|
||||||
g:bullets_enabled_file_types = ['markdown', 'text', 'gitcommit', 'quarto']
|
g:bullets_enabled_file_types = ['markdown', 'text', 'gitcommit', 'quarto', 'mbnotes', 'mbnotes.quarto']
|
||||||
# Disable the bullet changing on indents (for now)
|
# Disable the bullet changing on indents (for now)
|
||||||
g:bullets_outline_levels = ['num', 'std-']
|
g:bullets_outline_levels = ['num', 'std-']
|
||||||
|
|
||||||
|
@ -324,13 +340,16 @@ def EditCodeBlock()
|
||||||
|
|
||||||
# Set file type, if it is correctly annotated
|
# Set file type, if it is correctly annotated
|
||||||
if @f != '`'
|
if @f != '`'
|
||||||
execute 'set filetype=' .. @f
|
@f = substitute(@f, "[\{\}]", "", "g")
|
||||||
|
execute 'setf=' .. @f
|
||||||
endif
|
endif
|
||||||
|
|
||||||
set nomodified
|
set nomodified
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def SaveCodeBlock()
|
command -nargs=0 EditCodeBlock EditCodeBlock()
|
||||||
|
|
||||||
|
def g:SaveCodeBlock()
|
||||||
var b = bufnr("%")
|
var b = bufnr("%")
|
||||||
silent :%yank c
|
silent :%yank c
|
||||||
normal! mc
|
normal! mc
|
||||||
|
@ -345,67 +364,25 @@ enddef
|
||||||
augroup CodeBlocks
|
augroup CodeBlocks
|
||||||
autocmd!
|
autocmd!
|
||||||
|
|
||||||
autocmd BufWriteCmd *.codeblock <ScriptCmd>SaveCodeBlock()
|
autocmd BufWriteCmd *.codeblock g:SaveCodeBlock()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
augroup Notes
|
augroup Notes
|
||||||
# autocmd Filetype quarto setl tw=80 fo+=croqt ts=4 sts=4 sw=4 comments=n:>
|
autocmd!
|
||||||
|
|
||||||
# Surround mappings for Quarto callouts
|
autocmd FileType mbnotes imap <buffer> <tab> <c-r>=g:Ultisnips_expand("\<c-t>")<cr>
|
||||||
autocmd FileType quarto b:surround_110 = "::: {.callout-note}\n\r\n:::"
|
autocmd FileType mbnotes imap <buffer> <s-tab> <c-d>
|
||||||
autocmd FileType quarto b:surround_116 = "::: {.callout-tip}\n\r\n:::"
|
|
||||||
autocmd FileType quarto b:surround_119 = "::: {.callout-warning}\n\r\n:::"
|
|
||||||
autocmd FileType quarto b:surround_105 = "::: {.callout-important}\n\r\n:::"
|
|
||||||
|
|
||||||
autocmd FileType quarto imap <buffer> <tab> <c-r>=g:Ultisnips_expand("\<c-t>")<cr>
|
autocmd FileType mbnotes onoremap <expr> cb :<c-u>execute "normal! /^```\rk$ms?^```\rj:noh\rv`s"<cr>
|
||||||
autocmd FileType quarto imap <buffer> <s-tab> <c-d>
|
autocmd FileType mbnotes nnoremap <leader>ec :EditCodeBlock<cr>
|
||||||
|
autocmd FileType mbnotes inoremap <c-e> <esc>:EditCodeBlock<cr>
|
||||||
autocmd FileType quarto onoremap <expr> cb :<c-u>execute "normal! /^```\rk$ms?^```\rj:noh\rv`s"<cr>
|
|
||||||
autocmd FileType quarto nnoremap <expr> <leader>ec <ScriptCmd>EditCodeBlock()<cr>
|
|
||||||
autocmd FileType quarto inoremap <expr> <c-e> <esc><ScriptCmd>EditCodeBlock()<cr>
|
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
nnoremap <leader>x :silent keepp s/^- \[ \]/- [o]/e<cr>:silent keepp s/^- \[x\]/- [ ]/e<cr>:silent keepp s/^- \[o\]/- [x]/e<cr>
|
nnoremap <leader>x :silent keepp s/^- \[ \]/- [o]/e<cr>:silent keepp s/^- \[x\]/- [ ]/e<cr>:silent keepp s/^- \[o\]/- [x]/e<cr>
|
||||||
|
|
||||||
# Daily notes
|
|
||||||
def FormatOffset(offset: number): string
|
|
||||||
if offset == 0
|
|
||||||
return ""
|
|
||||||
elseif offset > 0
|
|
||||||
return "-v+" .. offset .. "d "
|
|
||||||
else
|
|
||||||
return "-v" .. offset .. "d "
|
|
||||||
endif
|
|
||||||
enddef
|
|
||||||
|
|
||||||
def OpenDailyNote(offset = 0)
|
|
||||||
var command = "date -v-4H " .. FormatOffset(offset) .. "\"+%Y-%m-%d\""
|
|
||||||
var date = trim(system(command))
|
|
||||||
var filename = $DAILY_NOTES_PATH .. "/" .. date .. "-daily.qmd"
|
|
||||||
|
|
||||||
if !filereadable(filename)
|
|
||||||
var template = $DAILY_NOTES_PATH .. "/template.py"
|
|
||||||
|
|
||||||
system(shellescape(template) .. " " .. shellescape(date) .. " > " .. shellescape(filename))
|
|
||||||
endif
|
|
||||||
|
|
||||||
execute "silent edit " .. filename
|
|
||||||
enddef
|
|
||||||
|
|
||||||
|
|
||||||
command -nargs=? Daily OpenDailyNote(<args>)
|
|
||||||
|
|
||||||
def StartUp()
|
|
||||||
if @% == ""
|
|
||||||
OpenDailyNote()
|
|
||||||
endif
|
|
||||||
enddef
|
|
||||||
|
|
||||||
augroup StartUp
|
augroup StartUp
|
||||||
autocmd!
|
autocmd!
|
||||||
|
|
||||||
autocmd VimEnter * ++nested StartUp()
|
|
||||||
|
|
||||||
autocmd VimResized * wincmd =
|
autocmd VimResized * wincmd =
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
@ -452,6 +429,10 @@ augroup Completion
|
||||||
autocmd!
|
autocmd!
|
||||||
|
|
||||||
autocmd User asyncomplete_setup {
|
autocmd User asyncomplete_setup {
|
||||||
|
asyncomplete#register_source(
|
||||||
|
asyncomplete#sources#mbnotes#get_source_options({ 'priority': 9 })
|
||||||
|
)
|
||||||
|
|
||||||
asyncomplete#register_source(
|
asyncomplete#register_source(
|
||||||
asyncomplete#sources#ale#get_source_options({ 'priority': 10 })
|
asyncomplete#sources#ale#get_source_options({ 'priority': 10 })
|
||||||
)
|
)
|
||||||
|
@ -468,10 +449,11 @@ def PreviewQuarto()
|
||||||
ClosePreview()
|
ClosePreview()
|
||||||
|
|
||||||
echom 'Starting preview job'
|
echom 'Starting preview job'
|
||||||
b:file = expand('%')
|
b:preview_job = job_start([
|
||||||
b:preview_job = job_start(
|
'quarto',
|
||||||
\ ['quarto', 'preview', b:file],
|
'preview',
|
||||||
\ )
|
expand('%')
|
||||||
|
])
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
def ClosePreview()
|
def ClosePreview()
|
||||||
|
|
Loading…
Add table
Reference in a new issue