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

RBuildTags gives message: 'file "etags" exists ...' but it doesn't. #349

Closed
rg-ch opened this issue Feb 26, 2025 · 12 comments
Closed

RBuildTags gives message: 'file "etags" exists ...' but it doesn't. #349

rg-ch opened this issue Feb 26, 2025 · 12 comments

Comments

@rg-ch
Copy link

rg-ch commented Feb 26, 2025

I've created a newdirectory
and I copied myfunc.R inside
opend it with nvim myfunc.R
launched R

:RBuildTags gives me the following messages

The file "etags" exists. Please, delete it and try again.

Image see below.

I found the same message here below but I can't find an etags file in the directory to delete.
Corresponding to the help message RBuildTags only creates etags files in the working directory, doesn't it ?

Image

Can you reproduce this. Can You tell me if etags works also for Rmd and Rnw files or is it limited to R and r files (default pattern in rtag).

Thanks in advance !

@jalvesaq
Copy link
Member

I didn't try to reproduce... When I read the first sentence of the bug report, I already knew what was causing the problem: In Lua, 0 evaluates to true. I made this mistake many times when translating from VimScript to Lua. The bug has been there since February 2024. Please, try the branch "etags".

@rg-ch
Copy link
Author

rg-ch commented Feb 26, 2025

It tried the etags branch. It works now for R and r files. That's great ! Thanks you very much for your very fast reaction. I think the best way, is to source("myfunc.R") in Rmd-files in order to be able to use tags, isn't it ?
Or can I tag functions in rmd or rnw chunks including this extensions in the rtags pattern ?
I have no experience. What do you think ?

@jalvesaq
Copy link
Member

I remember using this feature only very infrequently and a long time ago. The function was created with someone developing an R package in mind. The function should be helpful in the "R" directory. Possibly there is a better LSP alternative...

@jalvesaq
Copy link
Member

Trying LSP (languageserver): if the buffer where the function is defined has been opened, you can jump to it. For example, I mapped gd to vim.lsp.buf.definition(). If I go to the nvimcom/R directory and open misc.R and then :e help.R, pressing gd in Normal mode over nvim.getclass will make the cursor jump to the function definition in misc.R.

@jalvesaq
Copy link
Member

I'll merge the "etags" branch and close this issue. However the feature can be removed in the future if we agree that LSP is better. Currently, LSP recognizes R functions in Rmd files, but not in Quarto or Rnoweb ones.

Thanks for reporting the bug and for trying the branch!

@rg-ch
Copy link
Author

rg-ch commented Feb 28, 2025

You're welcome. Thanks for all your explanations. I think I need first to setup LSP for tryout, but I didn't find a simple setup and I'm a lua dummy.

Perhaps we shouldn't remove RBuildTags because it creates recursively all tags, even for simple variable creation without opening any R file. And it works in Rnw.

Would LSP also find rf_Stats in the following declaration.

Image

I remind you that I have no idea about the capacity of languageserver. You surely better know what to keep and to remove.
Best regards Roman

@PMassicotte
Copy link
Collaborator

I agree that this could be eventually be removed. air lsp will eventually add more stuff and made navigation much easier.

@rg-ch
Copy link
Author

rg-ch commented Feb 28, 2025

@PMassicotte : I can't find a minimal configuration for air lsp on r.nvim. I found only the following Note: If you are using the languageserver package, you should disable its auto completion feature in your ~/.Rprofile to get completions from cmp-r.

@PMassicotte
Copy link
Collaborator

Air only format code at the moment. They are working to add more capabilities.

@PMassicotte
Copy link
Collaborator

See posit-dev/air#270

@rg-ch
Copy link
Author

rg-ch commented Feb 28, 2025

OK thanks a lot for the indication.

@PMassicotte
Copy link
Collaborator

As mentioned by @jalvesaq, you could try to install rlanguageserver, it works relatively well for some operation, like going to definition, reference, renaming, etc. Please let us know how it goes.

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

No branches or pull requests

3 participants