diff --git a/Ultisnips/mbnotes.snippets b/UltiSnips/mbnotes.snippets similarity index 100% rename from Ultisnips/mbnotes.snippets rename to UltiSnips/mbnotes.snippets diff --git a/autoload/mbnotes.vim b/autoload/mbnotes.vim index ab4bf44..988d68f 100644 --- a/autoload/mbnotes.vim +++ b/autoload/mbnotes.vim @@ -34,27 +34,34 @@ export def RenderNote(format: string, buffer = "%") def ExitCb(job: job, exit: number) if exit != 0 - execute "botright sbuf " .. b:mbnotes_renderer_buffer - elseif exists("g:mbnotes_open_command") - execute "botright sbuf " .. b:mbnotes_renderer_buffer - execute "!" .. g:mbnotes_open_command .. " " .. output - execute "bwipeout " .. b:mbnotes_renderer_buffer - endif + if !g:mbnotes_renderer_show + execute g:mbnotes_renderer_buffer_command + .. " " .. b:mbnotes_renderer_buffer + endif + else + if exists("g:mbnotes_open_command") && g:mbnotes_open_command != "" + execute "!" .. g:mbnotes_open_command .. " " .. output + endif - unlet b:mbnotes_renderer_buffer + if g:mbnotes_renderer_close_on_end + && exists("b:mbnotes_renderer_buffer") + execute "bwipeout " .. b:mbnotes_renderer_buffer + endif + endif enddef - b:mbnotes_renderer_buffer = term_start([ - "quarto", - "render", - input, - "--to", - format, - "--output-dir", - g:mbnotes_out_dir - ], { + var command = [ + g:mbnotes_quarto_binary, "render", input, + "--to", format, + "--output-dir", g:mbnotes_out_dir + ] + g:mbnotes_quarto_render_args + + # echo command + + b:mbnotes_renderer_buffer = term_start(command, { cwd: g:mbnotes_dir, - hidden: true, + hidden: !g:mbnotes_renderer_show, + term_opencmd: g:mbnotes_renderer_buffer_command .. " %d", exit_cb: ExitCb }) enddef diff --git a/doc/mbnotes.txt b/doc/mbnotes.txt index 137edf6..42bfe62 100644 --- a/doc/mbnotes.txt +++ b/doc/mbnotes.txt @@ -130,6 +130,8 @@ If none of the above are defined, and this variable is not set explicitly, then the render commands (e.g. |:MBNotesRenderPDF|) will not open the output file after rendering. +Explicitly set this to the empty string to disable opening behaviour. + g:mbnotes_rename_on_save *g:mbnotes_rename_on_save* This plugin will attempt to intelligently rename a note based on its title, @@ -138,6 +140,38 @@ setting this variable to false >vim let g:mbnotes_rename_on_save = 0 +g:mbnotes_renderer_show *g:mbnotes_renderer_show* + +When a document is rendered, the quarto command to do so runs in a terminal +buffer. If this variable is true, the terminal buffer will be visible. By +default, the terminal buffer is not shown unless an error appears. >vim + + let g:mbnotes_renderer_show = 1 + +g:mbnotes_renderer_close_on_end *g:mbnotes_renderer_close_on_end* + +If `g:mbnotes_renderer_show` is true, then automatically close the renderer +buffer if it completes successfully. + +g:mbnotes_renderer_buffer_command *g:mbnotes_renderer_buffer_command* + +The command that should be used to open the renderer buffer, at any time. This +follows the default for terminal buffers opened by `term_start()` which is +`botright sbuf`. For example: >vim + + let g:mbnotes_renderer_buffer_command = "vertical sbuf" + +g:mbnotes_quarto_render_args *g:mbnotes_quarto_render_args* + +An array of extra arguments passed to the command used to render documents. For +example, to always use the jupyter engine: >vim + + let g:mbnotes_quarto_render_args = ["-M", "engine:jupyter"] + +g:mbnotes_quarto_binary *g:mbnotes_quarto_binary* + +Location of the quarto binary. By default, this uses whichever one is in $PATH. + ============================================================================== 4. Commands *mbnotes-commands* diff --git a/ftdetect/mbnotes.vim b/ftdetect/mbnotes.vim index 3aa960d..694359a 100644 --- a/ftdetect/mbnotes.vim +++ b/ftdetect/mbnotes.vim @@ -4,7 +4,7 @@ def IsMBNotes() var path_prefix = expand('%:p')[0 : len(g:mbnotes_dir) - 1] if path_prefix == g:mbnotes_dir - set filetype=mbnotes + set filetype=mbnotes.qmd endif enddef diff --git a/plugin/mbnotes.vim b/plugin/mbnotes.vim index ea1658d..5ea0a8e 100644 --- a/plugin/mbnotes.vim +++ b/plugin/mbnotes.vim @@ -4,6 +4,14 @@ if exists("g:mbnotes_loaded") finish endif +if !exists("g:mbnotes_renderer_show") + g:mbnotes_renderer_show = false +endif + +if !exists("g:mbnotes_renderer_close_on_finish") + g:mbnotes_renderer_close_on_finish = true +endif + if !exists("g:mbnotes_dir") echoerr "MBNotes: Error: g:mbnotes_dir not set." finish @@ -42,7 +50,19 @@ if !exists("g:mbnotes_date_format_long") endif if !exists("g:mbnotes_rename_on_save") - g:mbnotes_rename_on_save = 1 + g:mbnotes_rename_on_save = true +endif + +if !exists("g:mbnotes_quarto_binary") + g:mbnotes_quarto_binary = "quarto" +endif + +if !exists("g:mbnotes_quarto_render_args") + g:mbnotes_quarto_render_args = [] +endif + +if !exists("g:mbnotes_renderer_buffer_command") + g:mbnotes_renderer_buffer_command = "botright sbuf" endif import autoload 'mbnotes.vim'