Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add LSP-rome #1

Merged
merged 19 commits into from
Jun 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.dependabot export-ignore
.github/ export-ignore
codecov.yml export-ignore
mypy.ini export-ignore
pyrightconfig.json export-ignore
tox.ini export-ignore
unittesting.json export-ignore
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: npm
directory: /language-server
schedule:
interval: daily
time: "11:00"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 SublimeLSP

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
17 changes: 17 additions & 0 deletions LSP-rome.sublime-commands
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"caption": "Preferences: LSP-rome Settings",
"command": "edit_settings",
"args": {
"base_file": "${packages}/LSP-rome/LSP-rome.sublime-settings",
"default": "// Settings in here override those in \"LSP-rome/LSP-rome.sublime-settings\"\n\n{\n\t$0\n}\n"
}
},
{
"caption": "LSP-rome: Organize Imports",
"command": "lsp_code_actions",
"args": {
"only_kinds": ["source.organizeImports.rome"],
}
},
]
14 changes: 14 additions & 0 deletions LSP-rome.sublime-settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"settings": {
// The rome lsp server executable. If the path is relative, the workspace folder will be used as base path.
"rome.lspBin": null,
// Enable/Disable Rome handling renames in the workspace. (Experimental)
"rome.rename": null,
// Require a Rome configuration file to enable syntax errors, formatting and linting.
"rome.requireConfiguration": true,
},
// Also supports source.json but in Sublime Text it's not possible to differentiate JSON and JSONC and enabling
// Rome for JSONC by default would produce error diagnostics due to comments and trailing commas if those don't
// have proper "$schema" assigned.
"selector": "source.js | source.ts | source.jsx | source.tsx | source.js.jsx | source.js.react | source.ts.react",
}
34 changes: 34 additions & 0 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"id": "preferences",
"children": [
{
"caption": "Package Settings",
"mnemonic": "P",
"id": "package-settings",
"children": [
{
"caption": "LSP",
"id": "lsp-settings",
"children": [
{
"caption": "Servers",
"id": "lsp-servers",
"children": [
{
"caption": "LSP-rome",
"command": "edit_settings",
"args": {
"base_file": "${packages}/LSP-rome/LSP-rome.sublime-settings",
"default": "// Settings in here override those in \"LSP-rome/LSP-rome.sublime-settings\"\n\n{\n\t$0\n}\n",
}
}
]
}
]
}
]
}
]
}
]
73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# LSP-rome

[Rome](https://rome.tools/) unifies your development stack by combining the functionality of separate tools. It uses a single configuration file, has fantastic performance, and works with any stack. This package enables Sublime Text integration so that you can:
- Format files on save or when issuing the `LSP: Format Document` command
- See linting hints while you type and apply code fixes
- Perform refactors

The package supports JavaScript and TypeScript files.

## Installation

1. Install [LSP](https://packagecontrol.io/packages/LSP) and [LSP-rome](https://packagecontrol.io/packages/LSP-rome) via Package Control.
2. (Optional but recommended) Install [LSP-file-watcher-chokidar](https://github.com/sublimelsp/LSP-file-watcher-chokidar) via Package Control to enable functionality to notify the server about changes to the `rome.json` configuration file.
3. Restart Sublime.

## Configuration

Open the configuration file using the Command Palette `Preferences: LSP-rome Settings` command or from the Sublime menu.

> **Note**
> By default Rome requires a configuration file (`rome.json`) in the root of the project to enable syntax errors, formatting and linting. This can be changed through the `rome.requireConfiguration` option in `Preferences: LSP-rome Settings`.

## Rome Resolution

The package tries to use Rome from your project's local dependencies (`node_modules/rome`). We recommend adding Rome as a project dependency to ensure that NPM scripts and the extension use the same Rome version.

You can also explicitly specify the `rome` binary the extension should use by configuring the `rome.lspBin` setting in `LSP-rome` Settings.

If the project has no dependency on Rome and no explicit path is configured, the extension uses the Rome version managed by this package.

## Usage

### Format document

To format an entire document, open the _Command Palette_ (<kbd>Ctrl</kbd>/<kbd title="Cmd">⌘</kbd>+<kbd title="Shift">⇧</kbd>+<kbd>P</kbd>) and select `LSP: Format Document`.

To format a text range, select the text you want to format, open the _Command Palette_ (<kbd>Ctrl</kbd>/<kbd title="Cmd">⌘</kbd>+<kbd title="Shift">⇧</kbd>+<kbd>P</kbd>), and select `LSP: Format Selection`.

### Fix on save

To enable fix on save, open `Preferences: LSP Settings` from the _Command Palette_ and set:

```json
{
"lsp_code_actions_on_save": {
"quickfix.rome": true
}
}
```

### Imports Sorting [Experimental]

Rome has experimental support for imports sorting through the "Organize Imports" code action. This action is accessible through the _Command Palette_ (<kbd>Ctrl</kbd>/<kbd title="Cmd">⌘</kbd>+<kbd title="Shift">⇧</kbd>+<kbd>P</kbd>) by selecting `LSP-rome: Organize Imports`.

Currently, this functionality needs to be explicitly enabled in the `rome.json` configuration file:

```json
{
"organizeImports": {
"enabled": true
}
}
```

You can add the following to `Preferences: LSP Settings` if you want the action to run automatically on save instead of calling it manually:

```json
{
"lsp_code_actions_on_save":{
"source.organizeImports.rome": true
}
}
```
8 changes: 8 additions & 0 deletions dependencies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"*": {
"*": [
"lsp_utils",
"sublime_lib"
]
}
}
155 changes: 155 additions & 0 deletions language-server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions language-server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"rome": "^12.1.3"
}
}
Loading