Skip to content

[Proposal] Refactor formatting logic to use external command(s) #329

Open
@rami3l

Description

@rami3l

After reading several issues about code formatting support (#29, #303, #304), I think it might be feasible to just make a configurable subprocess command and launch it when code formatting is triggered, in the following steps (to be completed):

  1. Fix the default formatting style (of the plugin and of the codebase): Fix code formatting with ktfmt (fixes #304) #330.
  2. Add option to customize formatting: TODO.

This proposal is made with the following considerations in mind:

  • There are various ways of formatting a Kotlin codebase. Apart from the ktlint vs. ktfmt debate, each has different installation options (for just Gradle for example, there are existing Gradle plugins like ktlint-gradle and ktfmt-gradle, and there's also spotless).

  • This has been done in similar projects. For example, rust-analyzer simply launches rustfmt to handle this.

  • However, given the fact that there is no rustfmt equivalent in the Kotlin world, and that some might want to use this plugin without an explicit per-project formatter config, it's acceptable to keep the embed ktfmt as the default formatter.

What do you think of this idea? :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    formattingRelated to source code formatting

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions