Permalink
Browse files

R lint and svtools: fix CWD for Windows.

On Windows R is run with CWD set to the directory used at install time,
rather than the current directory.  The official workaround for this is
to add links to R from the home directories of each of your projects.
We can't do that in Vim, but we can call `setwd()` to Vim's idea of
current directory.  This mimics the behaviour of R on UNIX.
  • Loading branch information...
1 parent dd5ca1f commit bd7e34757d73f6ed95f41f178fd9e2b4a5e49eeb @lcd047 lcd047 committed Jun 14, 2014
Showing with 7 additions and 3 deletions.
  1. +1 −1 plugin/syntastic.vim
  2. +4 −1 syntax_checkers/r/lint.vim
  3. +2 −1 syntax_checkers/r/svtools.vim
View
@@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:syntastic_start
endif
-let g:syntastic_version = '3.4.0-85'
+let g:syntastic_version = '3.4.0-86'
lockvar g:syntastic_version
" Sanity checks {{{1
@@ -39,8 +39,11 @@ function! SyntaxCheckers_r_lint_IsAvailable() dict
endfunction
function! SyntaxCheckers_r_lint_GetLocList() dict
+ let setwd = syntastic#util#isRunningWindows() ? 'setwd("' . escape(getcwd(), '"\') . '"); ' : ''
+ let setwd = 'setwd("' . escape(getcwd(), '"\') . '"); '
let makeprg = self.getExecEscaped() . ' --slave --restore --no-save' .
- \ ' -e ' . syntastic#util#shescape('library(lint); try(lint(commandArgs(TRUE), ' . g:syntastic_r_lint_styles . '))') .
+ \ ' -e ' . syntastic#util#shescape(setwd . 'library(lint); ' .
+ \ 'try(lint(commandArgs(TRUE), ' . g:syntastic_r_lint_styles . '))') .
\ ' --args ' . syntastic#util#shexpand('%')
let errorformat =
@@ -51,8 +51,9 @@ function! SyntaxCheckers_r_svtools_GetLocList() dict
return []
endif
+ let setwd = syntastic#util#isRunningWindows() ? 'setwd("' . escape(getcwd(), '"\') . '"); ' : ''
let makeprg = self.getExecEscaped() . ' --slave --restore --no-save' .
- \ ' -e ' . syntastic#util#shescape('library(svTools); ' .
+ \ ' -e ' . syntastic#util#shescape(setwd . 'library(svTools); ' .
\ 'try(lint(commandArgs(TRUE), filename = commandArgs(TRUE), type = "flat", sep = ":"))') .
\ ' --args ' . syntastic#util#shexpand('%')

0 comments on commit bd7e347

Please sign in to comment.