yyx990803 / launch-editor

Open file in editor from Node.js.
MIT License
585 stars 67 forks source link

Add Cursor support #63

Closed gunta closed 5 months ago

gunta commented 10 months ago

https://cursor.sh/

jchase commented 8 months ago

2nd that. I've created a PR for this #70.

The function signature of both code and cursor are the same - code -g <file:line[:character]>. I'm not sure why even after installing the code shell command from within Cursor it still fails to map correctly, so this still requires an export LAUNCH_EDITOR=cursor in your bash profile in order to work. But... since cursor is not a known editor to launch-editor, it currently calls cursor with the default argument signature cursor <file> <line> <character> instead. The symptom is, it'll open the file in Cursor, but will open new additional files that are numbered with the and numbers thinking they are new files to be created.

In case anyone needs a workaround for this, I ended up following the instructions on running a custom launch script for it and it works great:

.bash_profile

LAUNCH_EDITOR=/path/to/your/cursor-launcher.sh

And then, cursor-launcher.sh:

#!/bin/bash

# Gets called with 3 args: filename, line, column
filename=$1
line=$2
column=$3

# Call Cursor with the expected arguments
cursor -g "${filename}:${line}:${column}"
haoqunjiang commented 5 months ago

Added in 2.7.0

Dreamzlol commented 5 months ago

Does it work for you guys? I have "launch-editor": "^2.7.0", Its just creating a .+page.svelte.swp as example.

Svelte config i have it also set,

vitePlugin: {
    inspector: {
        toggleKeyCombo: 'meta-shift',
        showToggleButton: 'always',
        toggleButtonPos: 'bottom-right',
        openKey: 'enter',
        escKey: 'Escape'
    }
}