Ⅰ. 插件描述
Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'stevendobay/vist'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'stevendobay/vist'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'stevendobay/vist'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/stevendobay/vist
Ⅳ. 文档说明
# ViST - Vi Scala+SBT Tools 0.3
Moved to gitlab
Requirements: Neovim 0.16.x+ or Vim 7.4.x+, SBT 0.13.x, sed, *nix
NOTE: ViST uses command line utilities(unix as an IDE) and SBT to help the developer.
It doesn't use contextual tools, therefore it isn't as advanced as an IDE but far less bloated and much faster.
ViST features:
- Syntax highlighting/detection for Scala and SBT files(thanks for derekwyatt and others for vim-scala)
- Create new SBT project from scratch
- Highlight errors after compilation
- Navigate between errors
- Rename definitions
- Find classes, traits, objects and functions
- Search for definitions in Sources with CTags
- Inspect methods of types and objects in the REPL(outside of vim, of course)
Installation
vim-plug:
Plug 'stevendobay/vist'
:source %
:PlugInstallvundle:
Plugin 'stevendobay/vist'
:source %
:PluginInstallpathogen:
cd ~/.vim/bundle ; git clone https://github.com/stevendobay/vist
neobundle:
NeoBundle 'stevendobay/vist'
:source %
:NeoBundleInstallProject Creation
Syntax: :SNewSBTProject project_name scala_version create_main_class add_default_plugins
"project_name" will set the name of the project like name := "$project_name"
"scala_version" will set the scala compiler & interpreter version: scalaVersion := "$scala_version"
"create_main_class" is a number, if it's bigger than 0 then a hello-world style Main object will be created under src/main/scala
"add_default_plugins" is a number, if it's bigger than 0 then some sbt plugins like sbt-coursier and scalafmt will be added to project/plugins.sbt
The "scalacOptions" section will contain "-encoding UTF-8", "-deprecation", "-unchecked", "-feature",
"-Xfatal-warnings", "-language:implicitConversions" and "-language:higherKinds".
There are other things which aren't mentioned, but they're hidden in comments.
Building
Type :SSetProject to set the current directory as the project folder, it'll be set at startup.
Type :SMake to build the project by sbt, the compilation output will be in "$project_dir/.comp_out".
Navigate with the :SNextError and :SPreviousError commands between the errors.
Turn off error highlighting by :SHideErrors.
Load all scala files from the "src" directory by :SLoadSrc.
Rename definitions
Syntax1: :SRenameWithSBT new_name - replaces the word under the cursor with "new_name" with the help of SBT.
It replaces at the definition's site first and starts a build to get hints from the compiler. After the build has finished
it'll use the sed command line utility to replace the occurences(whole word search) in the lines with errors.
Syntax2: :SRenameWithConfirm new_name - replaces the word under the cursor with "new_name" in each opened buffer. It requires user confirmation for all occurences(but y[es]/n[o]/a[ll]/q[uit] will be there).
Search in Sources
:SClass C - find all classes with their names starting with "C":STrait C - find all traits with their names starting with "C":SObject C - find all objects(singleton classes) with their names starting with "C":SDef C - find all functions(def only!) with their names starting with "C"
You can step between the found sources with :cnext and :cprev.
Search for definitions in Sources with CTags
Type :SInstallCTags to install ctags definition for scala under "~/.ctags".
If it already contains a language definition for scala, the operation will be skipped!
The program "Exuberant CTags" need to be installed!
Type :SGenCTagsSrc to generate a ctags file for the sources under "src".
You'll be able to find the generated file in the "tags" file. To use it, you need to type :set tags=tags.
You can search for a definition named "MyDefinition" like ":tag MyDefinition".
To add multiple source directories, put their path in a file, like "ctags_list.txt" and use :SGenCTagsFromList ctags_list.txt.
Type/Object Inspection
In your vist installation there is a file "E.scala", you can load it into the scala REPL with:load path-to-vist/E.scala. It's recommended to use it in the "sbt console". To get up-to-date info about
its usage, type "E.help" in the REPL.
Default settings
By default, vist sets the tabstop, shiftwidth and softtabstop to 2 for scala and sbt files!
Internal Variables(be careful with these!)
let g:compilationOutputFile = ".comp_out" "the output of the compilation will be stored here
let g:compileCmd = "sbt -no-colors compile" "this is how the compilation will be performed
let g:currentProject = "" "this is where the path to the current project is stored
let g:errors = {} "dictionary of errors({'filepath:line number' : 'error message'})
let g:errorIndex = -1 "the index of the current error