jalvesaq / Nvim-R

Vim plugin to work with R
GNU General Public License v2.0
962 stars 125 forks source link

enable plugin if .here file is present in folder #468

Closed olesendan closed 11 months ago

olesendan commented 4 years ago

Hi Jalvesaq.

Do you think if it is possibly to implement some kind og check on startup.

The check would be, is there any file namesd .here. and then if there is a file, then the plugin is enabled?

Your thourths regarding this?

Greetings from denmark Dan Olesen

jalvesaq commented 4 years ago

What are .here files?

olesendan commented 4 years ago

.here files is a file, used by the here package. when this file is in a folder, then the here package is able to set that folder as the root folder for a R project.

jennybc explaines it way better then me https://github.com/jennybc/here_here

In my usercase i'm using .here files as .Rproj files, because I'm not using Rstudio.

my workflow for a new project. make a folder cd to folder open radian usethis_use::description() usethis::use_readme() usethis::use_license() close radian open nvim

It would be nice, if I could this make folder cd to folder start nvim :! touch .here ",rf" usethis::use_description() .....

Does this make sense?

Greetings from denmark Dan Olesen

jalvesaq commented 4 years ago

Unfortunately, I can't add support for all packages that have specific needs. But if someone wanted to write a complement to Nvim-R, I can add a link to it at the section Source additional scripts of Nvim-R's documentation.

In the meanwhile, you could try this in your vimrc/init.vim:

set autochdir
olesendan commented 4 years ago

Hi Jalvesaq.

thank you for your suggestion. I tried it, but nothing seems to change.

I've tried your suggestion in the docs, to enable nvim-r global. Strangelly enough nothing happens when I have tihs command

command RStart let oldft=&ft | set ft=r | exe 'set ft='.oldft | let b:IsInRCode = function("DefaultIsInRCode") | normal rf

If I use the shortcut "rf" nothing happens. If I use the command ":RStart" nvim-r starts R. So I'm doing something wrong, resulting in the command not being mapped.

jalvesaq commented 4 years ago

The shortcut <LocalLeader>rf doesn't work before :RStart because the file type was never set to "r" and, thus, none of Nvim-R commands are available yet. After the command :RStart, you can close R with <LocalLeader>rq and, then, open it again with <LocalLeader>rf.