vim-pandoc / vim-rmarkdown

Rmarkdown support for vim
98 stars 26 forks source link

RMarkdown not working on Windows system #34

Open santibreo opened 4 years ago

santibreo commented 4 years ago

Hi,

I am using your plugin with both vim-pandoc and vim-pandoc-syntax as they are required but I can't compile the Rmarkdown documents into any format because I am working with a Windows computer (we all hate Windows but we all need to work for a living). The error is pretty straightforward: the vim function expand("%:p") that you are using in vim-rmarkdown/autoload/rmarkdown/command.vim (lines 89 and 94) gives the file path using single backslashes which R interprets as if they were escaping characters. The minimal-effort-but-not-so-elegant workaround that I have found is:

45  -   let @9 = @+
46  -   let @+ = expand("%:p")
...
87 -    if output_type == "revealjs_presentation"
88 -        let invocation = 'Rscript -e "library(rmarkdown);library(revealjs);render('. 
89 -                        \ 'readClipboard(), '. 
90 -                        \ 'revealjs_presentation()' .
91 -                        \ render_opts.')"'
92 -    else
93 -        let invocation = 'Rscript -e "library(rmarkdown);render('. 
94 -                    \ 'readClipboard(), '. 
95 -                    \ output_type_arg .
96 -                    \ render_opts.')"'
97 -    endif
...
123-   let @+=@9 

This way it should work but now I am getting:

Error: Unrecognized output format specified

Which is because R is not understanding the format type \"html_output\". Any idea about how to solve this?

Thanks a lot!

santibreo commented 4 years ago

I have found a solution myself. It is not the most elegant but it works. All my problems are related with the use of single and double quotes, once the Windows backslash issue has been solved.

I added a version of command.vim with minimal changes that is actually working for me (saved as txt to upload, but its extension is vim). my_version.txt

alerque commented 4 years ago

Can you submit this directly as a PR so that we we can see how tests run, whether other users can run it, and compare how it works on *nix? We can easily iterato on a PR, it's not really feasible to iterate throwing files around like this.