Skip to content
Discussion options

You must be logged in to vote

<LocalLeader>kr already saves the buffer before sending to R the command to knit it. But what you want can be achieved with an autocmd in your ~/.config/nvim/init.lua:

vim.cmd.autocmd("BufWritePost", "*.Rmd", "lua require('r.rmd').make('default')")

Or in your R.nvim config (example for lazy.nvim):

{
  "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,
},

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by inakineitor
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants