MunifTanjim / prettier.nvim

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

Prettierd and cli_options #24

Closed piedrahitapablo closed 1 year ago

piedrahitapablo commented 1 year ago

Using prettierd passing the cli_options property to setup makes this extension stop working.

I found https://github.com/MunifTanjim/prettier.nvim/issues/10#issuecomment-1214832685, and it gave me the hint to delete that property and after doing it everything started working as expected.

Can we add some clarification on the README? can I do a PR? or is this already solved and I'm missing something?

MunifTanjim commented 1 year ago

Supported version of prettierd is 0.22+.

Which version are you using?

piedrahitapablo commented 1 year ago

I have prettierd 0.23.2. I installed it using mason, not sure if that helps, I'm kind of learning neovim.

MunifTanjim commented 1 year ago

You need to share your config, otherwise I can't know what's wrong.

Also, you can pass debug = true to null-ls setup. And share the output of :NullLsLog.

piedrahitapablo commented 1 year ago

Sorry for the delay, this is the output:

[TRACE Mon Mar  6 13:30:39 2023] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:127: received LSP notification for method textDocument/didChange
[TRACE Mon Mar  6 13:30:39 2023] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS
[DEBUG Mon Mar  6 13:30:39 2023] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available
[TRACE Mon Mar  6 13:30:41 2023] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_FORMATTING
[DEBUG Mon Mar  6 13:30:41 2023] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:320: spawning command "prettierd" at /Users/piedra/code/personal/test-swc with args { "/Users/piedra/code/personal/test-swc/src/hello.ts", "--config-precedence=prefer-file", "--single-quote" }
[TRACE Mon Mar  6 13:30:41 2023] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:204: error output: TypeError: Cannot read properties of undefined (reading 'length')

[TRACE Mon Mar  6 13:30:41 2023] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:205: output: nil
[TRACE Mon Mar  6 13:30:41 2023] ...t/null-ls.nvim/lua/null-ls/helpers/generator_factory.lua:209: ignoring stderr due to generator options

and this is my prettier.nvim config:

prettier.setup({
    bin = 'prettierd',
    filetypes = {
        "css",
        "graphql",
        "html",
        "javascript",
        "javascriptreact",
        "json",
        "less",
        "markdown",
        "scss",
        "typescript",
        "typescriptreact",
        "yaml",
    },
    cli_options = {
        config_precedence = "prefer-file",
        single_quote = true,
    }
})

not sure if it helps but I called prettier using the :Prettier command

MunifTanjim commented 1 year ago

Thanks for the logs.

Looks like this PR in prettierd introduced the bug: https://github.com/fsouza/prettierd/pull/436

MunifTanjim commented 1 year ago

Should be fixed with @fsouza/prettierd@0.23.3

piedrahitapablo commented 1 year ago

Thanks!