Closed inspiredlabs closed 1 year ago
svelte inspector does not include an option to customize the editor that is opened by vite. This feature is provided by vite via https://github.com/yyx990803/launch-editor#launch-editor . You can customize the editor command via LAUNCH_EDITOR
env, which is described in their docs.
Thanks. I've just setup a fresh repo to test this on.
Out of the box, this requires people to do several things:
svelte.config.js
, under kit
, add: kit: {
adapter: adapter()
},
// plugin options
vitePlugin: {
exclude: [],
// DX options
inspector: {
toggleKeyCombo: 'meta-shift',
holdMode: false,
showToggleButton: 'never'
}
}
npm run dev -- --open
), this is what will happen on macOS
your terminal will throw:Could not open +page.svelte in the editor. The editor process exited with an error: spawn code ENOENT.
export LAUNCH_EDITOR=cursor
, or tailor your package.json
file, like this: "scripts": { "dev": "export LAUNCH_EDITOR=cursor && vite dev", ... }
.NB: I don't know how useful it is to use a typical .env
file. Whiles it's full of useful variables, I'm not sure this is the most natural home for LAUNCH_EDITOR=cursor
. And, in my testing it still throws: The editor process exited with an error: spawn code ENOENT.
when it's set here anyway.
Seeing as this is out of experimental, my hope is the inspector works by default OOTB.
Thanks again.
Like i mentioned before, the feature to open the editor is implemented in vite, not vite-plugin-svelte. This does work out of the box for most common editors as launch-editor scans the process list for known executables. If it does not work for yours, I suggest you file an issue with launch-editor and maybe send them a PR to support cursor
.
Or you follow their configuration options and put the environment variable in an appropriate place for your development, be it a .env file or your shells rc file.
A short paragraph can be added to our docs that mentions this and link to launch-editor.
I have updated your report to be an enhancement request, as this is not a bug in vite-plugin-svelte. Support questions like "How do i use svelte inspector with editor X" can be asked in our discord chat too, in #svelte-and-kit
there are a lot of helpful community members and some of them use svelte inspector with vim and other editors too.
Problem
It is not clear from the documentation how to use svelte-inspector with editors that are not supported by launch-editor (the library in vite that opens the editor for us) ootb.
Solution
Add a link to launch-editor docs, mentioning
LAUNCH_EDITOR
environment variableoriginal report below:
Describe the bug
There seems to be some detail missing, I know that these are "upstream" issues – but I think it's fair to say this plugin is about DX. So, with that in mind, I'd like to highlight some bugs/documentation.
Does that mean that I can specify:
VITE_INSPECTOR_EDITOR=code
, orVITE_INSPECTOR_EDITOR=cursor
?svelte.config.js
might look like this:But this leaves some details unanswered. Here's an example using VSC (Visual Studio Code):
Cmd+Shift+P
(Mac) orCtrl+Shift+P
(Windows/Linux) to open the Command Palette.Shell Command: Install 'code' command in PATH
.npm run dev --openVim
, so you have to specify your editor in your terminal environment too, so:echo $EDITOR
vim
.export EDITOR=code
echo $EDITOR
again, it should returncode
.~/.zshrc
export EDITOR=cursor
source ~/.zshrc
npm run dev -- --open
, and thenmeta-shift
+ click.Reproduction URL
https://kit.svelte.dev/
Reproduction
The documentation says that this is all that needs configuring, but as described this is an incomplete solution:
Logs
No response
System Info