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

Communication with Rgui.exe doesn't work #308

Open
jalvesaq opened this issue Jan 11, 2025 · 12 comments
Open

Communication with Rgui.exe doesn't work #308

jalvesaq opened this issue Jan 11, 2025 · 12 comments
Labels

Comments

@jalvesaq
Copy link
Member

As reported by @oktouerl, Rgui.exe as an external "terminal" doesn't work: #307 (comment)

@jalvesaq
Copy link
Member Author

Is anybody using R.nvim with Rgui.exe? I plan to remove the option to run Rgui.exe at the end of February 2025...

jalvesaq added a commit that referenced this issue Jan 12, 2025
@jalvesaq
Copy link
Member Author

I started to remove the integration with Rgui.exe but realized it would be impossible not to break something because I don't have access to a Windows machine. I would need at least Windows running on a virtual machine, and I don't plan to install one anytime soon. So, I'm leaving this issue open.

@PMassicotte
Copy link
Collaborator

I could eventually test on wife's Windows machine.

@jalvesaq
Copy link
Member Author

Thanks, but it would still be complicated. Ideally, I would make the changes and leave the code without known bugs. In this case, I would make the changes and leave the code with an unknown number of bugs. It could be a lot of work for both of us. It's better to let the junk code stay because, although useless, it causes no harm.

@DKBurns
Copy link

DKBurns commented Feb 24, 2025

Hi All, I have to work on windows for work. Upon updating the plugin R no longer starts. Noice last line is:

   Warn  09:27:44 notify.warn R.nvim Cannot start R: rnvimserver not started yet.

I'm using a simple config:

return{
  {
    "R-nvim/R.nvim",
    lazy = false,
    opts = {
      -- Create a table with the options to be passed to setup()
      R_args = { "--quiet", "--no-save" },
      hook = {
        on_filetype = function()
          -- This function will be called at the FileType event
          -- of files supported by R.nvim. This is an
          -- opportunity to create mappings local to buffers.
          vim.keymap.set("n", "<Enter>", "<Plug>RDSendLine", { buffer = true })
          vim.keymap.set("v", "<Enter>", "<Plug>RSendSelection", { buffer = true })

          local wk = require("which-key")
          wk.add({
            buffer = true,
            { "<localleader>a", group = "all" },
            { "<localleader>b", group = "between marks" },
            { "<localleader>c", group = "chunks" },
            { "<localleader>f", group = "functions" },
            { "<localleader>g", group = "goto" },
            { "<localleader>i", group = "install" },
            { "<localleader>k", group = "knit" },
            { "<localleader>p", group = "paragraph" },
            { "<localleader>q", group = "quarto" },
            { "<localleader>r", group = "r general" },
            { "<localleader>s", group = "split or send" },
            { "<localleader>t", group = "terminal" },
            { "<localleader>v", group = "view" },
          })
        end,
      },
      pdfviewer = "",
    },
    config = function(_, opts)
      vim.g.rout_follow_colorscheme = true
      require("r").setup(opts)
      require("r.pdf.generic").open = vim.ui.open
    end,
  },
}

I'm afraid I'm a bit of a noob so you might have to give me a little direction on giving you useful information!

For now it's fine, I'll just drag my heels back to Rstudio with vim bindings. I hope this info helps rather than confusing things...

EDIT: checkhealth results

==============================================================================
r: require("r.health").check()

Checking applications and plugins: ~
- OK Neovim version: 0.10.4+ge96f75a4e6
- OK C compiler (`gcc` or `clang`) found.
- OK `R-nvim/cmp-r` found.
- OK `nvim-treesitter/nvim-treesitter` found.

Checking tree-sitter parsers: ~
- OK `r`  found.
- OK `markdown`  found.
- OK `markdown_inline`  found.
- OK `rnoweb`  found.
- OK `latex`  found.
- OK `yaml`  found.

Checking language detection in a Quarto document: ~
- OK Correctly detected: `yaml`
- OK Correctly detected: `markdown`
- OK Correctly detected: `markdown_inline`
- OK Correctly detected: `chunk_header`
- OK Correctly detected: `r`
- OK Correctly detected: `chunk_end`

Checking language detection in an Rnoweb document: ~
- OK Correctly detected: `latex`
- OK Correctly detected: `chunk_header`
- OK Correctly detected: `r`
- OK Correctly detected: `chunk_end`

@jalvesaq
Copy link
Member Author

This bug was reported on January 11, but I can't fix it because don't have access to a Windows machine. You can try this in your R.nvim config:

    external_term = ""

@jalvesaq
Copy link
Member Author

What's the output of :RDebugInfo?

@DKBurns
Copy link

DKBurns commented Feb 24, 2025

Hi Thanks for getting back. I printed the latter first:

I can't prevent there being a space in the path as my username is fixed. Possibility it's that?

nvimcom info:
  Rversion: 4.4.1
  home: C:/Users/<my user name with a space in it>/AppData/Local/R/win-library/4.4/nvimcom
  version: 0.9.63
