Automatic Knitting #423
-
Hi! I was wondering if there is a way to automatically knit a document as the .Rmd buffer is saved. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
It should be the case. It works for both qmd and rmd files on my side. |
Beta Was this translation helpful? Give feedback.
-
vim.cmd.autocmd("BufWritePost", "*.Rmd", "lua require('r.rmd').make('default')") Or in your {
"R-nvim/R.nvim",
config = function()
local opts = {
hook = {
on_filetype = function()
if vim.o.filetype == "rmd" then
vim.cmd("autocmd BufWritePost <buffer> lua require('r.rmd').make('default')")
end
end,
},
}
require("r").setup(opts)
end,
}, |
Beta Was this translation helpful? Give feedback.
-
Thank you!! For anyone else attempting to the same in MacOS, the default file loading with Skim opened a new window every time there was a knit, regardless of whether it was manually or automatically, so I set |
Beta Was this translation helpful? Give feedback.
<LocalLeader>kr
already saves the buffer before sending to R the command to knit it. But what you want can be achieved with anautocmd
in your~/.config/nvim/init.lua
:Or in your
R.nvim
config (example forlazy.nvim
):