Ⅰ. 插件描述
Extension for vim-r-plugin to support the devtools packageⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'mllg/vim-devtools-plugin'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'mllg/vim-devtools-plugin'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'mllg/vim-devtools-plugin'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/mllg/vim-devtools-plugin
Ⅳ. 文档说明
# vim-devtools-plugin
Extension for the vim plugins Vim-R-Plugin and Nvim-r to support the devtools R package.
Installation
Use your favourite bundle manager to install this script, e.g.:
" Vundle
Plugin 'mllg/vim-devtools-plugin'
" Neobundle with lazy load
NeoBundleLazy 'mllg/vim-devtools-plugin',
\ {'autoload' : {'filetypes' : ['r','rmd','rnoweb']}}
" dein with lazy load
call dein#add('mllg/vim-devtools-plugin', {'on_ft' : ['r', 'rmd', 'rdoc', 'rnoweb']})
" Vim-Plug with lazy load
Plug 'mllg/vim-devtools-plugin', { 'for': ['r', 'rmd', 'rnoweb']}Available commands
RLoadPackage <dir>: Runsdevtools::load_all.RUnloadPackage <dir>: Runsdevtools::unload.RBuildPackage <dir>: Runsdevtools::build.RCheckPackage <dir>: Runsdevtools::check.RTestPackage <dir> <filter>: Runsdevtools::testusing specified filter (default'').RTestFile: Runsdevtools::testsetting a filter to test the current file.RDocumentPackage <dir>: Runsdevtools::documentRMakePackage <dir>: Runsdevtools::document, thendevtools::install.RSetupTest <dir>: Loads "testthat" and invisibly sources all files matching pattern^helperin the test directory.RSourceFile <file>: Sources the given file. If argument <file> is omitted, either the master file (if set, see below) or the current buffer gets sourced.RBuildPackgeTags <dir>: Builds a tag file for the package and stores it ing:devtools_rtags_dir(default is "~/.rtags"). All tag files in this directory will automatically added to &tags for file typesr,rnowebandrmd.RUsage <dir>: Loads the package and callscodetools::checkUsagePackage(). Reported problems are send to the quickfix window.RSetMaster <file>: Declare <file> the master file. Used in:RSourceFile. If <file> is omitted, the current buffer is declared as master. Note that this choice is not persistent between vim sessions.
The DESCRIPTION file is searched in <dir> and all its parents.
Default for <dir> is the directory of the current buffer.
If you do not want all these commands to be defined, set the option devtools_commands:
let g:devtools_commands = 0Support for FZF
If you are a user of FZF, you can grep your R history file with the following setup:
Make R history persistent across sessions
Put the following code in your .Rprofile, preferably inside the .First function:
if (interactive()) {
history_file = normalizePath("~/.Rhistory", mustWork = FALSE)
ok = try(utils::loadhistory(history_file))
if (inherits(ok, "try-error")) {
message("History could not be loaded: ", history_file)
} else {
message("Loaded history: ", history_file)
.Last <<- function() try(utils::savehistory(history_file))
}
}Create new command
function! s:fzf_r_history()
let l:history_file = expand('~/.Rhistory')
call g:devtools#send_cmd('utils::savehistory("' . l:history_file . '")')
call fzf#run({
\ 'source': 'cat ' . l:history_file . ' | grep -v "# \\[history skip\\]$" | uniq',
\ 'sink' : g:SendCmdToR,
\ 'options': '--no-sort --tac',
\ 'down' : '40%' })
endfunction
command! RHistory call s:fzf_r_history()Map to a key as you find appropiate.