Git Product home page Git Product logo

vim-scala's Introduction

vim-scala

This is a "bundle" for Vim that builds off of the initial Scala plugin modules by Stefan Matthias Aust and adds some more "stuff" that I find useful, including all of my notes and customizations.

Installation

You really should be using Tim Pope's Pathogen module for Vim (http://tammersaleh.com/posts/the-modern-vim-config-with-pathogen) if you're going to clone this repository because, well... you should.

Using the command-line

Using wget:

mkdir -p ~/.vim/{ftdetect,indent,syntax} && for d in ftdetect indent syntax ; do wget -O ~/.vim/$d/scala.vim https://raw.githubusercontent.com/derekwyatt/vim-scala/master/$d/scala.vim; done

Using cURL:

mkdir -p ~/.vim/{ftdetect,indent,syntax} && for d in ftdetect indent syntax ; do curl -o ~/.vim/$d/scala.vim https://raw.githubusercontent.com/derekwyatt/vim-scala/master/$d/scala.vim; done

Vundle

Alternatively, you can use Vundle to manage your plugins.

If you have Vundle installed, simply add the following to your .vimrc:

Plugin 'derekwyatt/vim-scala'

and then run

:PluginInstall

to install it.

Sorting of import statements

:SortScalaImports

There are different modes for import sorting available. For details, please consult the vimdoc help with

:help :SortScalaImports

Scaladoc comment indentation

By default, the plugin indents documentation comments according to the standard Javadoc format

/**
 * This is a doc comment using Javadoc-style indentation.
 */

