Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format on save doesn't work #92

Closed
lili21 opened this issue Dec 30, 2022 · 8 comments
Closed

format on save doesn't work #92

lili21 opened this issue Dec 30, 2022 · 8 comments

Comments

@lili21
Copy link

lili21 commented Dec 30, 2022

this commit delete the prettier.rc.lua file. which maybe the reason.

I put the file back, and now it works.

@EXPITC
Copy link
Contributor

EXPITC commented Jan 2, 2023

If ur case is format on save not prettier; if that ur, &case not work for ts but work lua file check ur lspconfig.lua then u can enable it on tsserver.setup on_attach put enable_format_on_save like in sumneko lua-server setup. works? no?

this commit delete the prettier.rc.lua file. which maybe the reason.

I put the file back, and now it works.

@Pkcarreno
Copy link

Pkcarreno commented Jan 19, 2023

I'm experiencing something similar to @lili21, but in my case is that neither prettier nor eslint format when saving (or assigning it to any key).
I have a couple of weeks like this, before everything was ok, so I assume it was the fault of some plugin that was updated but I can't find which one.

I'm on windows, with nvim 0.8.2

@statusunknown418
Copy link

Same issue here, anyone found workarounds?

@Pkcarreno
Copy link

Hey @AlvaroAquijeDiaz and @lili21, you both are on windows? Take a look at this jose-elias-alvarez/null-ls.nvim#1118

@statusunknown418
Copy link

Hey @AlvaroAquijeDiaz and @lili21, you both are on windows? Take a look at this jose-elias-alvarez/null-ls.nvim#1118

I'm on macOS but will check as well and update if found some workaround

@Pkcarreno
Copy link

@AlvaroAquijeDiaz, There is an error in null-ls regarding the path of the language server executable, specifically those coming from npm.

However I managed to solve my eslint problem by adding null_ls.builtins.formatting.eslint_d inside sources of the null-ls configuration as below:

null_ls.setup {
  sources = {
    null_ls.builtins.formatting.prettierd,
    null_ls.builtins.formatting.eslint_d, -- Here
    null_ls.builtins.diagnostics.eslint_d.with({
      diagnostics_format = '[eslint] #{m}\n(#{c})'
    }),
    null_ls.builtins.diagnostics.fish
  },
  ...
}

I hope it helps you

@statusunknown418
Copy link

statusunknown418 commented Jan 27, 2023

@Pkcarreno great news, however I haven't had the chance to look at the other link you mentioned but will update when I do it

@DindoLeonard
Copy link

In the null-ls.rc.lua, just rewrite null_ls.builtins.formatting.prettierd -> null_ls.builtins.formatting.prettier. worked for me

-- inside null.ls.setup()
  sources = {
    null_ls.builtins.formatting.prettier,
    -- null_ls.builtins.diagnostics.eslint_d.with({
    --   diagnostics_format = '[eslint] #{m}\n(#{c})'
    -- }),
    null_ls.builtins.diagnostics.zsh,
    null_ls.builtins.diagnostics.eslint_d.with({ -- js/ts linter
      -- only enable eslint if root has .eslintrc.js (not in youtube nvim video)
      condition = function(utils)
        return utils.root_has_file(".eslintrc.js") -- change file extension if you use something else
      end,
    }),
    null_ls.builtins.code_actions.eslint_d
  },

@craftzdog craftzdog closed this as not planned Won't fix, can't repro, duplicate, stale Mar 20, 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

No branches or pull requests

6 participants