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

New get_lang() #355

Closed
wants to merge 1 commit into from
Closed

New get_lang() #355

wants to merge 1 commit into from

Conversation

jalvesaq
Copy link
Member

@jalvesaq jalvesaq commented Mar 3, 2025

Close #353

@jalvesaq
Copy link
Member Author

jalvesaq commented Mar 3, 2025

This is an alternative way of checking if the cursor is within a code block that seems to be more robust than the current code.

@PMassicotte
Copy link
Collaborator

PMassicotte commented Mar 3, 2025

I think this is what we have already on this branch:

local get_code_chunks = function(bufnr)

It also get some more information from the string, all parameters, like eval:true etc.

Should I PR it instead?

With that you could use this function

R.nvim/lua/r/quarto.lua

Lines 118 to 132 in 5199f6b

--- This function gets the current code chunk based on the cursor position
---@param bufnr integer The buffer number.
---@return table
M.get_current_code_chunk = function(bufnr)
local row, _ = unpack(vim.api.nvim_win_get_cursor(0))
local chunks = get_code_chunks(bufnr)
if not chunks then return {} end
for _, chunk in ipairs(chunks) do
if row >= chunk.start_row and row <= chunk.end_row then return chunk end
end
return {}
end

@jalvesaq
Copy link
Member Author

jalvesaq commented Mar 3, 2025

Yes, your pull request also fixes the issue and is more complete.

@jalvesaq jalvesaq closed this Mar 3, 2025
@jalvesaq
Copy link
Member Author

jalvesaq commented Mar 3, 2025

Actually neither of the two pull requests seems to fix the issue... I forgot to run :MDHeaders.

@PMassicotte
Copy link
Collaborator

Actually neither of the two pull requests seems to fix the issue... I forgot to run :MDHeaders.

Yeah, just found that. Tomorrow I will take time to investigate this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

incompatibility with md-headers, a plugin to navigate through the headings of .md .rmd.
2 participants