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

typescript pack formatting is broken #974

Closed
3 tasks done
MrMic opened this issue May 19, 2024 · 51 comments
Closed
3 tasks done

typescript pack formatting is broken #974

MrMic opened this issue May 19, 2024 · 51 comments
Labels
upstream Issues that apply to upstream plugins and not AstroNvim directly.

Comments

@MrMic
Copy link
Contributor

MrMic commented May 19, 2024

Checklist

  • I have searched through the AstroNvim docs
  • I have searched through the existing issues of AstroNvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.10.0

Operating system/version

Linux Ubuntu 22.04

Terminal/GUI

kitty

Describe the bug

For a couple of days, the formatting with Javascript is broken.
I think it is an issue with prettier and/or eslint. Everything
is working with VS Code and Helix...
I saw few days ago that prettier was updated/upgraded and this
broke the formatting. Everything was OK before.

Capture d’écran du 2024-05-18 13-08-05

Steps to Reproduce

When I save a file, formatting failed

Expected behavior

formatting

Screenshots

see above

Additional Context

No response

@MrMic MrMic added the bug Something isn't working label May 19, 2024
@Uzaaft
Copy link
Member

Uzaaft commented May 21, 2024

Do you have any custom logic locally?

@Uzaaft
Copy link
Member

Uzaaft commented May 21, 2024

This has been raised earlier @MrMic. Not sure what's causing this, but I can't reproduce locally. All LSP's are up to date. Basic template + typescript pack.

@Uzaaft
Copy link
Member

Uzaaft commented May 21, 2024

What do you mean with "broken" @MrMic. Broken as in non-functional, or broken as in wrong formatting?

@MrMic
Copy link
Contributor Author

MrMic commented May 21, 2024

No custom logic.
LSP is OK.
The issue is with formatting, which does not work at all with JS / TS.
All was working fine around 10 or 15 days ago. And then, I saw an update/upgrade
and the formatting went wrong. And now, it is not working at all!

When I save JS file I got this notification error:
Error detected while processing BufWritePre Autocommands for "<buffer=12>"

@MrMic
Copy link
Contributor Author

MrMic commented May 21, 2024

Moreover when I install prettier in my project Dev Dependencies:
$> npm install --save-dev --save-exact prettier
and run:
$> npx prettier . --write
Everything works as expected... I mean formatted.

@Skarian
Copy link

Skarian commented May 21, 2024

This is a significant issue. I am having the same problem, formatting completely broken in JS/TS.

@Uzaaft
Copy link
Member

Uzaaft commented May 21, 2024

I Wonder if this is due to prettierd

@MrMic
Copy link
Contributor Author

MrMic commented May 21, 2024

I think so.
This bug happens when prettier was updated/upgraded a couple of days ago.

@Uzaaft
Copy link
Member

Uzaaft commented May 21, 2024

I'll take a look and try and debug this, but no promises on a timeline. Feel free to also investigate the issue and come up with a fix. I'm very pressed on times nowadays @Skarian @MrMic

@vadimshvetsov
Copy link

vadimshvetsov commented May 22, 2024

