Skip to content

Option to run external formatter from file working directory #9039

@theomessin

Description

@theomessin

I'm using a custom .helix/languages.toml for a monorepo setup. I don't want to use a global prettier bin, but rather the one installed in the currently worked on package. This is my config:

[[language]]
name = "typescript"
scope = "source.ts"
file-types = ["ts", "mts", "cts"]
injection-regex = "(ts|typescript)"
roots = ["package.json"]
language-servers = [{ except-features = ["format"], name = "typescript-language-server" }]
formatter = { command = "pnpm", args = ["prettier", "--parser", "typescript"] }
auto-format = true

However, this doesn't work if I open Helix from the monorepo root, as there's no package.json there and pnpm prettier fails. Maybe I'm misunderstanding how the workspace roots work, but I don't think the formatter is using these either. I ran pwd and see it's just the folder I opened Helix from.

formatter = { command = "pwd" }

Even if I installed a global prettier, it won't be using the correct .prettierignore and .prettierrc.yml. I would like the option of running the formatter from the working directory of the currently open file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-helix-termArea: Helix term improvementsC-enhancementCategory: Improvements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions