Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ATX header folding doesn't work #40

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 38 additions & 84 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,111 +1,65 @@
vim-rmarkdown
quarto-vim
=============

[RMarkdown](http://rmarkdown.rstudio.com/) support for vim.
[Quarto](https://quarto.org) support for vim.

## Setup
quarto-vim is a fork of the [vim-rmarkdown](https://github.com/vim-pandoc/vim-rmarkdown) plugin.

quarto-vim currently only handles syntax highlighthing for qmd
files, however we'd very much like to add more of the features
available in the excellent [vim-pandoc](https://githhub.com/vim-pandoc/viv-pandoc)
plugin. If you are interested in contributing please get in
touch by filing an issue or sending a pull request!

vim-rmarkdown requires
## Setup

* the [vim-pandoc](https://github.com/vim-pandoc/vim-pandoc) and
[vim-pandoc-syntax](https://github.com/vim-pandoc/vim-pandoc-syntax) vim plugins.
quarto-vim requires the [vim-pandoc-syntax](https://github.com/vim-pandoc/vim-pandoc-syntax) vim plugin.

* the [rmarkdown standalone package](https://github.com/rstudio/rmarkdown)

vim-rmarkdown's repo uses the typical bundle layout, so it's very simple to
quarto-vim's repo uses the typical bundle layout, so it's very simple to
install using some plugin manager such as [pathogen](https://github.com/tpope/vim-pathogen), [Vundle](https://github.com/VundleVim/Vundle.vim) or [NeoBundle](https://github.com/Shougo/neobundle.vim). For
example, using Vundle you should add

Plugin 'vim-pandoc/vim-rmarkdown'
```viml
Plugin 'vim-pandoc/vim-pandoc-syntax'
Plugin 'quarto-dev/quarto-vim'
```

to your .vimrc, source it, and execute `:PluginInstall`.

## Screenshot
Using [packer.nvim](https://github.com/wbthomason/packer.nvim), you should add

![screenshot](http://i.imgur.com/mwr6O5t.png)
```lua
use({
"quarto-dev/quarto-vim",
requires = {
{"vim-pandoc/vim-pandoc-syntax"},
},
ft = {"quarto"},
})
```
to your `.vimrc` (or `init.lua` in Neovim).

## Usage

Files with the .Rmd extension are automatically detected as RMarkdown files.
vim-rmarkdown loads vim-pandoc and pandoc's markdown syntax, and adds some
extra functionality specific to rmarkdown.
Files with the .qmd extension are automatically detected as Quarto files and use highlithing rules from vim-pandoc-syntax (in addition to some special rules for Quarto executable code).

### Syntax

vim-rmarkdown extends pandoc's markdown syntax so
quarto-vim extends pandoc's markdown syntax so that:

```{r qplot, fig.width=4, message=FALSE}
library(ggplot2)
```{python}
import numpy as np
np.arange(15).reshape(3, 5)
```

```{r}
summary(cars)
qplot(speed, dist, data=cars) +
geom_smooth()
```
are recognized as Python and R code cells.

is recognized as an R code chunk, and
Inline R is also handled for the knitr engine:

inline unformatted text like `r 1 + 2`

as inline R.

R syntax is used within such fenced codeblocks and inline spans.

### Command

To render the file using rmarkdown, the user can execute the `|:RMarkdown|`
command. Its syntax is

`:RMarkdown[!] [OUTPUT_TYPE] [- RENDER_ARGS[ -]] [OUTPUT_TYPE_ARGS]`

OUTPUT_TYPE is one of "pdf", "word", "html", "md", "beamer", "ioslides",
"revealjs", "all", or a combination thereof (e.g., "pdf+html"). Command
completion is provided for defining this variable.

RENDER_ARGS are arguments passed to rmarkdown::render(...), and
OUTPUT_TYPE_ARGS are passed to output objects such as rmarkdown::pdf_document(...)
and rmarkdown::word_document(...). (Refer to RMarkdown's documentation).
Note RENDER_ARGS MUST be surrounded by '- ' and ' -'.

The bang (!) version opens the created file on successful execution. If the
execution fails, a message will be shown and a buffer will open with Rscript's
output (can be dismissed by pressing q in normal mode).

:RMarkdown builds a R expression that executes rmarkdown. For example, if the
current file is "input.Rmd",

:RMarkdown pdf

executes

Rscript -e 'library(rmarkdown);render("input.Rmd", "pdf_document")'

If OUTPUT_TYPE is ommited, RMarkdown produces an html document.

Some more examples:

:RMarkdown pdf latex_engine="xelatex", toc=TRUE
->
Rscript -e 'library(rmarkdown);render("input.Rmd", pdf_document(latex_engine="xelatex", toc=TRUE)

:RMarkdown html - quiet=FALSE - toc=FALSE
->
Rscript -e 'library(rmarkdown);render("input.Rmd", html_document(toc=TRUE), quiet=FALSE)

:RMarkdown word - quiet=FALSE
->
Rscript -e 'library(rmarkdown);render("input.Rmd", "word_document", quiet=FALSE)

Note `|:RMarkdown|` doesn't parse the arguments itself, so the user must type them
exactly as they should be used in R (for example, commas should separate
arguments). For example,

:RMarkdown latex_engine="lualatex" bibliography="input.bib"

will cause rmarkdown to fail.

## NrrwRgn

If the NrrwRgn plugin is available, vim-rmarkdown will register an extra
command, |:RNrrw|, which "narrows" the current R chunk in a separate buffer.
This command is also mapped to "<LocalLeader>ccn" in normal mode.

`" vim: set ft=help :`
R and Python syntax is used within such fenced codeblocks and inline spans.
161 changes: 0 additions & 161 deletions autoload/rmarkdown/command.vim

This file was deleted.

22 changes: 0 additions & 22 deletions autoload/rmarkdown/exexec.R

This file was deleted.

64 changes: 0 additions & 64 deletions autoload/rmarkdown/nrrwrgn.vim

This file was deleted.

Loading