From 765d53a1b17a91c504d01d8c4d2c27945af357aa Mon Sep 17 00:00:00 2001 From: Daniel Winkler Date: Sat, 31 Jan 2026 17:28:09 +1100 Subject: [PATCH] quarto setup --- ftplugin/quarto.lua | 23 +++++++++++++++++++++++ plugin/20_startup.lua | 4 ++++ plugin/21_datascience.lua | 8 ++++---- snippets/quarto.json | 13 +++++++++++++ snippets/r.json | 0 5 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 ftplugin/quarto.lua create mode 100644 snippets/quarto.json create mode 100644 snippets/r.json diff --git a/ftplugin/quarto.lua b/ftplugin/quarto.lua new file mode 100644 index 0000000..7ee10a0 --- /dev/null +++ b/ftplugin/quarto.lua @@ -0,0 +1,23 @@ + + +local quarto = require('quarto') +quarto.setup() +vim.keymap.set('n', 'qp', quarto.quartoPreview, { silent = true, noremap = true }) + +vim.keymap.set("n", "", "RDSendLine", { buffer = true }) +vim.keymap.set("v", "", "RSendSelection", { buffer = true }) + +-- Assignment operator (--) +vim.keymap.set("i", "--", "lua MiniTrailspace.trim()RInsertAssign", { buffer = true, noremap = true }) + +-- Pipe operator (;;) +vim.keymap.set("i", ";;", "lua MiniTrailspace.trim()RInsertPipe", { buffer = true, noremap = true }) + +local runner = require("quarto.runner") +vim.keymap.set("n", "a", runner.run_cell, { desc = "run cell", silent = true }) +vim.keymap.set("n", "A", runner.run_all, { desc = "run all cells", silent = true }) +vim.keymap.set("n", "RA", function() + runner.run_all(true) +end, { desc = "run all cells of all languages", silent = true }) + + diff --git a/plugin/20_startup.lua b/plugin/20_startup.lua index 5ec11ac..ca18bd8 100644 --- a/plugin/20_startup.lua +++ b/plugin/20_startup.lua @@ -300,6 +300,9 @@ now_if_args(function() -- Use explicit buffer + filetype to avoid any ambiguity local ok = pcall(vim.treesitter.start, args.buf, args.match) vim.bo.syntax = 'on' + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + vim.wo[0][0].foldexpr = 'v:lua.vim.treesitter.foldexpr()' + vim.wo[0][0].foldmethod = 'expr' end, }) @@ -309,6 +312,7 @@ now_if_args(function() return end + vim.g.no_plugin_maps = true nto.setup({ move = { set_jumps = true, diff --git a/plugin/21_datascience.lua b/plugin/21_datascience.lua index ddb93a8..118ee20 100644 --- a/plugin/21_datascience.lua +++ b/plugin/21_datascience.lua @@ -97,9 +97,9 @@ later(function() enabled = true, }, }, - -- codeRunner = { - -- enabled = true, - -- default_method = "slime", - -- }, + codeRunner = { + enabled = true, + default_method = "slime", + }, }) end) diff --git a/snippets/quarto.json b/snippets/quarto.json new file mode 100644 index 0000000..51d3f9e --- /dev/null +++ b/snippets/quarto.json @@ -0,0 +1,13 @@ +{ + "Chunk": { + "R": { + "prefix": "_r", + "body": [ + "```{r}", + "$1", + "```" + ], + "description": "R code block" + } + } +} diff --git a/snippets/r.json b/snippets/r.json new file mode 100644 index 0000000..e69de29