-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multi-Editor Support via config (#146)
* feat: add project configuration files for IDE support and code style settings feat: implement EditorButton component to replace VsCodeButton for better flexibility fix: update RdtClientConfig to include editorName for improved configuration fix: refactor editor opening logic to use configurable editor settings in plugin * rm .idea and added to gitignore * added docs and removed an extra line added by accident * Additional improvements * small change * doc update --------- Co-authored-by: Alem Tuzlak <[email protected]>
- Loading branch information
1 parent
fb85ed0
commit fb9c1af
Showing
12 changed files
with
218 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,4 +131,7 @@ dist | |
|
||
.DS_Store | ||
**/.DS_Store | ||
.history | ||
.history | ||
|
||
# IDE | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
title: Remix Development Tools Editor Configuration | ||
description: Configuration options for the Remix Development Tools to interface with your editor | ||
--- | ||
|
||
Everyone uses their own editors, so it's important to be able to configure the editor that Remix Development Tools will open your files in. | ||
|
||
```ts | ||
type EditorConfig = { | ||
name: string; | ||
open(path: string, lineNumber: string | undefined): void; | ||
} | ||
``` | ||
## `name` | ||
The name of the editor that will be displayed on the Open in Editor button. | ||
## `open` | ||
This function will be called when the user clicks the Open in Editor button. It will receive the path to the file and the line number to open the file at. | ||
This function will both handle the case where you shift + right click an element on the page AND the open in X button in the UI, they return different values | ||
so be sure to cover both of them. | ||
```ts | ||
import { exec } from "node:child_process"; | ||
import { normalizePath } from "vite"; | ||
|
||
function open(path: string, lineNumber: string | undefined) { | ||
exec(`code -g "${normalizePath(path)}${lineNumber ? `:${lineNumber}` : ""}"`); | ||
} | ||
``` | ||
|
||
## Editors | ||
|
||
Below are some examples of configurations for popular editors. | ||
|
||
### VS Code | ||
|
||
To use VS Code as your editor, you don't need to do anything, it's the default editor. | ||
|
||
### WebStorm | ||
|
||
To use WebStorm as your editor, you can use the following configuration: | ||
|
||
```ts | ||
import { exec } from "node:child_process"; | ||
import { cwd } from "node:process"; | ||
|
||
const editor = { | ||
name: "WebStorm", | ||
open(path, lineNumber) { | ||
exec( | ||
`webstorm "${process.cwd()}/${path}" --line ${lineNumber ? `--line ${lineNumber}` : ""}`.replace( | ||
/\$/g, | ||
"\\$", | ||
), | ||
); | ||
}, | ||
}; | ||
``` | ||
|
||
### GoLand | ||
|
||
To use WebStorm as your editor, you can use the following configuration: | ||
|
||
```ts | ||
import { exec } from "node:child_process"; | ||
import { cwd } from "node:process"; | ||
|
||
const editor = { | ||
name: "WebStorm", | ||
open(path, lineNumber) { | ||
if (!path) return; | ||
exec( | ||
`goland "${process.cwd()}/${path}" ${lineNumber ? `--line ${lineNumber}` : ""}` | ||
); | ||
}, | ||
}; | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import clsx from "clsx"; | ||
|
||
interface EditorButtonProps { | ||
onClick: () => void; | ||
name: string; | ||
} | ||
|
||
const EditorButton = ({ name, onClick }: EditorButtonProps) => { | ||
return ( | ||
<button | ||
onClick={onClick} | ||
className={clsx( | ||
"rdt-flex rdt-cursor-pointer rdt-items-center rdt-gap-1 rdt-rounded rdt-border rdt-border-[#1F9CF0] rdt-px-2.5 rdt-py-0.5 rdt-text-sm rdt-font-medium rdt-text-[#1F9CF0]" | ||
)} | ||
> | ||
Open in {name} | ||
</button> | ||
); | ||
}; | ||
|
||
export { EditorButton }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.