R-nvim / R.nvim

Neovim plugin to edit R files
GNU General Public License v3.0
165 stars 18 forks source link

Inconsistent behaviour when cursor is in comment line #247

Open andy941 opened 2 weeks ago

andy941 commented 2 weeks ago

When the cursor is in a comment in a code chunk (Quarto) some keybindings do not work:

Both commands work perfectly well in the non-comment lines in the chunk for both Python and R chunks.

One other thing to note is that instead RNextRChunk works in comment lines too which makes it all even more confusing.

TO be clear this affects all the times when the cursor is in any comment line not only |#.

Could it be a bug?

image

jalvesaq commented 2 weeks ago

Thanks for reporting the bug! I will see this later.

PMassicotte commented 2 weeks ago

Interestingly, cc does not work, but cd does.

jalvesaq commented 1 week ago

I can't replicate the bug. Everything works as expected on my side.

jalvesaq commented 1 week ago

Maybe you could disable some plugins to see if they interfere with R.nvim. I have headlines.nvim installed, but I don't get the R and Python symbols at the right top of code blocks.

andy941 commented 1 week ago

Maybe you could disable some plugins to see if they interfere with R.nvim. I have headlines.nvim installed, but I don't get the R and Python symbols at the right top of code blocks.

This is a different plugin called markview.nvim, it's IMHO even better looking and more plug and play. But you are right, when I get the chance I'll test with a minimal config. Do you already have one ready?

jalvesaq commented 1 week ago

You can find examples of minimal config at https://github.com/R-nvim/R.nvim/blob/main/README.md and https://github.com/R-nvim/R.nvim/wiki/Configuration

jalvesaq commented 1 week ago

I replaced headlines.nvim with markview.nvim and I agree that it looks better. Thanks!

By the way, I still can't replicate the bug.

andy941 commented 1 week ago

Noted. I will let you know if the minimal config works later this week.

andy941 commented 6 days ago

I can confirm I have the same issue with the minimal config you provided (nvim --clean -u minimal.lua example.qmd).

Same problems as above when \cc and \cN.

Example.qmd


---
format:
    html:
        useMath: true
        standalone: true
        embed-resources: true
        self-contained: true
        self-contained-math: true
    # pdf:
    #     documentclass: article
    #     toc: false
    #     number-sections: true
    #     colorlinks: true
    #     #cite-method: biblatex
    #     header-includes:
    #       - |
    #         ```{=latex}
    #         \usepackage{fvextra}
    #         \DefineVerbatimEnvironment{Highlighting}{Verbatim}{
    #           breaksymbolleft={},
    #           showspaces = false,
    #           showtabs = false,
    #           breaklines,
    #           commandchars=\\\{\}
    #         }
    #         ```
    # gfm:
    #     output-file: "README"
    #     output-ext:  "md"
    #     fig-dpi: 300
title: ""
author: "Andrea Finocchio"
#bibliography: cite.bib
citeproc: true
link-citations: true
code-fold: true
fig-dpi: 300
engine: knitr
highlight-style: gruvbox
cache: false
code-overflow: wrap
---

```{r}
#| lst-label: lst-imports-and-functions-r
#| lst-cap: lst-imports-and-functions-r
#| code-summary: "Imports and Functions - R"
#| output: false
#| code-fold: true

library(tidyverse)
library(reticulate)
library(ggthemes)
library(ggpubr)
library(kableExtra)
#library(EnvStats)

@lst-imports-and-functions-r

#| label: imports-and-functions-python
#| code-summary: "Imports and Functions - Python"
#| output: false

import pysam
import pandas as pd
import matplotlib.pyplot as plt
import os
import json
from IPython.core.display import Markdown
from tabulate import tabulate
#import pybedtools
jalvesaq commented 6 days ago

I can't replicate the bug with the same command, nvim --clean -u minimal.lua example.qmd, where minimal.lua is the minimal config from the wiki and example.qmd is the code you posted. I'm using Neovim v0.11.0-dev-1032+g230b0c7f02 (compiled yesterday) on Debian Testing (Linux).

jalvesaq commented 6 days ago

Could you delete the nvim-treesitter directory to force the regeneration of all parsers?

Since I can't replicate the bug, we have to wait until someone can fix it and make a pull request.

andy941 commented 4 days ago

I have tried regenerating all parsers but that did not solve the issues (with minimal.lua config as well). This is even more minimalistic example if that helps:

---
title: ""
---

```{r}
#| label: imports-and-functions-r

library(tidyverse)
#| label: imports-and-functions-r

library(tidyverse)
#| label: imports-and-functions-python

import pandas as pd

starting from the top: `\gn` twice to get to the first line of the second block `#| label: imports-and-functions-r`, then try to get back one block with `\gN`, nothing happens. If you get to the code line in the same block, `\gN` goes back one block as expected. Also `\cc` does not work in code blocks when on any comment line with the error: `Not inside an T code chunk`.

Sorry I can be of more help, @PMassicotte  seem to have similar issues as me?

> Interestingly, cc does not work, but cd does.
PMassicotte commented 4 days ago

I will check that on my side when I am back to the office on Monday.

PMassicotte commented 2 days ago

This works fine on my side.

This here my code file

---
format:
  html:
    useMath: true
    standalone: true
    embed-resources: true
    self-contained: true
    self-contained-math: true
  # pdf:
  #     documentclass: article
  #     toc: false
  #     number-sections: true
  #     colorlinks: true
  #     #cite-method: biblatex
  #     header-includes:
  #       - |
  #         ```{=latex}
  #         \usepackage{fvextra}
  #         \DefineVerbatimEnvironment{Highlighting}{Verbatim}{
  #           breaksymbolleft={},
  #           showspaces = false,
  #           showtabs = false,
  #           breaklines,
  #           commandchars=\\\{\}
  #         }
  #         ```
  # gfm:
  #     output-file: "README"
  #     output-ext:  "md"
  #     fig-dpi: 300
title: ""
author: "Andrea Finocchio"
#bibliography: cite.bib
citeproc: true
link-citations: true
code-fold: true
fig-dpi: 300
engine: knitr
highlight-style: gruvbox
cache: false
code-overflow: wrap
---

```{r}
#| lst-label: lst-imports-and-functions-r
#| lst-cap: lst-imports-and-functions-r
#| code-summary: "Imports and Functions - R"
#| output: false
#| code-fold: true

library(tidyverse)
library(reticulate)
library(ggthemes)
library(ggpubr)
library(kableExtra)
# library(EnvStats)
# | label: imports-and-functions-python
# | code-summary: "Imports and Functions - Python"
# | output: false

import pysam
import pandas as pd
import matplotlib.pyplot as plt
import os
import json
from IPython.core.display import Markdown
from tabulate import tabulate

# import pybedtools

With me using send lines:

Peek 2024-10-28 09-56