Git Product home page Git Product logo

Comments (32)

jalvesaq avatar jalvesaq commented on August 18, 2024 1

But we could try to change the value of vim.o.iskeywords temporarily. It will be much simpler than the complicated algorithm that I have written.

from r.nvim.

jalvesaq avatar jalvesaq commented on August 18, 2024 1

nvimcom and rnvimserver now send Lua tables to R.nvim. You have to update cmp-nvim-r.
There are some bugs when completing functions from .GlobalEnv, but I will fix them later.

from r.nvim.

jalvesaq avatar jalvesaq commented on August 18, 2024 1

I moved the check for radian to the config. It's working there.

from r.nvim.

jalvesaq avatar jalvesaq commented on August 18, 2024 1

I rewrote get_first_obj() and now it is as good and as bad as Nvim-R's version. I don't want to improve it any further because perhaps it will be possible (and better) to rewrite it using tree-sitter in the future. To quickly test the function, I have put this in my init.lua:

vim.keymap.set("n", "T", function ()
    vim.api.nvim_echo({
        {"{"},
        {require("r.run").get_keyword(), "Function"},
        {"} {"},
        {require("r.cursor").get_first_obj(), "Type"},
        {"}"}}, false, {})
end, { expr = true})

from r.nvim.

jalvesaq avatar jalvesaq commented on August 18, 2024 1

With this option, I receive a warning message:

Invalid nvimpager value: "horizontal". Valid values are: "tab", "split", "float", and "no".

And nothing more happens. Hence, we have to investigate why you are not receiving this warning.

from r.nvim.

jalvesaq avatar jalvesaq commented on August 18, 2024 1

The warning should be wrapped by vim.schedule(). This is fixed now.

from r.nvim.

jalvesaq avatar jalvesaq commented on August 18, 2024 1

Yes, please, do git pull to get the warnings. I didn't see the warn bug because I had this in my lazy.nvim config:

    {
        'rcarriga/nvim-notify',
        config = function ()
            -- Overriding vim.notify with fancy notify
            local notify = require("notify")
            vim.notify = notify
            notify.setup()
            vim.keymap.set('',  '<Esc>', "<ESC>:noh<CR>:lua require('notify').dismiss()<CR>", {silent = true})
        end
    },

from r.nvim.

jalvesaq avatar jalvesaq commented on August 18, 2024 1

But you can also send lines from the Example section to R. The rdoc is modifiable to allow you to edit the examples. There was a bug that I fixed just now.

from r.nvim.

PMassicotte avatar PMassicotte commented on August 18, 2024

An option to send the current object to the terminal:

    if rcmd == "print" then
        send.cmd(vim.fn.expand("<cword>"))
        return
    end

from r.nvim.

jalvesaq avatar jalvesaq commented on August 18, 2024

An option to send the current object to the terminal:

The problem is that vim.fn.expand("<cword>") will not catch strings such as listname$element.

from r.nvim.

jalvesaq avatar jalvesaq commented on August 18, 2024

The problem while running <LocalLeader>rp is the function get_first_obj(). It has to be rewritten from scratch.

from r.nvim.

PMassicotte avatar PMassicotte commented on August 18, 2024

Has something about terminal color changed this recently? Looks like a new config is coloring my terminal. Nevermind, I just set hl_term = false and it is all good.

from r.nvim.

jalvesaq avatar jalvesaq commented on August 18, 2024

Yes, hl_term is being defined as true, but nvimcom/R/nvimcom.R should detect radian:

    if (length(find.package("colorout", quiet = TRUE, verbose = FALSE)) > 0 || Sys.getenv("RADIAN_VERSION") != "")
        hascolor <- TRUE

from r.nvim.

PMassicotte avatar PMassicotte commented on August 18, 2024

It was opening radian, but my console was all green-ish.

from r.nvim.

jalvesaq avatar jalvesaq commented on August 18, 2024

I did a minor improvement in get_first_obj. With the following code:

x <- rnorm(100)
y <- rnorm(100)
m <- lm(y ~ x)
summary(x)
summary(m)

If you press <LocalLeader>rp over summary, you should get different results for each summary()

from r.nvim.

PMassicotte avatar PMassicotte commented on August 18, 2024

I did a minor improvement in get_first_obj. With the following code:

x <- rnorm(100)
y <- rnorm(100)
m <- lm(y ~ x)
summary(x)
summary(m)

If you press <LocalLeader>rp over summary, you should get different results for each summary()

Is it works if my cursor is either on x or m !

from r.nvim.

jalvesaq avatar jalvesaq commented on August 18, 2024

rh (for help) is not working for a namespaced function. For example pack::fun()

I can't replicate this. It works for me, for example doing <LocalLeader>rh over the word vi:

vi
nvimcom::vi
utils::vi

from r.nvim.

PMassicotte avatar PMassicotte commented on August 18, 2024

Placing my cursor on library and hitting <LocalLeader>rh does nothing. With the older nrim-r, it opens the help file for the library() function.

image

Now, placing my cursor on vi indeed brings me a topic menu. Then, If I select either 1 for nvimcom or 2 for utils, nothing happens.

image

from r.nvim.

jalvesaq avatar jalvesaq commented on August 18, 2024

Maybe you have set options("pager") in your ~/.Rprofile... I couldn't think of another explanation.

from r.nvim.

jalvesaq avatar jalvesaq commented on August 18, 2024

Also: \rh only works if R is running, but, if not, R.nvim displays a warning message.

from r.nvim.

PMassicotte avatar PMassicotte commented on August 18, 2024

No option about pager in my rprofile.

Even typing ?lm in the console does nothing.

Peek 2024-02-18 03-35

So it looks like that tmp-R-Nvim is not opening a new window properly.

from r.nvim.

PMassicotte avatar PMassicotte commented on August 18, 2024

The only pager option I have is this config:

opts = {
   ...
   nvimpager = "horizontal",
   ...
  }

from r.nvim.

PMassicotte avatar PMassicotte commented on August 18, 2024

You are right, it works as before when using 'split'. I probably missed the change of the parameter (i.e. using an old value that was working with nvim-r).

from r.nvim.

PMassicotte avatar PMassicotte commented on August 18, 2024

What is supposed to be the file type of rdoc?

For me, :set filetype? returns nothing

image

Hence, sending example code in the terminal is not working because not recognized as r code.

from r.nvim.

jalvesaq avatar jalvesaq commented on August 18, 2024

The filetype rdoc no longer exists; only the syntax is being used.

from r.nvim.

jalvesaq avatar jalvesaq commented on August 18, 2024

It was a filetype that I created to display R documentation. Its functions are now in lua/r/rdoc.lua.

from r.nvim.

PMassicotte avatar PMassicotte commented on August 18, 2024

The filetype rdoc no longer exists; only the syntax is being used.

Do you have a good strategy to send example code to the console? I found it was a nice thing to do while browsing code example and have the ability to send it to the console.

from r.nvim.

jalvesaq avatar jalvesaq commented on August 18, 2024

\re to get the "Examples" section in an R buffer.

from r.nvim.

PMassicotte avatar PMassicotte commented on August 18, 2024

Another thing I am just facing is that sending above code does not always work. In this example, moving the cursor 2 lines below give me an error cannot open the connection. Moving back the cursor up, make it works again.

Peek 2024-02-18 06-49

Maybe we can just grab all the lines above and send them directly to the console instead of writing a tmp file.

from r.nvim.

PMassicotte avatar PMassicotte commented on August 18, 2024

But you can also send lines from the Example section to R. The rdoc is modifiable to allow you to edit the examples. There was a bug that I fixed just now.

You are on fire :)

from r.nvim.

jalvesaq avatar jalvesaq commented on August 18, 2024

Another thing I am just facing is that sending above code does not always work. In this example, moving the cursor 2 lines below give me an error cannot open the connection. Moving back the cursor up, make it works again.

Two lines above you were below the threshold of 20 lines to source lines and the lines were sent directly. I introduced the bug yesterday when fixing user config variables not being recognized. It should be fixed now.

from r.nvim.

PMassicotte avatar PMassicotte commented on August 18, 2024

All perfect now!

from r.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.