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

🐛 No highlighting in vs code workspaces #18

Closed
1 task done
AdrianSchmidt91 opened this issue Oct 9, 2023 · 16 comments
Closed
1 task done

🐛 No highlighting in vs code workspaces #18

AdrianSchmidt91 opened this issue Oct 9, 2023 · 16 comments
Labels
Enhancement Improves an existing feature Help wanted External contributions are welcome

Comments

@AdrianSchmidt91
Copy link

Environment information

not needed

What happened?

Open a workspace in vs code (for eg. an application that runs in combination with an other combination)
Highlighting does not work

Open the files without workspaces - highlighting works.

Expected result

That highlighting is working

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@nhedger
Copy link
Member

nhedger commented Oct 10, 2023

By highlighting, do you mean warnings and errors underlined with squiggly lines ?

@AdrianSchmidt91
Copy link
Author

By highlighting, do you mean warnings and errors underlined with squiggly lines ?

Yes.

@nhedger
Copy link
Member

nhedger commented Oct 10, 2023

Thanks for clarifying @AdrianSchmidt91.

@Rainson12
Copy link

Rainson12 commented Oct 12, 2023

I am experiencing the same issue however i did a few more tests and it was actually working with workspaces when the folder that contains the biome config is actually the first one in the workspace configuration. So for example this works (if projecta has biome config but projectb and c dont have it:

{
	"folders": [
		{
			"path": "..\\projecta"
		},
		{
			"path": "..\\projectb"
		},
		{
			"path": "..\\projectc"
		}
	],

but this doesnt work:

{
	"folders": [
		{
			"path": "..\\projectb"
		},
		{
			"path": "..\\projectc"
		},
		{
			"path": "..\\projecta"
		}
	],

so it seems to be an issue of the order of the folders in the workspace?!

please note that within the workspace config there was no additional config parameters other than the folders

@AdrianSchmidt91
Copy link
Author

AdrianSchmidt91 commented Oct 12, 2023

I am experiencing the same issue however i did a few more tests and it was actually working with workspaces when the folder that contains the biome config is actually the first one in the workspace configuration. So for example this works (if projecta has biome config but projectb and c dont have it:

{
	"folders": [
		{
			"path": "..\\projecta"
		},
		{
			"path": "..\\projectb"
		},
		{
			"path": "..\\projectc"
		}
	],

but this doesnt work:

{
	"folders": [
		{
			"path": "..\\projectb"
		},
		{
			"path": "..\\projectc"
		},
		{
			"path": "..\\projecta"
		}
	],

so it seems to be an issue of the order of the folders in the workspace?!

Also the "Format Document With.." will then not display "Biome" if the biome-project is not at first place in that folders array.

@samirergaibi
Copy link

The same problem occurs when using biome for a single project in a monorepo like pnpm workspaces. Having a biome.jsonin the root works but does not really make sense to have if it is only used in one of the projects.

No syntax highlighting, and Biome won't show up as a formatter in vs code.

@nhedger
Copy link
Member

nhedger commented Oct 21, 2023

The VS Code extension currently uses the workspace.findFiles API to locate a biome.json file at the root of any of the workspaces and it uses the first one that it finds.

https://github.com/biomejs/biome/blob/5179abd24b315194416f357afe6b69e11e6470e7/editors/vscode/src/main.ts#L49-L62

@ematipico
Copy link
Member

ematipico commented Oct 23, 2023

@nhedger what does this mean for us? Sorry, I don't know how to interpret your comment 😅

@nhedger
Copy link
Member

nhedger commented Nov 26, 2023

Went a bit fast over this last time.

I believe there to be two factors to this issue:

  1. The VS Code extension checks for the presence of biome.json at the root of the first workspace folder to determine whether it should continue the activation process or abort it. This can be bypassed by not requiring the configuration file, but is not the reason why it does not work in multi-folder workspaces.

  2. The LSP server does not have support for multiple workspace folders, and attempts to find biome.json at the {root_uri}/biome.json path. My guess is that it maps to the first available workspace folder, but I'm not certain. I'd have to do some tests.

@hulkish
Copy link

hulkish commented Dec 12, 2023

Having this issue also, in vscode it seems to just ignore my project's biome.json and actually causes issues (for ex, by using undesired quote type for formatting)

@ematipico ematipico added Enhancement Improves an existing feature Help wanted External contributions are welcome labels Dec 12, 2023
@atomiks
Copy link

atomiks commented Jan 14, 2024

Coming from #75:

The LSP server does not have support for multiple workspace folders, and attempts to find biome.json at the {root_uri}/biome.json path. My guess is that it maps to the first available workspace folder, but I'm not certain. I'd have to do some tests.

I can confirm (based on my issue above) that it seems to use the first config file it finds in the list of folders in the workspace.

I believe Prettier's extension works down-up instead: using whichever file was saved, it should traverse up the directory tree and use the first biome.json it finds, rather than a top-down approach from the workspace root. Are there limitations where this doesn't work?

@arendjr
Copy link
Contributor

arendjr commented Jan 14, 2024

I think the way Prettier works here should be the way to go indeed. That would work well with both workspaces and monorepos.

@john-wennstrom
Copy link

I get kind of the same issue. Only when I put the biome.json in the root of my monorepo project, the biome plugin take into account my defined rules.

@ematipico
Copy link
Member

I'm going to close this issue. People can follow biomejs/biome#1573 for updates.

The LSP doesn't support workspaces yet

@kendallroth
Copy link

Open the files without workspaces - highlighting works.

Apologies for commenting on a closed issue, but does this actually work? When attempting to use Biome in a VS Code project with no workspace configuration, I'm not getting any highlighting whatsoever, so I was a little confused to see this 🤷?

@flekschas
Copy link

I might be doing something wrong but has anybody figured out how to get highlights working when the JS project is in a subfolder?

I have a JS project under js in my project. Following https://deploy-preview-974--biomejs.netlify.app/reference/vscode/#defining-projects-in-a-workspace-folder I've created a file under .vscode/settings.json and set it to

{
  "biome.projects": [
    {
      "path": "js"
    }
  ]
}

However, I'm not getting any highlights. I've restarted code but that doesn't help either.

I'm running

  • VSCode Version: 1.91.1
  • Biome Plugin Version: v2024.10.40751 (pre-release)
  • Biome Version: v1.9.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Improves an existing feature Help wanted External contributions are welcome
Projects
None yet
Development

No branches or pull requests