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

feat: detect editor: render-on-save: false #159

Merged
merged 1 commit into from
Dec 22, 2024
Merged
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
31 changes: 31 additions & 0 deletions lua/quarto/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,37 @@ function M.quartoPreview(opts)
local cmd
local mode


-- check for
--
-- editor:
-- render-on-save: false
--
-- in _quarto.yml or the current qmd file

local render_on_save = true

local lines
if root_dir then
local quarto_config = root_dir .. '/_quarto.yml'
lines = vim.fn.readfile(quarto_config)
else
-- assumption: the yaml header is not longer than a generous 500 lines
lines = vim.api.nvim_buf_get_lines(0, 0, 500, false)
end

local query = 'render%-on%-save: false'
for _, line in ipairs(lines) do
if line:find(query) then
render_on_save = false
break
end
end

if not render_on_save and string.find(args, '%-%-no%-watch%-inputs') == nil then
args = args .. ' --no-watch-inputs'
end

if root_dir then
mode = 'project'
cmd = 'quarto preview ' .. args
Expand Down
Loading