Time:
  windows setup: 0.0721994
  check health (async): 0.0128711
  global setup: 0.154099

I put external_term = "" like so. Sorry if it's wrong I'm still learning how to manipulate config lua files:

  return {
    "R-nvim/R.nvim",
    lazy = false,
    opts = {
      -- Create a table with the options to be passed to setup()
      external_term = "",
      R_args = { "--quiet", "--no-save" },
      hook = {
        on_filetype = function()
          -- This function will be called at the FileType event
          -- of files supported by R.nvim. This is an
          -- opportunity to create mappings local to buffers.
          vim.keymap.set("n", "<Enter>", "<Plug>RDSendLine", { buffer = true })
          vim.keymap.set("v", "<Enter>", "<Plug>RSendSelection", { buffer = true })

          local wk = require("which-key")
          wk.add({
            buffer = true,
            { "<localleader>a", group = "all" },
            { "<localleader>b", group = "between marks" },
            { "<localleader>c", group = "chunks" },
            { "<localleader>f", group = "functions" },
            { "<localleader>g", group = "goto" },
            { "<localleader>i", group = "install" },
            { "<localleader>k", group = "knit" },
            { "<localleader>p", group = "paragraph" },
            { "<localleader>q", group = "quarto" },
            { "<localleader>r", group = "r general" },
            { "<localleader>s", group = "split or send" },
            { "<localleader>t", group = "terminal" },
            { "<localleader>v", group = "view" },
          })
        end,
      },
      pdfviewer = "",
    },
    config = function(_, opts)
      vim.g.rout_follow_colorscheme = true
      require("r").setup(opts)
      require("r.pdf.generic").open = vim.ui.open
    end,
  }

Finally, I noticed some more optut in Noice which appears upon opening the R file:

11:26:03 msg_show ...ns/AppData/Local/nvim-data/lazy/R.nvim/lua/r/windows.lua:12: attempt to call field 'system' (a nil value)
11:26:03 msg_show stack traceback:
11:26:03 msg_show ^I...ns/AppData/Local/nvim-data/lazy/R.nvim/lua/r/windows.lua:12: in function 'set_R_home'
11:26:03 msg_show ^I...rns/AppData/Local/nvim-data/lazy/R.nvim/lua/r/server.lua:173: in function 'start_rnvimserver'
11:26:03 msg_show ^I...rns/AppData/Local/nvim-data/lazy/R.nvim/lua/r/server.lua:230: in function <...rns/AppData/Local/nvim-data/lazy/R.nvim/lua/r/server.lua:226>

I think this is because R is set to start up automatically when an .R or .Rmd file is opened in nvim.

Hopefully that provides some clues. Also, thank you very much for having a look at this.

@jalvesaq
Copy link
Member Author

Please, try the branch "win_system". It should fix the bug

R.nvim/lua/r/windows.lua:12: attempt to call field 'system' (a nil value)

@DKBurns
Copy link

DKBurns commented Feb 24, 2025

it worked! R is happily playing nice and console opened upon pressing <localleader>rf

For reference to any others that might be forced to work with windows, a working config as of 2025-02-24 (I will edit this if/when the branch is merged) is:

return {
  "R-nvim/R.nvim",
  branch = "main",
  lazy = false,
  opts = {
    -- Create a table with the options to be passed to setup()
    external_term = "",
    R_args = { "--quiet", "--no-save" },
    hook = {
      on_filetype = function()
        -- This function will be called at the FileType event
        -- of files supported by R.nvim. This is an
        -- opportunity to create mappings local to buffers.
        vim.keymap.set("n", "<Enter>", "<Plug>RDSendLine", { buffer = true })
        vim.keymap.set("v", "<Enter>", "<Plug>RSendSelection", { buffer = true })

        local wk = require("which-key")
        wk.add({
          buffer = true,
          { "<localleader>a", group = "all" },
          { "<localleader>b", group = "between marks" },
          { "<localleader>c", group = "chunks" },
          { "<localleader>f", group = "functions" },
          { "<localleader>g", group = "goto" },
          { "<localleader>i", group = "install" },
          { "<localleader>k", group = "knit" },
          { "<localleader>p", group = "paragraph" },
          { "<localleader>q", group = "quarto" },
          { "<localleader>r", group = "r general" },
          { "<localleader>s", group = "split or send" },
          { "<localleader>t", group = "terminal" },
          { "<localleader>v", group = "view" },
        })
      end,
    },
    pdfviewer = "",
  },
  config = function(_, opts)
    vim.g.rout_follow_colorscheme = true
    require("r").setup(opts)
    require("r.pdf.generic").open = vim.ui.open
  end,
}

EDIT: following the merge, main branch is used. Confirmed the above config is functioning on windows, following removing the plugin reinstalling.

jalvesaq added a commit that referenced this issue Feb 24, 2025
@jalvesaq
Copy link
Member Author

Merged now.

@jalvesaq
Copy link
Member Author

Note: I didn't close the issue because running R in Rgui.exe was reported as not working and I haven't fixed the bug yet.

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

No branches or pull requests

3 participants