biomejs/biome-vscode

๐Ÿ› No highlighting in vs code workspaces

Closed this issue ยท 15 comments

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

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

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

Yes.

Thanks for clarifying @AdrianSchmidt91.

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

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.

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.

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

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

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.

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)

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?

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

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.

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

The LSP doesn't support workspaces yet

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 ๐Ÿคท?