https://kotlinlang.org logo
#feed
Title
# feed
e

evanchooly

07/24/2019, 3:46 PM
installing npm to format my kotlin code? 😕
t

tddmonkey

07/24/2019, 3:48 PM
That rules it out for me straight away too
💯 5
l

Liam Humphreys

07/24/2019, 3:55 PM
I'm just dipping my sweaty toe into the kotlin world and noticed the formatters are pretty unwieldy so i made that plugin for my own sake, would the kotlin-based approach be to deliver this as a gradle plugin?
t

tddmonkey

07/24/2019, 3:57 PM
pretty much. there are npm plugins for gradle that will handle the distribution for you so it’s seamless. We’re kinda spoiled- Gradle can bootstrap itself so we get used to not having to install other dependencies manually
e

evanchooly

07/24/2019, 3:59 PM
i use ktlint, personally
👍 1
just a maven plugin
l

Liam Humphreys

07/24/2019, 4:29 PM
I checked out ktlint and spotless and some other kotlin formatting solutions but the setup was pretty intimidating and cumbersome to a gradle/java/kotlin noob, i am dumb and just want to learn one thing at a time so using the npm prettier plugin I can have boilerplate gradle, kotlin code formatted on save in a not-intellij editor, and I can focus on learning kotlin 😄
e

evanchooly

07/24/2019, 4:30 PM
wow. that's a long way to go to avoid work. 🙂 ktlint is really just a plugin entry in your pom, iirc. but no worries. i don't want to take away from your work or contribution. you learned something. you built something you needed and filled a gap you perceived. so good on you! i'm all for it. 👍🏻
👍 3
l

Liam Humphreys

07/24/2019, 4:34 PM
indeed it was the very long route 🤔 . Thanks 😄 when I'm more comfortable with this ecosystem I'll look to tear it away from npm
s

Spike Baylor

07/24/2019, 4:42 PM
@evanchooly lets face it, "a long way to go to avoid work" is what makes a developer a developer 😄
😄 1
💯 2
e

evanchooly

07/24/2019, 4:42 PM
it's how we got linux. and kotlin! 😄
g

gildor

07/24/2019, 11:28 PM
IDEA to format code. Also you don't need Gradle to run ktlint, this is standalone tool, not a library
l

Liam Humphreys

07/25/2019, 7:31 AM
@gildor I want formatters to be IDE / Editor agnostic, that way each dev on my team can work with their preferred setup, we got some devs using emacs, one on vim, the rest are atom and vscode
g

gildor

07/25/2019, 7:52 AM
IDEA also can be used headless to format code.
Anyway, ktlint is standalone tool too, so can be integrated with any other editor
l

Liam Humphreys

07/25/2019, 8:07 AM
I didn't know that about IDEA, thanks. Also that is true, we probably could have gotten by with ktlint. We use many languages though, as I'm sure most devs do now, and prettier's plugin architecture means setting up a dev env for all the languages is consistently easy - just install plugins 😄
g

gildor

07/25/2019, 8:24 AM
But every editor/IDE has own plugin infrastructure, so integrate existing tool with it looks as good approach
l

Liam Humphreys

07/25/2019, 8:42 AM
Maybe there is some misunderstanding here, when you want to try out a new language and wish to have it formatted then if you are using prettier you just add a plugin to your existing prettier install, and (assuming you've hooked prettier's cmds into your editor / IDE) it'll just work, to me that is simpler than installing standalone formatters per language - each with different cmds to be integrated with your tooling. But all of that doesn't matter because it's subjective - I happen to like working that way, I don't expect everyone or anyone else to agree. The "good approach", as you put it, is just what works best for each of us as individuals, allowing us to be productive
g

gildor

07/25/2019, 2:06 PM
yeah, for sure it’s nice to reuse existing plugin systems, just always was a bit sceptical about alternative editors/IDE for Kotlin, one of the biggest features of Kotlin is good tooling that provided by official Idea platform plugins, again it’s much more complicated when you talking about whole team, I’m just talking from point of view of a developer Anyway, really nice project and showcase of integration with JS ecosystem
s

Spike Baylor

07/25/2019, 2:30 PM
the tooling for kotlin to me is huge. Without it, there are quite a few kotlin features (particularly anything implicit) that would drive me mad without intellij. Intellij's inlining of implicit types is a lot of what makes lambdas and DSLs and the likes so great. Without intellij telling me what 'it' actually is, or that 'this' is of type X within this scope, I'd probably hate kotlin instead of loving it like i do.
👍🏼 4
m

mkerr

07/29/2019, 3:01 AM
I’ve been using the Kotlinter Gradle plugin for Ktlint, it’s pretty simple. Not super configurable but I think that’s changed now that Ktlint supports more customization. I couldn’t get Spotless working with Kotlin DSL for Gradle but I may revisit later.
Also using SonarQube/SonarLint but haven’t looked at what rules we have set up for Kotlin
Spike: I don’t need those generally, you get used to it. I was using C# for a long while. The syntax is less cumbersome for pure Kotlin but can be gross for lambda declarations that interface with Java code
5 Views