commit
34b1b55fb9
4 changed files with 143 additions and 10 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
# Pre-amble
|
||||||
|
|
||||||
|
extends quarto, markdown, rmarkdown, pandoc
|
||||||
|
|
||||||
|
priority -1
|
||||||
|
|
||||||
|
# Header
|
||||||
|
|
||||||
snippet note "Note Front Matter" b
|
snippet note "Note Front Matter" b
|
||||||
---
|
---
|
||||||
title: "${1:Title}"
|
title: "${1:Title}"
|
||||||
|
@ -9,6 +17,8 @@ date: "${3:`!v strftime(g:mbnotes_date_format_short, localtime() + (g:mbnotes_ne
|
||||||
$0
|
$0
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
# Callouts
|
||||||
|
|
||||||
snippet :::n "Callout: Note" b
|
snippet :::n "Callout: Note" b
|
||||||
::: {.callout-note}
|
::: {.callout-note}
|
||||||
${0:${VISUAL:text...}}
|
${0:${VISUAL:text...}}
|
||||||
|
@ -33,6 +43,8 @@ ${0:${VISUAL:text...}}
|
||||||
:::
|
:::
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
|
# Code
|
||||||
|
|
||||||
snippet `r "R Code Block" b
|
snippet `r "R Code Block" b
|
||||||
\`\`\`{r}
|
\`\`\`{r}
|
||||||
${1:#| output: ${2:false}}
|
${1:#| output: ${2:false}}
|
||||||
|
@ -57,13 +69,3 @@ ${0:${VISUAL:# code...}}
|
||||||
\`\`\`
|
\`\`\`
|
||||||
endsnippet
|
endsnippet
|
||||||
|
|
||||||
snippet todo "Make a To-Do List!" b
|
|
||||||
- [ ] ${0:What would you like to do..?}
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
snippet --- "Horizontal Rule" b
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
$0
|
|
||||||
endsnippet
|
|
||||||
|
|
||||||
|
|
|
@ -114,3 +114,75 @@ export def NewNote()
|
||||||
var file = date .. "_new-note.qmd"
|
var file = date .. "_new-note.qmd"
|
||||||
execute "edit " .. g:mbnotes_dir .. "/" .. file
|
execute "edit " .. g:mbnotes_dir .. "/" .. file
|
||||||
enddef
|
enddef
|
||||||
|
|
||||||
|
export def Operator(context = {}, type: string = ''): string
|
||||||
|
if type == ''
|
||||||
|
var _context = {
|
||||||
|
"dot_command": false,
|
||||||
|
"extend_block": '',
|
||||||
|
"virtualedit": [&l:virtualedit, &g:virtualedit]
|
||||||
|
}
|
||||||
|
&operatorfunc = function(Operator, [_context])
|
||||||
|
set virtualedit=block
|
||||||
|
return 'g@'
|
||||||
|
endif
|
||||||
|
|
||||||
|
var save = {
|
||||||
|
"clipboard": &clipboard,
|
||||||
|
"selection": &selection,
|
||||||
|
"virtualedit": [&l:virtualedit, &g:virtualedit],
|
||||||
|
"register": getreginfo('m'),
|
||||||
|
"visual_marks": [getpos("'<"), getpos("'>")]
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
set clipboard= selection=inclusive virtualedit=
|
||||||
|
var commands = {
|
||||||
|
"line": "'[V']",
|
||||||
|
"char": "`[v`]",
|
||||||
|
"block": "`[\<c-V>`]",
|
||||||
|
}[type]
|
||||||
|
|
||||||
|
var [_, _, col, off] = getpos("']")
|
||||||
|
if off != 0
|
||||||
|
var vcol = getline("'[")->strpart(0, col + off)->strdisplaywidth()
|
||||||
|
|
||||||
|
if vcol >= [line("'["), '$']->virtcol() - 1
|
||||||
|
context['extend_block'] = '$'
|
||||||
|
else
|
||||||
|
context['extend_block'] = vcol .. '|'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
if context['extend_block'] != ''
|
||||||
|
commands ..= 'oO' .. context['extend_block']
|
||||||
|
endif
|
||||||
|
|
||||||
|
commands ..= '"my'
|
||||||
|
|
||||||
|
execute 'silent noautocmd keepjumps normal! ' .. commands
|
||||||
|
|
||||||
|
NewNote()
|
||||||
|
|
||||||
|
# normal! "mPG"_dd
|
||||||
|
normal! "mPG
|
||||||
|
finally
|
||||||
|
setreg('m', save['register'])
|
||||||
|
setpos("'<", save['visual_marks'][0])
|
||||||
|
setpos("'>", save['visual_marks'][1])
|
||||||
|
&clipboard = save['clipboard']
|
||||||
|
&selection = save['selection']
|
||||||
|
|
||||||
|
if context['dot_command']
|
||||||
|
&l:virtualedit = save['virtualedit'][0]
|
||||||
|
&g:virtualedit = save['virtualedit'][1]
|
||||||
|
else
|
||||||
|
&l:virtualedit = context['virtualedit'][0]
|
||||||
|
&g:virtualedit = context['virtualedit'][1]
|
||||||
|
endif
|
||||||
|
|
||||||
|
context['dot_command'] = true
|
||||||
|
endtry
|
||||||
|
|
||||||
|
return ""
|
||||||
|
enddef
|
||||||
|
|
|
@ -7,7 +7,10 @@
|
||||||
2. Setup ............................. |mbnotes-setup|
|
2. Setup ............................. |mbnotes-setup|
|
||||||
3. Configuration ..................... |mbnotes-config|
|
3. Configuration ..................... |mbnotes-config|
|
||||||
4. Commands .......................... |mbnotes-commands|
|
4. Commands .......................... |mbnotes-commands|
|
||||||
|
4.1. Operator .................... |mbnotes-operator|
|
||||||
5. Front Matter ...................... |mbnotes-front-matter|
|
5. Front Matter ...................... |mbnotes-front-matter|
|
||||||
|
6. Integrations ...................... |mbnotes-integrations|
|
||||||
|
6.1. UltiSnips ................... |mbnotes-ultisnips|
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
1. Introduction *mbnotes*
|
1. Introduction *mbnotes*
|
||||||
|
@ -214,6 +217,28 @@ results of the quarto render command that was attempted.
|
||||||
Render the current buffer as an HTML file and open it. See |:MBNotesRenderPDF|
|
Render the current buffer as an HTML file and open it. See |:MBNotesRenderPDF|
|
||||||
for details on behaviour.
|
for details on behaviour.
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
4.1 Operator *mbnotes-operator*
|
||||||
|
|
||||||
|
New notes can be created from any text within Vim. These will be put into a new
|
||||||
|
note as created by `:MBNotesNew`, which will be opened.
|
||||||
|
|
||||||
|
*gb*
|
||||||
|
gb{motion} Yank the text that {motion} moves over and put it into a
|
||||||
|
new note buffer.
|
||||||
|
|
||||||
|
*gbb*
|
||||||
|
gbb Yank the current line into a new note buffer.
|
||||||
|
|
||||||
|
*v_gb*
|
||||||
|
{Visual}gb Yank the highlighted text into a new note buffer (for
|
||||||
|
{Visual} see |Visual-mode|).
|
||||||
|
|
||||||
|
These mappings are only set if `gb` is not already mapped to something. If they
|
||||||
|
are, or if you wish to customise these mappings, create new normal and visual
|
||||||
|
mode mappings (`nmap` and `xmap`) to `<Plug>MBNotesNew`, and a normal mode
|
||||||
|
mapping to `<Plug>MBNotesNewLine`.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
5. Front Matter *mbnotes-front-matter*
|
5. Front Matter *mbnotes-front-matter*
|
||||||
|
|
||||||
|
@ -245,4 +270,28 @@ Anything supported by Quarto can be specified here and will be imported and
|
||||||
merged with any front matter specified at the top of any file. See the Quarto
|
merged with any front matter specified at the top of any file. See the Quarto
|
||||||
docs for more information, specifically on projects.
|
docs for more information, specifically on projects.
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
6. Integrations *mbnotes-integrations*
|
||||||
|
|
||||||
|
There are many different plugins that I use to help my notes work better. I
|
||||||
|
have packaged some of the integrations in this plugin, such that they will load
|
||||||
|
if those plugin are installed.
|
||||||
|
|
||||||
|
==============================================================================
|
||||||
|
6.1. Snippets *mbnotes-ultisnips*
|
||||||
|
|
||||||
|
This plugin packages a few UltiSnips snippets out of the box. These facilitate
|
||||||
|
creating Quarto front matter with a date and title, callout blocks (as per the
|
||||||
|
Quarto documentation), and fenced code blocks that Quarto will execute.
|
||||||
|
|
||||||
|
If you use UltiSnips and would not like these, create a file called
|
||||||
|
`mbnotes.snippets` in your snippets directory, and include a line: >snippets
|
||||||
|
|
||||||
|
clearsnippets
|
||||||
|
|
||||||
|
The snippets vended by this plugin are at priority -1, so should be cleared by
|
||||||
|
a default priority instruction. Furthermore, any of these snippets can be very
|
||||||
|
easily overwritten. See the `priority` keyword in |ultisnips-basic-syntax| for
|
||||||
|
more information.
|
||||||
|
|
||||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||||
|
|
|
@ -100,4 +100,14 @@ command -nargs=0 MBNotesNewSplit {
|
||||||
mbnotes.NewNote()
|
mbnotes.NewNote()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nnoremap <expr> <Plug>MBNotesNew <SID>mbnotes.Operator()
|
||||||
|
xnoremap <expr> <Plug>MBNotesNew <SID>mbnotes.Operator()
|
||||||
|
nnoremap <expr> <Plug>MBNotesNewLine <SID>mbnotes.Operator() .. '_'
|
||||||
|
|
||||||
|
if !hasmapto('<Plug>MBNotesNew') || maparg('gb', 'n') ==# ''
|
||||||
|
nmap gb <Plug>MBNotesNew
|
||||||
|
xmap gb <Plug>MBNotesNew
|
||||||
|
nmap gbb <Plug>MBNotesNewLine
|
||||||
|
endif
|
||||||
|
|
||||||
g:mbnotes_loaded = 1
|
g:mbnotes_loaded = 1
|
||||||
|
|
Loading…
Add table
Reference in a new issue