Today I've updated AstroNvim and formatting was completely broken for all my TS projects.
I have some easy repro steps:

  • Start new app with create-next-app with TailwindCSS (didn't test without)
  • Create new AstroNvim config and add community packages:
return {
  "AstroNvim/astrocommunity",
  { import = "astrocommunity.pack.tailwindcss" },
  { import = "astrocommunity.pack.typescript" },
}
  • Go to src/app/page.tsx file and save - everything will be fine
  • Go to the next file src/app/layout.tsx and save - everything will be shifted to the line start.

So the first file save is always ok, but the second is always shifting all the contents to the start of line.
image

@MrMic
Copy link
Contributor Author

MrMic commented May 22, 2024

Today I've updated AstroNvim and formatting was completely broken for all my TS projects. I have some easy repro steps:

  • Start new app with create-next-app with TailwindCSS (didn't test without)
  • Create new AstroNvim config and add community packages:
return {
  "AstroNvim/astrocommunity",
  { import = "astrocommunity.pack.tailwindcss" },
  { import = "astrocommunity.pack.typescript" },
}
  • Go to src/app/page.tsx file and save - everything will be fine
  • Go to the next file src/app/layout.tsx and save - everything will be shifted to the line start.

So the first file save is always ok, but the second is always shifting all the contents to the start of line. image

Got the same issue!

@Uzaaft
Copy link
Member

Uzaaft commented May 23, 2024

@vadimshvetsov Feel free to help us in fixing this.

@vadimshvetsov
Copy link

vadimshvetsov commented May 23, 2024

I removed the tailwindcss pack and reproduced the issue, so it looks like the problem is somewhere in the typescript pack. It looks like wrong formatting is produced by prettierd, and the weird thing is that the first opened and saved file will be formatted correctly.

@Uzaaft
Copy link
Member

Uzaaft commented May 23, 2024

We've already established that.

@Uzaaft
Copy link
Member

Uzaaft commented May 23, 2024

I checked the two latest commits to the typescript pack, and those didn't break anything

@MrMic
Copy link
Contributor Author

MrMic commented May 23, 2024

I saw the update of prettier a couple of days ago (10 or 15 days) and it was
for the core of Astronvim not with the community packages. If I remember well.
And from this point on I got issues with formatting.

@vadimshvetsov
Copy link

I've rollbacked to my previous lock file and updated just astrocommunity to 8.5 and can't see any issue with formatting. I'll update packages one by one and will find which one causes the issue.

@vadimshvetsov
Copy link

I've updated astrocore and astrolsp without any issue. But once I update AstroNvim 4.2 -> 4.7.5 I can see the issue. I'll figure out exact version next.

@vadimshvetsov
Copy link

vadimshvetsov commented May 23, 2024

To those who are blocked by this issue, you can change either the version in lazy-lock.json:

  "AstroNvim": { "branch": "main", "commit": "0f875f4a7f1963d6c61eb564cadb8e556e406dd5" },

After opening nvim, just run :Lazy restore, and it will pick up the last working formatting version.

Or directly set shiftwidth back to 2 or 4 depending on preference before opening any file or in config.

This issue appeared right after the commit that came with AstroNvim 4.5.1:
AstroNvim/AstroNvim@f3dbb86 (PR)

@Uzaaft
Copy link
Member

Uzaaft commented May 23, 2024

Wait. That shouldn't, if I'm thinking correctly, affect the prettier stuff

@Uzaaft
Copy link
Member

Uzaaft commented May 23, 2024

Prettier should override that anyways since it has its own prefered logic for tabs/spaces.

@vadimshvetsov
Copy link

I've updated all my packages back to the latest and just put :set shiftwidth=2 - its working perfectly now for me 🤷‍♂️

Checked with latest create-next-app also.

@vadimshvetsov
Copy link

I guess prettier ignores tabWidth setting somehow.

@Uzaaft
Copy link
Member

Uzaaft commented May 23, 2024

I think this just exposes an underlying issue with the prettier/prettierd and neovim.

@Uzaaft
Copy link
Member

Uzaaft commented May 23, 2024

Issue is upstream:
pmizio/typescript-tools.nvim#270

@Uzaaft Uzaaft added upstream Issues that apply to upstream plugins and not AstroNvim directly. and removed bug Something isn't working labels May 23, 2024
@MrMic
Copy link
Contributor Author

MrMic commented May 23, 2024

I notice an update but I still have no formatting and null-ls seems to get stuck at
the bottom right corner of the UI.

Capture d’écran du 2024-05-23 14-14-16

@Uzaaft
Copy link
Member

Uzaaft commented May 23, 2024

Issue is resolved for me with a basic template + typescript pack. nothing else init.

@Uzaaft
Copy link
Member

Uzaaft commented May 23, 2024

I think this issue is proof that we should move away from typescript-tools.nvim to vtsls lsp instead.

@mehalter
Copy link
Member

This should be fixed now that we have moved to vtsls. Let me know if this should be reopened.

@MrMic
Copy link
Contributor Author

MrMic commented May 24, 2024

Not OK for me!
Sorry.
null-ls seems to be stuck with prettierd

Capture d’écran du 2024-05-24 14-12-52

Capture d’écran du 2024-05-24 14-12-23

@Uzaaft
Copy link
Member

Uzaaft commented May 24, 2024

Make sure to update your dependencies @MrMic . It's working fine for me now

@MrMic
Copy link
Contributor Author

MrMic commented May 24, 2024

Make sure to update your dependencies @MrMic . It's working fine for me now

What do you mean by "dependencies"? All my packages are up-to-date.
I press "pa"...

@mehalter
Copy link
Member

Also open Mason and make sure to uninstall tsserver

@MrMic
Copy link
Contributor Author

MrMic commented May 24, 2024

Also open Mason and make sure to uninstall tsserver

I did it again. And it has been installed again but I still have the same issue...
tsserver works perfectly fine, it is an issue with prettier(d) and formatting.
One or 2 weeks ago I saw updates for prettier and since then I got issues.

@mehalter
Copy link
Member

Well you shouldn't see tsserver at all in the latest update 😅 so it shouldn't be working at all haha . Can you share an example project that's throwing the error and steps to replicate.

@MrMic
Copy link
Contributor Author

MrMic commented May 24, 2024

I see it when I open my project...
Anyway, here it is:
https://github.com/MrMic/NextJS-14-S04_NEW.git

BTW: When I work with VS Code on it I have no issue at all!

@mehalter
Copy link
Member

It would definitely be strange if you got a null-ls error message in vs code 😂

@Uzaaft
Copy link
Member

Uzaaft commented May 24, 2024

@MrMic delete your plugins and try again.

@Uzaaft
Copy link
Member

Uzaaft commented May 24, 2024

I.e the lazy cache folder

@MrMic
Copy link
Contributor Author

MrMic commented May 24, 2024

I.e the lazy cache folder

Where is it located? (on linux)

@Uzaaft
Copy link
Member

Uzaaft commented May 24, 2024

I've send you it before 😐

rm -rf ~/.cache/nvim
rm -rf ~/.local/share/nvim
rm -rf ~/.local/state/nvim

Also: List time you had a bug in a plugin, you "...deleted and reinstalled the plugin, and this solved my issue... weird." Whatever that meant, try that as well.

@mehalter mehalter changed the title Formatting is broken typescript pack formatting is broken May 24, 2024
@mehalter
Copy link
Member

@MrMic I don't have any issues formatting that project, also it correctly only attaches vtsls and eslint, it doesn't add prettier at all. Can you share your config? You might have a bug on your end

@MrMic
Copy link
Contributor Author

MrMic commented May 24, 2024

I've send you it before 😐

rm -rf ~/.cache/nvim
rm -rf ~/.local/share/nvim
rm -rf ~/.local/state/nvim

Also: List time you had a bug in a plugin, you "...deleted and reinstalled the plugin, and this solved my issue... weird." Whatever that meant, try that as well.

Done. But I still have this issue...

@MrMic
Copy link
Contributor Author

MrMic commented May 24, 2024

@MrMic I don't have any issues formatting that project, also it correctly only attaches vtsls and eslint, it doesn't add prettier at all. Can you share your config? You might have a bug on your end

https://github.com/MrMic/astronvim_v4.git

@mehalter
Copy link
Member

I get a 404, that might be private

@MrMic
Copy link
Contributor Author

MrMic commented May 24, 2024

I get a 404, that might be private

Yes indeed. Should be public now for some time...

@mehalter
Copy link
Member

Ok, I found the error. Investigating now.

@Uzaaft
Copy link
Member

Uzaaft commented May 24, 2024

Ok, I found the error. Investigating now.

Seems to be a reccuring thing with your config @MrMic 😂

@mehalter
Copy link
Member

Ok @MrMic , AstroNvim v4.7.7 should resolve the specific error message you are getting, but there are still a lot of issues with your configuration. I will make a PR with a few fixes I found immediately, but I haven't really gone through it with a fine tooth comb

@mehalter
Copy link
Member

Ok, I opened a PR on your config. Hopefully it all makes sense. God speed!

https://github.com/MrMic/astronvim_v4/pull/1

@MrMic
Copy link
Contributor Author

MrMic commented May 24, 2024

Ok, I opened a PR on your config. Hopefully it all makes sense. God speed!

MrMic/astronvim_v4#1

Apply the PR and it seems to work fine now!
Very big thanks @mehalter . It is very kind of you to spend
time for me.
Thank @Uzaaft too, even with your sarcastic sense of humor... 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Issues that apply to upstream plugins and not AstroNvim directly.
Projects
None yet
Development

No branches or pull requests

5 participants