4537: Support for kotlin

pschiffer

What version are you running?

2.5.7

What's the URL of the page this enhancement relates to, if any?

diff viewer

Describe the enhancement and the motivation for it.

Support for kotlinsyntax highlighting seems to be missing. Pygments should support kotlin files but something prevents the file to be correctly highlighted.

What operating system are you using? What browser?

Ubuntu 14.04 / Chrome

Please provide any additional information below.

#1 pschiffer

Same on 2.5.10

#2 pschiffer

Is anybody here?

david
#3 david

We're here, but very busy. This isn't a particularly high priority issue given our workload right now, and so failing a deeper analysis of what's failing (which would speed up the fix), it's probably going to sit for a while.

#4 pschiffer

I fully understand. I haven't been able to find where the syntax highlighting is done. Can you point me in the right direction and maybe I can fix it and provide a patch myself.

chipx86
#5 chipx86

What file extension are you using? Looking at Pygments it maps *.kt files to Kotlin, but not *.kts. There are no other lexers claiming *.kt, and we do filename-based matching, so if you're using *.kt, it should be working.

#6 pschiffer

We are using .kt as it is the default in IntelliJ

chipx86
#7 chipx86

Can you verify the version of Pygments you have installed?

#8 pschiffer

pip list | grep Pygments
Pygments (2.2.0)

chipx86
#9 chipx86

Should work then. Running 2.2, any *.kt file I provide is using the Kotlin lexer in Pygments. Does the file have any highlighting at all in your case? And how many lines are there in the files you're testing with?

#10 pschiffer

Maybe it's only a partial error, I see some bold keywords but for example the "{" of a "companion object" has a red border (indicating an error, correct?)
It also does not detect the current method like in java files.

chipx86
#11 chipx86

The support for showing the current class/method is part of Review Board. We don't have Kotlin support in there, but it shouldn't be hard to add if you want to try throwing together a patch. These are all defined in reviewboard/diffviewer/filetypes.py as a list of regexes that match a suitable line, grouped by file extension.

The red box does mean an error in the syntax, as determined by Pygments. If most of the file is highlighted right, then this usually means that the lexer doesn't support some aspect of the language (they rely heavily on user-contributed patches). What I'd do is try to create a small file that exhibits this behavior in Review Board and then see if it has the same problem on http://pygments.org/demo/. If so, then you'd need to file a bug or a patch against Pygments. If it's only in Review Board, and we can see the test file, I'll take a look and see what may be tripping things up.

#12 pschiffer

Thanks, I'll do that.