derekwyatt / vim-scala Goto Github PK
View Code? Open in Web Editor NEWMy work on integration of Scala into Vim - not a ton here, but useful for me.
Home Page: http://derekwyatt.org
License: Apache License 2.0
My work on integration of Scala into Vim - not a ton here, but useful for me.
Home Page: http://derekwyatt.org
License: Apache License 2.0
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.
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.
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?
Hi,
The quasiquotes assignment like this is not highlighted correctly
val q"val $name = $value" = someTree
It'll just keep the dependency on XPT where it belongs - i.e. if you don't install XPT then you aren't bothered by the inclusion of this stuff in the scala plugin.
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' '^/tmp' | lcd %:p:h | endif
20 set tags=tags,./tags,$PROJTOP/tags
21 "autocmd BufEnter * if expand("%:p:h") !
22 set autochdir
23 colorscheme murphy
24 syntax on
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.
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
.
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!")
}
}
Hi, the following string, for example, is not highlighted correctly and messes up highlighting for the rest of the document.
s"""bar="foo""""
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
Can you please provide "a dummy's guide to installation of this plugin"... for dummy's in a hurry?
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.
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) = {
}
}
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.
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.
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
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)
}
}
}
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
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 type
s. 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.
diff --git a/syntax/scala.vim b/syntax/scala.vim
index a61a60a..e83635b 100644
--- a/syntax/scala.vim
+++ b/syntax/scala.vim
@@ -4,6 +4,8 @@ elseif exists("b:current_syntax")
finish
endif
+scriptencoding utf-8
+
let b:current_syntax = "scala"
syn case match
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.
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
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.
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?
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:
How to replicate:
$ vim file1.scala
<ctrl-w> s
:e file2.scala
Outcome: No syntax highlighting for new window.
Expected: Highlighting for new window.
It'll be good if vim-scala can override the default tabspace in user configuration file with ts=2, this is the recommended coding standard for scala.
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.
is anybody experiencing delayed saving with the plugin enabled?
if so, is there any solution for it?
thanks
I had to do a find . -iname "*" | xargs dos2unix for the plugin to work on windows zsh.
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.
Hi Derek,
I've compared the current master head (ba87018) with 38f8fda, here are two screenshots:
I found 3 issues:
tail
is highlighted as a type, which I guess is a bug and happens because it's preceded with a colon.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
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?
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.
This highlights just fine:
def f: List[Int]
but this doesn't:
def f:
List[Int]
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 :-)
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!
I would like to do two things to this project and I was wondering if you are okay with that:
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
I have vim-sbt installed but if it is load before vim-scala then *.sbt will have the scala
filetype and the syntax highlighting will be wrong.
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!
This causes a noticeable delay when opening vim helps.
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.
object Foo {
def foo {
val bar = { item =>
}
wrong
}
}
Looks like this on 7.4.491.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.