MunifTanjim / prettier.nvim

Prettier plugin for Neovim's built-in LSP client.
MIT License
289 stars 9 forks source link

Enable package.json key by default #20

Closed p-m-p closed 1 year ago

p-m-p commented 1 year ago

Hi, thanks for sharing this plugin.

I have it working but it took me some time to figure things out due to the default options not checking for the prettier key in package.json by default. Given this is how prettier works by default it seems that it would be ideal to have this as the default behaviour. I also wasn't able to get it working with the example in the readme and instead came up with the below after looking through the code.

prettier.setup({
  ["null-ls.condition"] = function ()
    return require('prettier.utils').config_exists({
      check_package_json = true
    })
  end
})

Do you think this would be a better option? Happy to try and contribute a change back if so.

MunifTanjim commented 1 year ago

I also wasn't able to get it working with the example in the readme

Ah, looks like there's a typo in the code:

https://github.com/MunifTanjim/prettier.nvim/blob/f27e94f81c9cd5b0925bf46eabb5570c832bd6a7/lua/prettier/init.lua#L6

Need to fix that.

Do you think this would be a better option?

Sure, let's change the default value of check_package_json to true and update the readme file.