R-nvim / R.nvim

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

When R is run I get error: "The package nvimcom wasn't loaded yet. Please, quit R and try again." #138

Closed mschmidty closed 1 month ago

mschmidty commented 1 month ago

When I run R /rf, it flashes a new buffer that closes immediately, and then gives an error message that says: The package nvimcom wasn't loaded yet. Please, quit R and try again. I believe this might be because running a server may be blocked but I am unsure.

Running :RDebugInfo produces:

nvimcom info: version: 0.9.41 
home: C:/Users/[...]/AppData/Local/Programs/R/R-4.3.0/library/nvimcom 
Rversion: 4.3.0   
before_rns.R stderr: (empty) 
stderr of last completion data building: (empty)    
before_rns.R stdout: (empty)      
Time:   
windows setup: 12.6626066       
global setup: 12.8171984 
check health (async): 0.0356714   
before_rns.R (async): 2.1279077 
jalvesaq commented 1 month ago

Perhaps, @akthe-at can help you...

akthe-at commented 1 month ago

Thanks @jalvesaq ... Hi @mschmidty , is this a new issue for you? Have you ever successfully run R.nvim before or your first attempt at setting it up?

I think it might be helpful for us to debug this issue if you showed us your config for R.nvim as well.

If my memory serves me correctly, I might have had this issue when I didn't have the right tooling to allow nvimcom to build correctly and I needed to make sure gcc was available on my PATH.

mschmidty commented 1 month ago

I appreciate your response.

I have not gotten R.nvim running on my windows machine (work, and the reason for the current issue), but I do have it running on my Mac (personal) with the same config.

My config is basically just the default:

require('lazy'). setup({
--other plugin config
   {
    'nvim-treesitter/nvim-treesitter',
    build = ':TSUpdate',
    opts = {
      ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc', 'markdown_inline', 'r', 'rnoweb' },
      auto_install = true,
      highlight = {
        enable = true,
        additional_vim_regex_highlighting = { 'ruby' },
      },
      indent = { enable = true, disable = { 'ruby' } },
    },
    config = function(_, opts)
      require('nvim-treesitter.install').prefer_git = true
      require('nvim-treesitter.configs').setup(opts)
    end,
  },

  {
    "R-nvim/R.nvim",
    lazy = false
  },
  "R-nvim/cmp-r",
  {
    "hrsh7th/nvim-cmp",
    config = function()
      require("cmp").setup({ sources = {{ name = "cmp_r" }}})
      require("cmp_r").setup({ })
    end,
  },
})
-- with treesitter config elsewhere

I'm pretty new to neovim and vim in general so I've been using the kickstart nvim init.lua.

I think it is a proxy issue because a window popped up the first time I tried to run R.nvim but I have not seen it since the first time.

gcc seems to be in my path:

❯ which gcc
/c/msys64/ucrt64/bin/gcc
akthe-at commented 1 month ago

Hey Mike welcome to the neovim community! I am also forced to use Windows for my work computer so I know how you feel. I am going to copy and paste my R.nvim config for you.

I think the big piece that you need to try and add to get it to work is the R_path in opts. I don't think anything else in my console is imperative but its easier to copy and paste the entire thing and might give you ideas of things to modify.

Feel free to delete it all except the R_path which obviously needs to be modified to match your own

{
    "R-nvim/R.nvim",
    ft = { "r", "rmd", "rout" },
    opts = {
      R_path = "C:\\Users\\ARK010\\AppData\\Local\\Programs\\R\\R-4.3.3\\bin\\x64", --I found that / and \\ both work here.
     -- ^^ Also make sure this file path is available on your PATH ^^
      open_html = 1,
      objbr_auto_start = true,
      objbr_opendf = 1,
      objr_place = "console, below",
      open_pdf = 0,
      hl_term = true,
      OutDec = ",",
      close_term = true,
      nvim_pager = "tab",
      pdfviewer = "sumatrapdf",
    },
    config = function()
      vim.g.R_bracketed_paste = 0
      vim.g.R_args = {}
      vim.g.rout_follow_colorscheme = false
      if vim.o.termguicolors then
        vim.g.rout_color_input = "guifg=#f265b5"
        vim.g.rout_color_normal = "guifg=#10A1BD"
        vim.g.rout_color_number = "guifg=#c0c95f"
        vim.g.rout_color_integer = "guifg=#c0c95f"
        vim.g.rout_color_float = "guifg=#c0c95f"
        vim.g.rout_color_complex = "guifg=#c0c95f"
        vim.g.rout_color_negnum = "guifg=#a48cf2"
        vim.g.rout_color_negfloat = "guifg=#a48cf2"
        vim.g.rout_color_date = "guifg=#37f499"
        vim.g.rout_color_true = "guifg=#37f499"
        vim.g.rout_color_false = "guifg=#ff5d5e"
        vim.g.rout_color_inf = "guifg=#04d1f9"
        vim.g.rout_color_constant = "guifg=#39DDFD"
        vim.g.rout_color_string = "guifg=#37f499"
        vim.g.rout_color_error = "guifg=#ffffff guibg=#f0313e"
        vim.g.rout_color_warn = "guifg=#f0313e"
        vim.g.rout_color_index = "guifg=#d0d080"
      end
    end,
  }
mschmidty commented 1 month ago

@akthe-at Thanks Adam. I'm happy to be dipping my toes into neovim.

R_path was it. I added the R_path and made sure it was in my $PATH and R started right up.

Thank you so much! I really appreciate the help.

akthe-at commented 1 month ago

Awesome, please feel free to reach out for any help you might need. Windows & Neovim isn't everyone's first desired mix but it is definitely doable and enjoyable once it is setup!

jasonpott commented 4 days ago

Thanks for taking the time to clarify that the path variable needs to explicitly stated in the configuration for R.nvim.

jalvesaq commented 4 days ago

Thanks for taking the time to clarify that the path variable needs to explicitly stated in the configuration for R.nvim.

You have to remember to update the R_path after upgrading R while, ideally, R.nvim would be able to find the R path in the Windows registry.