Open vigilancer opened 5 years ago
Do you maybe mean launching kotlin-compiler.jar
in makeprg
instead of kotlin-stdlib.jar
? Because to run the program, you must first compile it with kotlinc
(or with java .../kotlin-compiler.jar
)
When I enable this plugin and open kotlin file in vim it takes care about compiling .kt file into .class file (with Kt suffix).
If I create hello.kt
with content:
fun main(args: Array<String>) {
println("Hello!!")
}
and open it in vim (with kotlin-vim
enabled) there will be compiled class file:
% tree -L 2
.
├── HelloKt.class
├── META-INF
│ └── main.kotlin_module
└── hello.kt
What I propose is to simplify running this class with :make
command.
it takes care about compiling .kt file into .class file
What do you mean by this? There's no code in this plugin that invokes the Kotlin compiler, which makes me wonder how exactly are you getting .class files without launching the compiler manually.
Something compiling it alright.
It happens if filetype
is set to kotlin
. Let me investigate.
Butler Linter did it. My mistake, kotlin-vim
have nothing to do with it apart from setting filetype to kotlin
.
Seems w0rp/ale
is too smart. We don't want to rely on linter to compile, do we.
Okay, then we can extend original idea and add compilation command into makerg
too.
OK, thanks for the clarification.
I would actually wait until KT-27171 is implemented, at which point the burden of deciding how is the executable file named and in what package it lies will be completely on the kotlin
command line script, and the kotlin-vim
plugin can simply invoke kotlin %
. We can also require that the kotlin
script name can be resolved when running it via the shell (i.e. it must exist in PATH
) and avoid looking up the Kotlin installation path manually.
Yes, this should fit the bill. That feature strikes me as more elegant solution. Merely wondering are there any estimates?
I don't have any estimates at this point, since we've only started planning 1.4/1.3.x recently and we don't know the complete picture of what's to be done yet. I can only say that I am personally encouraged by the possibility of a more user-friendly Kotlin CLI, and will do my best to implement KT-27171 as soon as I have an opportunity, at the very least to improve my own UX when working with Kotlin.
This is really great, looking forward to it.
How do you feel about adding support for appropriate
makeprg
into this plugin? Something like this should do:(
%
filename:r
remove extensiongs?^.?\\u&?
- capitalise first letter (hello - Hello) - same as in/^./\u&/gs
Kt
- add to the end )This will cover scripts without specified package:
:!java -cp .:/usr/local/Cellar/kotlin/1.3.10/libexec/lib/kotlin-stdlib.jar HelloKt
But sure this can be extended with something like
:echo substitute(getline(1), ‘package ‘, ‘’, ‘’)
.I'm not totally clear on how to get kotlin stdlib path. We can try to guess it or require user to set env variable to the kotlin install dir.