jose-elias-alvarez / null-ls.nvim

Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
Other
3.62k stars 790 forks source link

Issue with prettier null-ls when i create new file in reactjs project #1519

Open Rahul-icoder opened 1 year ago

Rahul-icoder commented 1 year ago

FAQ

Issues

Neovim Version

0.9.0

Dev Version?

Operating System

Macos with m1 processor

Minimal Config

null-ls-config.lua

issue only with prettier plugin

local null_ls = require("null-ls")

null_ls.setup({
    sources = {
        null_ls.builtins.formatting.prettier,
        null_ls.builtins.formatting.black,
        null_ls.builtins.formatting.gofmt,
        null_ls.builtins.formatting.shfmt,
    },
    on_attach = function(client, bufnr)
        if client.supports_method("textDocument/formatting") then
            vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
            vim.api.nvim_create_autocmd("BufWritePre", {
                group = augroup,
                buffer = bufnr,
                callback = function()
                    -- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead
                    vim.lsp.buf.format()
                end,
            })
        end
    end,

})


### Steps to Reproduce

1) create new file in reactjs project
2) write some code 
3) then save this document
4) again write some more code in this file
5) then press ESC key , to go back to normal mode , here the issue you will see

note : the issue is code duplication.

### Reproducibility Check

- [ ] I confirm that my minimal config is based on the `minimal_init.lua` template and that my issue is reproducible by running `nvim --clean -u minimal_init.lua` and following the steps above.

### Expected Behavior

i expect to format document while saving.

### Actual Behavior

But the problem is , it automatically duplicate code exponentially while go insert mode to normal mode.

### Debug Log

[WARN  Sun Mar 19 16:10:49 2023] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:94: failed to run generator: ...site/pack/packer/start/null-ls.nvim/lua/null-ls/loop.lua:165: command shfmt is not executable (make sure it's installed and on your $PATH)
[WARN  Wed Mar 22 12:24:09 2023] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:94: failed to run generator: ...site/pack/packer/start/null-ls.nvim/lua/null-ls/loop.lua:165: command eslint is not executable (make sure it's installed and on your $PATH)
[WARN  Wed Mar 22 13:07:47 2023] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:94: failed to run generator: ...site/pack/packer/start/null-ls.nvim/lua/null-ls/loop.lua:165: command eslint is not executable (make sure it's installed and on your $PATH)
[WARN  Fri Mar 24 10:31:30 2023] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:94: failed to run generator: ...site/pack/packer/start/null-ls.nvim/lua/null-ls/loop.lua:165: command shfmt is not executable (make sure it's installed and on your $PATH)
[WARN  Fri Mar 24 10:51:44 2023] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:94: failed to run generator: ...site/pack/packer/start/null-ls.nvim/lua/null-ls/loop.lua:165: command shfmt is not executable (make sure it's installed and on your $PATH)
[WARN  Sat Mar 25 19:25:06 2023] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:94: failed to run generator: ...site/pack/packer/start/null-ls.nvim/lua/null-ls/loop.lua:165: command shfmt is not executable (make sure it's installed and on your $PATH)
[WARN  Tue Mar 28 13:59:14 2023] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:94: failed to run generator: ...site/pack/packer/start/null-ls.nvim/lua/null-ls/loop.lua:165: command shfmt is not executable (make sure it's installed and on your $PATH)
[WARN  Tue Mar 28 16:33:21 2023] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:94: failed to run generator: ...site/pack/packer/start/null-ls.nvim/lua/null-ls/loop.lua:165: command shfmt is not executable (make sure it's installed and on your $PATH)
[WARN  Tue Mar 28 17:34:53 2023] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:94: failed to run generator: ...site/pack/packer/start/null-ls.nvim/lua/null-ls/loop.lua:165: command shfmt is not executable (make sure it's installed and on your $PATH)
[WARN  Mon Apr 10 14:34:03 2023] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:94: failed to run generator: ...site/pack/packer/start/null-ls.nvim/lua/null-ls/loop.lua:165: command shfmt is not executable (make sure it's installed and on your $PATH)
[WARN  Fri Apr 14 17:15:02 2023] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:94: failed to run generator: ...site/pack/packer/start/null-ls.nvim/lua/null-ls/loop.lua:165: command prettier is not executable (make sure it's installed and on your $PATH)
[WARN  Sat Apr 15 10:49:27 2023] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:94: failed to run generator: ...site/pack/packer/start/null-ls.nvim/lua/null-ls/loop.lua:165: command prettier is not executable (make sure it's installed and on your $PATH)

### Help

Yes

### Implementation Help

_No response_

### Requirements

- [X] I have read and followed the instructions above and understand that my issue will be closed if I did not provide the required information.
jose-elias-alvarez commented 1 year ago

Please provide a minimal reproduction according to the issue template or I cannot investigate this.

kostromin59 commented 1 year ago

The same issue