To enable the indentation standard as recommended for Scaladoc comments (from http://docs.scala-lang.org/style/scaladoc.html, since Scaladoc2), add the command let g:scala_scaladoc_indent = 1 to .vimrc file, e.g:

/** This is a Scaladoc comment using the recommended indentation.
  * let g:scala_scaladoc_indent = 1
  */

vim-scala's People

Contributors

0xqd avatar ab avatar blast-hardcheese avatar ches avatar crater2150 avatar derekwyatt avatar dinduks avatar euclio avatar evverx avatar gordiandziwis avatar henrytill avatar igorfrenkel avatar jamessan avatar jdanbrown avatar jimenezrick avatar jsatk avatar kopiczko avatar leonardehrenfried avatar mmorearty avatar nathanalderson avatar normenmueller avatar pankajroark avatar pritchett avatar ratanrsur avatar richashworth avatar sprsquish avatar todesking avatar ujihisa avatar veloce avatar zoonfafer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-scala's Issues

Syntax highlighting

Hi Derek,

I've compared the current master head (ba87018) with 38f8fda, here are two screenshots:

ba87018:
vim-scala-syntax-master

38f8fda:
vim-scala-syntax-38f8fda

I found 3 issues:

  1. In the previous version, the return type was nicely highlighted, while it's not in the current version.
  2. In the current version, the tail is highlighted as a type, which I guess is a bug and happens because it's preceded with a colon.
  3. In the current version, parentheses in type declarations like List[(Int, Int)] are not highlighted.

One more suggestion is to add highlighting of all uses of a variable. Currently, the variable name is only highlighted in the declaration.

Otherwise, it works great, thanks a lot for your awesome work!

Best regards,
Anton

Pathogen Install

I've cloned this repo into my ~/.vim/bundle folder just like all other plugins (you can see my dotfiles) but alas no plugin is detected. I've tried just a few of the basic commands (ie SortScalaImports) without luck.

In addition to cloning am I required to also run the wget/curl command or am I missing something painstakingly obvious?

sbt.scala

au BufRead,BufNewFile *.sbt setfiletype sbt.scala in fdetect/scala.vim causes all .sbt files to be picked up by syntastic. You might want to add the following to your README.md to get around this:

If you use syntastic it will pick up .sbt files for checking. To get around this, add the following to your .vimrc:

" SBT
" required to disable syntastic checking.
augroup filetype_sbt
  autocmd!
  autocmd BufNewFile,BufRead *.sbt set filetype=sbt
  autocmd FileType sbt setlocal syntax=scala
augroup END

Spell check does not work for comments

Hi,

I wanted to use Vim's spell checker for my Scala code. It did not work until I changed this line in the syntax file:

syn region scalaDocComment start="/\*\*" end="\*/"  contains=scalaDocTags,scalaTodo,@scalaHtml,@Spell keepend

I don't know if this is clean. However, it would be nice if the syntax file would be changed to support spell checking in the comments.

syntax for case class

Hello, thanks for your work, it makes my life easier.

I just wanted to point out that since the recent refactoring of the syntax file, the case class are not correctly hilighted.

Not expecting to see a fix anytime soon, of course. I just wanted to have it written somewhere.

Thanks

Indentation after commented lines

Hi,

Let's take a look at this code snippet:

val foo = "foo".toUpperCase
  //.toLowerCase

If I add, let's say, val bar = "bar" right after the commented line, the last line gets the same indentation level as the previous one.

val foo = "foo".toUpperCase
  //.toLowerCase

  val bar = "bar"

This shouldn't happen, as the commented line should somehow be ignored, and not taken into account when counting the indentation value.

I'll try to make a PR soon.

Samy

Wrong syntax parsing

This is not correctly parsed:

class OpiBrowseController(queryProcessor: QueryProcessor) {                  
  def getAll(keyword: Option[String], from: String, size: Int): Seq[Opi] = { 

  }                                                                          
}                                                                            

But If I remove type at the end of the def it parsed correctly:

class OpiBrowseController(queryProcessor: QueryProcessor) {                  
  def getAll(keyword: Option[String], from: String, size: Int) = { 

  }                                                                          
}                                                                            

Slow file writes?

I noticed after installing this plugin any writes to a scala file takes a considerable amount of time, regardless of file size. I didn't find any BufWritePre or something that I thought would be the culprit. Could you shed any light on that or is this something unusual?

Pick a real license

I'd like to strongly urge you to read up on open-source licensing and actually pick a license. As an open-source developer, it's extremely important that you familiarize yourself with the basic licenses and use one that's been legally vetted.

Technically, your current position of "no license" means that nobody is allowed to use this software except you: copyright law reserves all rights to the copyright holder except those explicitly granted to licensees.

You make things even more messy when you say "you can do whatever you want" but "you can't take credit for my work." These two statements contradict one another. You have to worry about legal liabilities if you say something like "do whatever you want." (E.g., does that include using it in a medical device? are you prepared for the legal ramifications if someone dies because your software was buggy?) You can be sued if you accidentally imply some kind of warranty.

GitHub is wise to recommend the Apache 2 license to people as the default. It is the most popular "do whatever you want" license. It protects you thoroughly while granting anybody the ability to use anything you published for any purpose—provided the user takes on any risks or obligations. Redistributors are not allowed to remove your copyrights from the code and must retain your NOTICE file. (This is a legal version of "don't take credit for my work.")

If you just want to make your software available for people to use as widely as possible, Apache 2.0 is your best bet. It's extremely permissive while also being defensible enough for big companies like Google to use.

Wrong syntax parsing

Hi Derek,

Here is an other one where the code don't get parsed correctly:

trait Template[T] extends Renderable[Iterable[T]] {
  def update(_fields: Seq[Renderable[T]]) = new Template[T] {
    def fields = _fields
  }
}

Picture here: http://tinypic.com/r/1g55xd/6

Can't get it work with Vundle

Hi,

This is probably some silly mistake that I am making, but I'm trying to install the plugin with Vundle:

https://github.com/katcipis/my.vim/blob/master/vimrc#L73

And no magic happens :-(. I can see the plugin installed on my ~/.vim, but when I open a File.scala there is no syntax highlighting, nothing. Is there something else that I have to do get it working ?

I executed the Vundle install command, actually all the others plugins that I have are working, except vim-scala.

error in help file syntax additions

I get this error message when opening any help file inside vim.

$ vim -c ':help'

"help.txt" [readonly] 217L, 8055C
Error detected while processing /home/andy/.vim/bundle/vim-scala/after/syntax/help.vim:
line    4:
E399: Not enough arguments: syntax region rgnScala matchgroup=Ignore concealends start='!sc!' end='!/sc!' contains=@ScalaCode
E399: Not enough arguments: syntax region rgnScala matchgroup=Ignore concealends start='!sc!' end='!/sc!' contains=@ScalaCode
Press ENTER or type command to continue

Quasiquotes extractor

Hi,

The quasiquotes assignment like this is not highlighted correctly

val q"val $name = $value" = someTree

maybe scala.xpt.vim should be under a directory named scala

i use Vundle install vim-scala and xptemplate , and something wrong

error ocure file : ftplugin\xpt\xpt.xpt.vim

let s:xpt_snip = split( globpath( &rtp, "ftplugin/**/*.xpt.vim" ), "\n" )
call map( s:xpt_snip, 'substitute(v:val, ''\V\'', ''/'', ''g'')' )
call map( s:xpt_snip, 'matchstr(v:val, ''\Vftplugin/\zs\.\*\ze.xpt.vim'')' )

for v in s:xpt_snip
    echoerr v  " debug 
    let [ ft, snip ] = split( v, '/' )
    ...
endfor

debug output:

_comment/c.like
...
java/java/
javascript/javascript
...
scala

when "scala" output, err occur, because 'scala' can't be splited by '/'.

so i think scala.xpt.vim should placed under a new dir named scala.

Import scala plugin from scala-dist

scala-dist includes vim support code, but it's not very maintained. Could you integrate the useful bits?

One bit is the templating system, touched by this pull request (open since ages): scala/scala-dist#80

However, you need a license for that!

Comma backsearch seems not working

Hi,

I just tried the plugin, it's excellent. But the comma key seems not working properly. I have to type the comma key twice to search backward.

I'm using vim 7.4 at the moment. The comma key worked properly if I start vim without any configuration.

Custom indentation overriden.

When I set my tabstop and shiftwidth to 4, the plugin seems to override it to 2. I've used ack-grep to find out that the only existances of such override occur in "vim-scala/ftplugin/scala.vim".

My workaround is to simply delete this overrides so it can use my settings. It works but I have no idea what could it break - hopefully nothing.

Installation instructions

Can you please provide "a dummy's guide to installation of this plugin"... for dummy's in a hurry?

Error in opening scala files

Does this plugin intends to be a fully featured scala IDE ?

If not why is it trying to compile the scala buffer, I keep on getting

"core/src/main/scala/spark/api/python/PythonPartitioner.scala" 48L, 1442C
Couldn't determine class path.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error resolving version for 'net.alchim31.maven:scala-maven-plugin': Plugin requires Maven version 3.0
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Fri Feb 22 16:48:39 IST 2013
[INFO] Final Memory: 5M/239M
[INFO] ------------------------------------------------------------------------

I am sorry if some other plugin is doing this, But i faced this problem since today when i pulled the repo.

Error occurs when open a scala file

When open a scala file, I got the following:

Executed command: "'/usr/local/bin/ctags'  -f -  --format=2  --excmd=pattern  --fields=nksSa  --extra=  --sort=yes  --language-force=scala --scala-kinds=pVvTtoacrm  '/var/folders/sb/w1x7dlfx1059_ftd44q1k5x80000gn/T/vS1Wt9z/11.scala'"
Command output:
ctags: Unknown language "scala" in "language-force" option
Press ENTER or type command to continue

When enter, it works fine, syntax are highlighted correctly, but it's really annoying that I have to see this and press an extra enter key for every new opened file. Please help.

Highlighting issue related to annotations

In the following code, everything inside the respond function is highlighted as a string.

object Foo {
  @Get
  @Route(Array("/{:Version}/path_to"))
  def respond(r: Req) = {
    println("Hello world")
  }
}

However, if you remove the outer object, it highlights correctly.

@Get
  @Route(Array("/{:Version}/path_to"))
  def respond(r: Req) = {
    println("Hello world")
  }

This seems to happen with classes, objects, traits, outer functions -- basically any curly-brace block.

Screenshots:

screen shot 2014-10-29 at 10 31 58 am
screen shot 2014-10-29 at 10 32 12 am

Triple Quasi Quotes ending with "

Hi, the following string, for example, is not highlighted correctly and messes up highlighting for the rest of the document.

s"""bar="foo""""

Cannot give ScalaSquareBrackets a custom color

Hi, I'm writing my own colorscheme with focus on Scala.

When I'm trying to give ScalaSquareBrackets a custom one it doesn't work:

hi scalaSquareBrackets guifg=#006fe6 guibg=NONE guisp=NONE gui=bold

Is this a bug or am I doing something wrong?

Thanks!

Syntax for symbol

Hi Derek,

Would you mind adding a syntax for scala symbol?

Maybe this is sufficient:

syn match scalaSymbol "'\w\+\%([^']\)\@="
hi link scalaSymbol Constant

syn match scalaChar "'\w'"
hi link scalaChar Character

Thanks.

Syntax highlighting failure on `+:` pattern match

The following highlights incorrectly:

case entity +: Nil => Some(x)

Nil is registering as a Type (which is probably OK), but that bleeds across all the way to the ( -- i.e. => Some is also a Type.

Indentation failure for brackets

As per 895f6a4

Expected:

  def createTables {
    import org.scalaquery.ql.extended.SQLiteDriver.Implicit._ 
    try {
      db withSession {
        Users.ddl.create
      }
    } catch {
      case e => println(e)
    }
  }

Actual:

  def createTables {
    import org.scalaquery.ql.extended.SQLiteDriver.Implicit._ 
    try {
      db withSession {
        Users.ddl.create
  }
} catch {
  case e => println(e)
    }
}
  }

Question: Is it okay to convert the Readme to markdown?

I'm currently adding a vim command to this repo that can automatically sort Scala imports. A pull request will be coming in a few days/weeks.

I would like to add documentation but I prefer properly formatted and syntax-highlighted code blocks. This can be achieved with Github's Markdown parsing.

Are you ok with me converting the Readme to markdown?

Indentation problem for `}`?

The following is what is indented by vim-scala. The last } is indented one level. Shouldn't it be unindented?

object HelloWorld {
  def main(args: Array[String]) {
    println("Hello, world!")
  }
  }

Syntax mis-highlights function parameter type

image

The default value for parameter f is mis-highlighted.

This is caused by a royal PITA. The brackets aren't actually set up as a region. If they were, then I could say that => follows that region and keep things to the scope of types. But, I can only have one region defined that begins as (, and that causes problems. I could use a match but you can't easily (or at all?) have matches contain the same matches recursively, like you would with regions. I could go on... but it's easier to sum it up as a PITA.

XML breaks indentation

XML notation breaks indentation and is not properly indented itself:

vim-scala xml break indent

Excuse my terseness, not sure what else to mention.

Another example, notice awkward indentation and highlighting of the curly braces:

ensime

did you ever get anywhere with ENSIME integration?

The server has recently seen a bit of a revival, we'd love to gain more contributors and a good go-to Vim extension that uses ensime :-)

Alternative solution for ftplugin

Hi,

Instead of removing the default values of tabstop, etc. from ftplugin, I suggest instead to add a global variable that can be set by the user in the vimrc. Maybe something like this:

if !exists('g:vim_scala_own_settings') || !g:vim_scala_own_settings
  setlocal textwidth=140
  setlocal shiftwidth=2
  setlocal softtabstop=2
  setlocal expandtab
  setlocal formatoptions=tcqr
endif

Thanks.

Vim high CPU usage

When I open more than 8 files Vim makes heavy load on the CPU.
If I remove the plug-in (syntax highlighting) then everything is OK.

Syntax highlight error on xpath expression

val xml = <xml><text>abc</text></xml>
val text = (xml\"text").text

\ was treated as escape character instead of xpath child searching function.
Current solution: add a space after \.

highlight_error

Loosing syntax highlighting when flipping buffers

Hi - Firstly thanks for this nice plugin
When I first launch vim <somefile.scala> it shows the syntax highlighting
However if I flip to another scala file it looses its colors
If I do : set filetype=scala in the new buffer the colors become visible.
What am I missing here ?

My .vimrc file looks like this
5 set ai
6 set sw=4
7 set nowrap
8 set incsearch
9 set hlsearch
10 set guifont=Liberation\ Mono\ 10
11 set nobackup
12 set ruler
13 set nu
14 set fileformat=unix
15 highlight search ctermfg=12 ctermbg=3
16 highlight Identifier ctermfg=4
17 highlight Statement ctermfg=5
18 filetype plugin on
19 let g:pydiction_location = '/.vim/plugin/complete-dict'
20 set tags=tags,./tags,$PROJTOP/tags
21 "autocmd BufEnter * if expand("%:p:h") !
'^/tmp' | lcd %:p:h | endif
22 set autochdir
23 colorscheme murphy
24 syntax on

indentation problem with "case"

Below is my code pasted from "scala for the impatient" book.

class HiActor extends Actor {
def act() {
while (true) {
println("In")
receive {
case "Hi" => println("Hello")
}
}
}
}

This code works, but under this code, I get problem with indentation.
When I use "case" syntax, (i.e. to declare case class), it auto-indents to match the tab of case above.

slow saving

is anybody experiencing delayed saving with the plugin enabled?

if so, is there any solution for it?

thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.