VS Live Share Support for VSC plugin
I've been finding this to be incredibly useful for formatting my silly dumb mistakes but also pointing out my errors too although I sometimes share a tab I'm working on with someone using VS Live Share (https://marketplace.visualstudio.com/items?itemName=MS-vsliveshare.vsliveshare)
I've tried seeing if it had to do with VS Code's restricted mode so I set this in my JSON config
"security.workspace.trust.enabled": false,
Although the options available for formatters when I'm connected to someone else's session omits StyLua. This happens with or without the above.
I can't remember exactly why this isn't already a thing.
In live share all the files are virtual and (I believe) stored in memory. I think we can get around this by passing the contents of the files through to stdin, but the main issue is configuration.
The binary won't be able to correctly resolve for the relevant .stylua.toml or .styluaignore file when applying the formatting. The ignore file is fine, because we already do a manual check in the extension, but the config file may be an issue.
I think we could possibly get around this by manually looking (in the extension) for the toml file, parsing it, then passing the config as command line options to the binary. It means we unfortunately have to keep config resolution up to date in two locations (but tbh config is hardly changing), and we may miss the correct toml file.
Some useful recommendations as well for reference: https://docs.microsoft.com/en-us/visualstudio/liveshare/reference/extensions#known-issues
Sorry for the significant delay. Looking back at this, it seems that VSCode now supports passing through the relevant formatter to any live sharing clients. So this should hopefully no longer be an issue. Do you still experience problems here?
I've been spoiled by GitHub's Copilot now for autocompletion and formatting, but still have formatonsave enabled with stylua running. I'm not sure how this would look live but I think it'd be a big difference in workflow if it were there.
Just tested this recently and it looks like the live share was working without issues. On a secondary computer with stylua extension not installed, formatting still works due to the above pass-through feature