Skip to content

Conversation

@ro0gr
Copy link
Contributor

@ro0gr ro0gr commented Nov 11, 2024

continues #564
addresses #567

@github-actions github-actions bot requested a review from stevearc November 11, 2024 23:02
@ro0gr ro0gr force-pushed the sync-prettier-with-prettierd branch from b763bae to ec4d274 Compare November 11, 2024 23:04
-- @param self conform.FormatterConfig
-- @param ctx conform.Context|conform.RangeContext
-- @return string[]|nil args the arguments for setting a `prettier` parser if they exist in the options, nil otherwise
M.prettier_cwd = function(self, ctx)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a gut feeling it should be a part of some external dependency, so it could be shared between other plugins like nvim-lint, etc. Until then this is only used by 2 formatters, so this does not seem to be the best to share it via a general utils file that is used everywhere. I'm considering to move this into the lua/conform/util/prettier-cwd or smth like that now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we share the logic between 2 formatters I'd avoid duplicating tests for the second formatter, so I'd test the prettier_cwd( util instead

@ro0gr ro0gr force-pushed the sync-prettier-with-prettierd branch from ec4d274 to 0da505e Compare November 11, 2024 23:37
Copy link
Owner

@stevearc stevearc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be a lot simpler. In general the util functions are general enough that they might be shared by a lot of different formatters. What if for the prettier formatter you just did

cwd = require("conform.formatters.prettierd").cwd

@ro0gr
Copy link
Contributor Author

ro0gr commented Nov 12, 2024

What if for the prettier formatter you just did

TLDR; OK, this is definitely easier (not simpler though) to do, so I'll stop overthinking it and make a step back. Thanks.

I've tried it initially, but then I could not decide which of both formatters should really own the cwd logic. IMO neither of them should, cause in my "ideal world"(it's beyond the scope of this project, I know!) this logic could be shared out of the conform, for instance with nvim-lint. That's why I feel keeping this as a shared util(via util/prettier.lua is a bit closer to my "ideal world".

@ro0gr
Copy link
Contributor Author

ro0gr commented Nov 12, 2024

close in favour of #573

@ro0gr ro0gr closed this Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants