Git Product home page Git Product logo

Comments (35)

jalvesaq avatar jalvesaq commented on July 18, 2024 1

We could also echo like the first n and the last n lines of the block.

It's a good idea, but I don't know how to implement it with base::source().

So, if I understand correctly, we could simply send the lines to the console without sourcing a temp file (except for some use case you describe)?

Yes, except if the number of lines is > max_lines_paste. I suggest a default value close to 20 for this option. Of course, users would be free to change it to any value between 1 and inf.

from r.nvim.

jalvesaq avatar jalvesaq commented on July 18, 2024 1

We could also echo like the first n and the last n lines of the block.

Actually, this could be done inside nvimcom:::NvimR.source()

from r.nvim.

jalvesaq avatar jalvesaq commented on July 18, 2024 1

If indeed the problem was the environment variable being nil, it should be fixed now.

from r.nvim.

jalvesaq avatar jalvesaq commented on July 18, 2024 1

I uploaded some bug fixes in many files. So, please, do git pull before pushing new changes. I intended to do a pull request, but I forgot to create a branch and pushed the changes to the main branch.

from r.nvim.

jalvesaq avatar jalvesaq commented on July 18, 2024 1

The main reason was that when I pressed <leader>gd over a function name in a Lua buffer, the LSP opened a quickfix window with two lines and, then, when I pressed <Enter> nothing happened. The problem was that I mapped <Enter> to send lines to R, and the map was active in all buffers. The hooks are very cheap to add; just 2 lines of code: one in the table config and the other where the function should be called.

from r.nvim.

PMassicotte avatar PMassicotte commented on July 18, 2024

I like the idea of max_line_to_paste. We could also echo like the first n and the last n lines of the block. So, if I understand correctly, we could simply send the lines to the console without sourcing a temp file (except for some use case you describe)?

from r.nvim.

PMassicotte avatar PMassicotte commented on July 18, 2024

Should send functions work at the moment? I am trying to use the tmp-R-Nvim and I keep getting R is not ready yet, coming from this line

https://github.com/jalvesaq/tmp-R-Nvim/blob/587be7749934431b5ab13e2745eeaa4f14560441/lua/r/send.lua#L65

rf indeed opens the R terminal, but when I try to send a function I get the R not ready.

from r.nvim.

jalvesaq avatar jalvesaq commented on July 18, 2024

I was testing the external terminal, and introduced this bug for the built-in terminal. I will fix it in a couple of minutes.

from r.nvim.

PMassicotte avatar PMassicotte commented on July 18, 2024

No rush :)

from r.nvim.

jalvesaq avatar jalvesaq commented on July 18, 2024

I can't replicate the bug.

from r.nvim.

jalvesaq avatar jalvesaq commented on July 18, 2024

Could you try this:

echo 'remove.packages("nvimcom")' | R

Maybe nvimcom needs to be rebuilt...

from r.nvim.

PMassicotte avatar PMassicotte commented on July 18, 2024

I removed nvimcom and it re-install when I open a R file in nvimr. But I still have that same issue.

Peek 2024-02-10 13-08

from r.nvim.

PMassicotte avatar PMassicotte commented on July 18, 2024

WIll investigate and report back.

from r.nvim.

PMassicotte avatar PMassicotte commented on July 18, 2024

Actually, I am getting some lua errors. Do you get some if you type :messages

image

from r.nvim.

PMassicotte avatar PMassicotte commented on July 18, 2024

Looks like it is coming from exec_stdout_cmd

from r.nvim.

jalvesaq avatar jalvesaq commented on July 18, 2024

When an environment variable doesn't exist, the vim.env.VAR is nil...
I will grep 'vim.env.*\.\.' and fix the cases when the environment variable might not exist.

from r.nvim.

PMassicotte avatar PMassicotte commented on July 18, 2024

Super, working perfectly fine!

from r.nvim.

PMassicotte avatar PMassicotte commented on July 18, 2024

The echo/silent and down/stay are inverted in function call:

https://github.com/jalvesaq/tmp-R-Nvim/blob/46ef896d83331879ec2685628688f2a04f114a50/lua/r/maps.lua#L150-L154

https://github.com/jalvesaq/tmp-R-Nvim/blob/46ef896d83331879ec2685628688f2a04f114a50/lua/r/send.lua#L172-L192

so m is equall to either echo/silent.

We can fix that later when we decide what to do with the echo/silent options.

from r.nvim.

jalvesaq avatar jalvesaq commented on July 18, 2024

We can fix that later when we decide what to do with the echo/silent options.

What is your opinion on this? I prefer to eliminate the "echo" parameter from the send functions because users can set the value of source_args as ", echo=TRUE". It's redundant to have both maps for echoing what is being sourced and the option to do this with source_args. I prefer to simplify the functions and reduce the number of key bindings. But if you like the parameter we can keep it.

from r.nvim.

jalvesaq avatar jalvesaq commented on July 18, 2024

Super, working perfectly fine!

If you do git pull now the Object Browser will auto start faster because I removed the 1 second delay on Unix.

from r.nvim.

PMassicotte avatar PMassicotte commented on July 18, 2024

We can fix that later when we decide what to do with the echo/silent options.

What is your opinion on this? I prefer to eliminate the "echo" parameter from the send functions because users can set the value of source_args as ", echo=TRUE". It's redundant to have both maps for echoing what is being sourced and the option to do this with source_args. I prefer to simplify the functions and reduce the number of key bindings. But if you like the parameter we can keep it.

Make total sens. I up to remove echo.

from r.nvim.

PMassicotte avatar PMassicotte commented on July 18, 2024

Super, working perfectly fine!

If you do git pull now the Object Browser will auto start faster because I removed the 1 second delay on Unix.

Oh this is nice. Open a nanosecond after the terminal. Tx!

from r.nvim.

jalvesaq avatar jalvesaq commented on July 18, 2024

So, please, feel free to remove the "echo" parameter if you have time.

from r.nvim.

PMassicotte avatar PMassicotte commented on July 18, 2024

all right, will do it right now

from r.nvim.

jalvesaq avatar jalvesaq commented on July 18, 2024

I'm implementing the option max_paste_lines...

from r.nvim.

PMassicotte avatar PMassicotte commented on July 18, 2024

Great! The project is taking shape!

from r.nvim.

jalvesaq avatar jalvesaq commented on July 18, 2024

I already tried most features, and they are working. One problem is some key bindings not being activated. When the same function is mapped twice, one with argument false and the other with true, only the second one is active, as we can see with :nmap. This happens at least with SendParagraph, and SendSelection.

from r.nvim.

PMassicotte avatar PMassicotte commented on July 18, 2024

Meaning that

    -- Paragraph
    create_maps("ni", "RSendParagraph",   "pp", "<Cmd>lua require('r.send').paragraph(false)")
    create_maps("ni", "RDSendParagraph",  "pd", "<Cmd>lua require('r.send').paragraph(true)")

Is only mapping the last one?

from r.nvim.

jalvesaq avatar jalvesaq commented on July 18, 2024

Thanks for looking at that!

I found the problem: it was my configuration! I was setting custom key bindings and they were preventing maps.lua to do its job.

My default mapping to send lines of code to R, <Enter> is also preventing me from using the LSP quickfix list. I will create a new hook to overcome this problem.

from r.nvim.

PMassicotte avatar PMassicotte commented on July 18, 2024

oh cool!

from r.nvim.

jalvesaq avatar jalvesaq commented on July 18, 2024

My configuration now is (commented lines ommited):

return {
    dir = '~/src/tmp-R-Nvim',
    config = {
        R_args = {'--quiet', '--no-save'},
        hook = {
            after_config = function ()
                vim.api.nvim_buf_set_keymap(0, "n", "<Enter>", "<Plug>RDSendLine", {})
                vim.api.nvim_buf_set_keymap(0, "v", "<Enter>", "<Plug>RSendSelection", {})
            end
        },
        -- user_maps_only = true,
        auto_start = 1,
        objbr_auto_start = true,
    },
    lazy = false
}

from r.nvim.

PMassicotte avatar PMassicotte commented on July 18, 2024

Great, I will try that when I am back at home in few hours.

from r.nvim.

jalvesaq avatar jalvesaq commented on July 18, 2024

I have had to create some maps conditionally:

    {
        dir = '~/src/tmp-R-Nvim',
        opts = {
            R_args = {'--quiet', '--no-save'},
            hook = {
                after_config = function ()
                    vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rq', '<Plug>RClose', {})
                    vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>ss', '<Plug>RSendSelection', {})
                    vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>sp', '<Plug>RDSendParagraph', {})
                    vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rl', '<Plug>RListSpace', {})
                    vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rm', '<Plug>RClearAll', {})
                    vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rp', '<Plug>RObjectPr', {})
                    vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rn', '<Plug>RObjectNames', {})
                    vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rt', '<Plug>RObjectStr', {})
                    vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rv', '<Plug>RViewDF', {})
                    vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>ra', '<Plug>RShowArgs', {})
                    vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rh', '<Plug>RHelp', {})
                    vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rs', '<Plug>RSummary', {})
                    vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>ro', '<Plug>RUpdateObjBrowser', {})
                    vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>r=', '<Plug>ROpenLists', {})
                    vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>r-', '<Plug>RCloseLists', {})
                    if vim.o.syntax ~= "rbrowser" then
                        vim.api.nvim_buf_set_keymap(0, "n", "<Enter>", "<Plug>RDSendLine", {})
                        vim.api.nvim_buf_set_keymap(0, "v", "<Enter>", "<Plug>RSendSelection", {})
                        vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>sb', '<Plug>RSendMBlock', {})
                        vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>rf', '<Plug>RStart', {})
                    end
                    if vim.o.filetype == "rmd" or vim.o.filetype == "quarto" then
                        vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>kn', '<Plug>RKnit', {})
                        vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>kr', '<Plug>RMakeRmd', {})
                        vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>gn', '<Plug>RNextRChunk', {})
                        vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>gN', '<Plug>RPreviousRChunk', {})
                        vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>sc', '<Plug>RSendChunk', {})
                        vim.api.nvim_buf_set_keymap(0, 'n', '<LocalLeader>sh', '<Plug>RSendChunkFH', {})
                    end
                end
            },
            user_maps_only = true,
            -- clear_line = false,
            auto_start = 1,
            -- bracketed_paste = false,
            objbr_auto_start = true,
            term_title = "tmux",
            -- external_term = "foot",
        },
        lazy = false
    },

from r.nvim.

PMassicotte avatar PMassicotte commented on July 18, 2024

You have to do it to avoid duplicated map? On my side all works fine (maybe I missed something)

from r.nvim.

PMassicotte avatar PMassicotte commented on July 18, 2024

Good to know!

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.