Skip to content

Commit fe98c80

Browse files
committed
feat: allow to customize editor to open, fix #748
1 parent a290648 commit fe98c80

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

packages/devtools-kit/src/_types/options.ts

+1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ export interface VSCodeTunnelOptions {
184184
export interface NuxtDevToolsOptions {
185185
behavior: {
186186
telemetry: boolean | null
187+
openInEditor: string | undefined
187188
}
188189
ui: {
189190
componentsGraphShowGlobalComponents: boolean

packages/devtools/client/pages/settings.vue

+24
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,23 @@ const {
2424
sidebarScrollable,
2525
} = useDevToolsOptions('ui')
2626
27+
const {
28+
openInEditor,
29+
} = useDevToolsOptions('behavior')
30+
2731
const client = useClient()
2832
33+
const editorOptions = [
34+
['Auto', undefined],
35+
['VS Code', 'vscode'],
36+
['VS Code Insider', 'vscode-insider'],
37+
['Cursor', 'cursor'],
38+
['Zed', 'zed'],
39+
['WebStorm', 'webstorm'],
40+
['Sublime Text', 'sublime'],
41+
['Atom', 'atom'],
42+
]
43+
2944
const scaleOptions = [
3045
['Tiny', 12 / 15],
3146
['Small', 14 / 15],
@@ -227,6 +242,15 @@ watchEffect(() => {
227242
{{ i[0] }}
228243
</option>
229244
</NSelect>
245+
246+
<div mx--2 my1 h-1px border="b base" op75 />
247+
248+
<p>Open In Editor</p>
249+
<NSelect v-model="openInEditor" n-primary>
250+
<option v-for="i of editorOptions" :key="i[0]" :value="i[1]">
251+
{{ i[0] }}
252+
</option>
253+
</NSelect>
230254
</NCard>
231255

232256
<h3 mt2 text-lg>

packages/devtools/src/constant.ts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const defaultOptions: ModuleOptions = {
2121
export const defaultTabOptions: NuxtDevToolsOptions = {
2222
behavior: {
2323
telemetry: null,
24+
openInEditor: undefined,
2425
},
2526
ui: {
2627
componentsView: 'list',

packages/devtools/src/server-rpc/general.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ import { logger } from '@nuxt/kit'
77
import { colors } from 'consola/utils'
88
import destr from 'destr'
99
import { resolve } from 'pathe'
10-
1110
import { snakeCase } from 'scule'
11+
1212
import { resolveBuiltinPresets } from 'unimport'
1313
import { getDevAuthToken } from '../dev-auth'
1414
import { setupHooksDebug } from '../runtime/shared/hooks'
15+
import { getOptions } from './options'
1516

1617
export function setupGeneralRPC({
1718
nuxt,
@@ -181,8 +182,11 @@ export function setupGeneralRPC({
181182
if (result)
182183
return true
183184
}
185+
let editor = getOptions()?.behavior.openInEditor ?? undefined
186+
if (editor === 'auto')
187+
editor = undefined
184188
// @ts-expect-error missin types
185-
await import('launch-editor').then(r => (r.default || r)(path + suffix))
189+
await import('launch-editor').then(r => (r.default || r)(path + suffix, editor))
186190
return true
187191
}
188192
catch (e) {

0 commit comments

Comments
 (0)