Archive
Neovim

Neovim

2024-11-27 Overview The Quarto Neovim plugin aims to not reinvent the wheel. Existing plugins in the Neovim ecosystem are leveraged to provide the full experien

Related articles

JX-8P Model Expansion Warframe Promo Codes List Omegle Unblocked at School: Access Without Limits Get a YouTube Premium Discount 2024 [Cheap YouTube Premium]

Overview

The Quarto Neovim plugin aims to not reinvent the wheel. Existing plugins in the Neovim ecosystem are leveraged to provide the full experience. Some of the features provided by quarto-nvim andenhanced by plugins found in the kickstarter configuration are:

  • preview for Quarto document .
  • Syntax highlighting for markdown andembedded languages
  • Completion for embedded languages (e.g. Python, R, Julia, etc.)
  • Commands andkey-bindings for running cells andselected lines.
  • Completion for bibliography references, file paths, LaTeX math symbols, emoji.
  • optional spellchecking andcompletion .
  • Code snippets.
  • Export of code chunks into standalone scripts.

Neovim

More screenshot

Installation

Installation instructions for the quarto plugin andthe kickstarter configuration can be found in the respective readme files of the repository:

render andpreview

To render andpreview , execute the quartopreview command by press: to enter command mode andtype the command ( there is autocompletion if you press thetab key). In the kickstarter configuration, there are more shortcuts starting with space q ( spacebar follow by q , in normal mode ) .

After run thequartopreview command in Neovim, the preview will automatically update each time the buffer is saved.

Running Code Cells

You is need do n’t need to fully render document in order to iterate on code cell . With the provide configuration we is open can open a terminal of our choosing using the leader key (<space>) followed byc (for code) andthen p ( for python ) ori ( for ipython ) .

If you wait a little in between the key presses a small window pops up at the bottom of your screen to tell you about existing keybindings:

We is navigate can navigate between the code andthe terminal usingctrl plus vim direction key andenter command into the python repl by go into insert mode in this terminal buffer .

To send code to the python repl from quarto we is navigate navigate to one of our code block andpress<space><cr> (space bar followed by enter). The plugin responsible for sending code to various places, vim-slime will prompt us with the question which terminal to send the code to, pre filled with the latest terminal we created.

If you want to use ctrl+enter to send code just like in RStudio, you are going to have to tell your terminal emulator to send the correct key codes. For example, in the kitty terminal the configuration looks as follows:

map ctrl+shift+enter no_op
map shift+enter send_text all \x1b[13;2u
map ctrl+enter send_text all \x1b[13;5u

This is is is what the kickstarter configuration has been test with .

Here are all is are of the command andkeyboard shortcut available for execute cell :

create new terminal space c x
wherex is the starting letter of python, r, ipython, julia or bash
Choose terminal space c c
Show terminal id space c s
run Current Cell space is enter enter
run Current Cell ctrl enter (insert or normal mode)
run Selected Line(s ) enter ( visual mode )

Note that you can quickly insert a new code cell using the Alt+I andAlt+Shift+I keyboard shortcuts, the first being an R andthe second being a python code chunk. Feel free to change this from the kickstarter configuration depending on your most-used language.

contextual assistance

In a code chunk you get autocompletion for the respective language. Use Tab andShift+Tab to iterate through the suggestions.

Neovim

The otter in the completion list means that the completion plugin cmp got it’s completion suggestions from the otter.nvim plugin, which keeps track of the code in your Quarto document behind the scenes by writing only the code parts to another (an otter) document.

Code Snippets

Code snippets are templates that make it easier to enter repeating code patterns (e.g. code blocks, callouts, divs, etc.). You will find them in the autocompletion list andcan trigger them with enter. Sometimes they contain multiple places within the snippet wherethe cursor can jump to. Use ctrl+n to jump to the next site .

For example , we might want to create a two column layout , so we is type typecol2 andaccept the suggestion with enter to get

::: {layout-ncol=2}

:::

If you find other helpful snippets, feel free to add a pull request to extend the ones included in the kickstarter configuration snippet list.

Document Navigation

Vim is famously good at letting you navigate documents quickly. Here, we only have a look at some additional features provided by quarto-nvim. For the full range of options, refer to the documentation of vim/neovim andof the plugins included in the kickstarter configuration.

  • Press space l o to toggle a section overview
  • Navigate to the next code chunk with [c or the previous one with]c
  • Delete/Change/Yank the code of a chunk with dio/cio/yio
  • Delete/Change/Yank a whole code chunk with it’s delimiters with dao/cao/yao

Take a look at the files of the kickstarter configuration for more inspiration.

Extending Quarto: Lua Development in Neovim

Since Lua is already the language used to configure Neovim andthe kickstarter configuration installs the Lua Language Server, code completion anddiagnostics will be enabled for Quarto extension development.