Skip to content

Commit

Permalink
Merge branch 'main' into no-restart
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl authored Sep 22, 2024
2 parents 8d0daff + 9b6ecb6 commit 58d7c9f
Show file tree
Hide file tree
Showing 27 changed files with 4,732 additions and 4,622 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
matrix:
os:
- ubuntu-latest
# - macOS-latest
- macOS-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
Expand Down
3 changes: 3 additions & 0 deletions LSP.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
// The maximum number of characters (approximately) before a scrollbar appears.
"popup_max_characters_height": 1000,

// Show diagnostics in hover popup if available
"show_diagnostics_in_hover": true,

// Show code actions in hover popup if available
"show_code_actions_in_hover": true,

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
2.2.0
9 changes: 5 additions & 4 deletions docs/src/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ You can include special variables in the `command_args` array that will be autom

| Variable | Type | Description |
| -------- | ---- | ----------- |
| `"$document_id"` | object | JSON object `{ 'uri': string }` containing the file URI of the active view, see [Document Identifier](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentIdentifier) |
| `"$document_id"` | object | JSON object `{ "uri": string }` containing the URI of the active view, see [TextDocumentIdentifier](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentIdentifier) |
| `"$versioned_document_id"` | object | JSON object `{ "uri": string, "version": int }` containing the URI and version of the active view, see [VersionedTextDocumentIdentifier](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#versionedTextDocumentIdentifier) |
| `"$file_uri"` | string | File URI of the active view |
| `"$selection"` | string | Content of the (topmost) selection |
| `"$offset"` | int | Character offset of the (topmost) cursor position |
| `"$selection_begin"` | int | Character offset of the begin of the (topmost) selection |
| `"$selection_end"` | int | Character offset of the end of the (topmost) selection |
| `"$position"` | object | JSON object `{ 'line': int, 'character': int }` of the (topmost) cursor position, see [Position](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#position) |
| `"$position"` | object | JSON object `{ "line": int, "character": int }` of the (topmost) cursor position, see [Position](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#position) |
| `"$line"` | int | Zero-based line number of the (topmost) cursor position, see [Position](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#position) |
| `"$character"` | int | Zero-based character offset relative to the current line of the (topmost) cursor position, see [Position](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#position) |
| `"$range"` | object | JSON object with `'start'` and `'end'` positions of the (topmost) selection, see [Range](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#range) |
| `"$text_document_position"` | object | JSON object with `'textDocument'` and `'position'` of the (topmost) selection, see [TextDocumentPositionParams](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentPositionParams) |
| `"$range"` | object | JSON object with `"start"` and `"end"` positions of the (topmost) selection, see [Range](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#range) |
| `"$text_document_position"` | object | JSON object with `"textDocument"` and `"position"` of the (topmost) selection, see [TextDocumentPositionParams](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentPositionParams) |
102 changes: 88 additions & 14 deletions docs/src/language_servers.md
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,8 @@ Follow installation instructions on [LSP-intelephense](https://github.com/sublim
"phpactor": {
"enabled": true,
"command": ["PATH/TO/phpactor", "language-server"],
"selector": "source.php"
"selector": "embedding.php",
"priority_selector": "source.php",
}
}
}
Expand Down Expand Up @@ -484,6 +485,24 @@ Follow installation instructions on [LSP-ruff](https://github.com/sublimelsp/LSP

Follow installation instructions on [R-IDE](https://github.com/REditorSupport/sublime-ide-r#installation).

## Racket

1. Install the [Racket](https://packagecontrol.io/packages/Racket) package from Package Control for syntax highlighting.
2. Follow the instructions for installation at [racket-langserver](https://github.com/jeapostrophe/racket-langserver).
3. Open `Preferences > Package Settings > LSP > Settings` and add the `"racket-langserver"` client configuration to the `"clients"`:

```jsonc
{
"clients": {
"racket-langserver": {
"enabled": true,
"command": ["racket", "-l", "racket-langserver"],
"selector": "source.racket"
}
}
}
```

## Ruby / Ruby on Rails

There are multiple options:
Expand Down Expand Up @@ -760,35 +779,90 @@ See [Javascript/TypeScript](#javascripttypescript).
## Typst

1. Install the [Typst](https://packagecontrol.io/packages/Typst) package from Package Control for syntax highlighting.
2. Download the [typst-lsp](https://github.com/nvarner/typst-lsp/releases) language server executable for your platform.
3. Open `Preferences > Package Settings > LSP > Settings` and add the `"typst-lsp"` client configuration to the `"clients"`:
2. Optional: to enable auto-completions for the relevant situations in Typst files, adjust Sublime's `"auto_complete_selector"` and/or `"auto_complete_triggers"` setting (`Preferences > Settings`); for example
```jsonc
{
"auto_complete_triggers":
[
{"selector": "text.html, text.xml", "characters": "<"},
{"selector": "punctuation.accessor", "rhs_empty": true},
{"selector": "text.typst", "characters": "#", "rhs_empty": true},
],
}
```
There are 2 available languages servers.
### Tinymist
This server has more features, like go to definition, rename, etc.
1. Install [tinymist](https://github.com/Myriad-Dreamin/tinymist).
2. Open `Preferences > Package Settings > LSP > Settings` and add the `"tinymist"` client configuration to the `"clients"`:
```jsonc
{
"clients": {
"typst-lsp": {
"tinymist": {
"enabled": true,
"command": ["C:\\path\\to\\typst-lsp-win32-x64.exe"], // adjust this path according to your platform/setup
"selector": "text.typst"
"command": ["path/to/tinymist"], // adjust this path according to your platform/setup
"selector": "text.typst",
// you can provide some initialization options:
"initializationOptions": {
"exportPdf": "never",
"typstExtraArgs": [],
},
}
}
}
```
4. Optional: to enable auto-completions for the relevant situations in Typst files, adjust Sublime's `"auto_complete_selector"` and/or `"auto_complete_triggers"` setting (`Preferences > Settings`); for example
3. Optional: to enable some useful commands provided by language server, add the following to the `*.sublime-commands`:
<!-- how to call: see https://github.com/Myriad-Dreamin/tinymist/blob/main/editors/vscode/src/extension.ts -->
```jsonc title="Packages/User/Default.sublime-commands"
[
// ...
{
"caption": "tinymist - Pin the main file to the currently opened document",
"command": "lsp_execute",
"args": {
"session_name": "tinymist",
"command_name": "tinymist.pinMain",
"command_args": ["${file}"]
}
},
{
"caption": "tinymist - Unpin the main file",
"command": "lsp_execute",
"args": {
"session_name": "tinymist",
"command_name": "tinymist.pinMain",
"command_args": [null]
}
},
]
```
### Typst-lsp
1. Install [typst-lsp](https://github.com/nvarner/typst-lsp/releases).
2. Open `Preferences > Package Settings > LSP > Settings` and add the `"typst-lsp"` client configuration to the `"clients"`:
```jsonc
{
"auto_complete_triggers":
[
{"selector": "text.html, text.xml", "characters": "<"},
{"selector": "punctuation.accessor", "rhs_empty": true},
{"selector": "text.typst", "characters": "#", "rhs_empty": true},
],
"clients": {
"typst-lsp": {
"enabled": true,
"command": ["path/to/typst-lsp"], // adjust this path according to your platform/setup
"selector": "text.typst"
}
}
}
```
5. Optional: to enable some useful commands provided by language server, add the following to the `*.sublime-commands`:
3. Optional: to enable some useful commands provided by language server, add the following to the `*.sublime-commands`:
<!-- how to call: see https://github.com/nvarner/typst-lsp/blob/master/editors/vscode/src/extension.ts -->
```jsonc title="Packages/User/Default.sublime-commands"
Expand Down
2 changes: 2 additions & 0 deletions messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@
"1.8.0": "messages/1.8.0.txt",
"1.9.0": "messages/1.9.0.txt",
"2.0.0": "messages/2.0.0.txt",
"2.1.0": "messages/2.1.0.txt",
"2.2.0": "messages/2.2.0.txt",
"install": "messages/install.txt"
}
11 changes: 11 additions & 0 deletions messages/2.1.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
=> 2.1.0

# Features

- Add `refactoring_auto_save` setting to save modified files after applying a refactoring (#2433) (Janos Wortmann)

# Fixes and Improvements

- Respect semantic token capability when dynamically registered (#2453) (Rafał Chłodnicki)
- Use caret for point to look up symbol (#2440) (Troels Bjørnskov)
- Various typing improvements (#2446, #2450, #2456, #2458, #2460, #2459) (Janos Wortmann, Jack Cherng, deathaxe)
18 changes: 18 additions & 0 deletions messages/2.2.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
=> 2.2.0

# Features

- feat: Add `"show_diagnostics_in_hover"` setting (#2489) (@HJX-001)

# Fixes

* fix: Unexpected keyword argument 'event' when using mouse keys (2492) (@deathaxe)
- fix: Enum issues (#2484, #2487) (Janos Wortmann)
- fix: Remove logging.basicConfig() and avoid polluting other packages (#2478) (Предраг Николић)

# Documentation

- docs: Add racket-langserver (#2481) (omentic)

# API changes
- Allow plugins to listen for server notification messages (#2496) (Предраг Николић)
3 changes: 3 additions & 0 deletions plugin/code_lens.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ def run(self, edit: sublime.Edit) -> None:
lambda i: self.on_select(code_lenses, i)
)

def want_event(self) -> bool:
return False

def on_select(self, code_lenses: list[CodeLensExtended], index: int) -> None:
try:
code_lens = code_lenses[index]
Expand Down
7 changes: 5 additions & 2 deletions plugin/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .core.edit import apply_text_edits
from .core.logging import debug
from .core.promise import Promise
from .core.protocol import CompletionEditRange
from .core.protocol import EditRangeWithInsertReplace
from .core.protocol import CompletionItem
from .core.protocol import CompletionItemDefaults
from .core.protocol import CompletionItemKind
Expand Down Expand Up @@ -127,7 +127,7 @@ def is_range(val: Any) -> TypeGuard[Range]:
return isinstance(val, dict) and 'start' in val and 'end' in val


def is_edit_range(val: Any) -> TypeGuard[CompletionEditRange]:
def is_edit_range(val: Any) -> TypeGuard[EditRangeWithInsertReplace]:
return isinstance(val, dict) and 'insert' in val and 'replace' in val


Expand Down Expand Up @@ -368,6 +368,9 @@ def run(self, edit: sublime.Edit, index: int, session_name: str) -> None:
else:
self._on_resolved(session_name, item)

def want_event(self) -> bool:
return False

def _on_resolved_async(self, session_name: str, item: CompletionItem) -> None:
sublime.set_timeout(functools.partial(self._on_resolved, session_name, item))

Expand Down
11 changes: 8 additions & 3 deletions plugin/core/edit.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from __future__ import annotations
from .logging import debug
from .protocol import AnnotatedTextEdit
from .protocol import Position
from .protocol import TextEdit
from .protocol import UINT_MAX
from .protocol import WorkspaceEdit
from typing import Dict, List, Optional, Tuple
from typing import Dict, List, Optional, Tuple, Union
import sublime


WorkspaceChanges = Dict[str, Tuple[List[TextEdit], Optional[int]]]
WorkspaceChanges = Dict[str, Tuple[List[Union[TextEdit, AnnotatedTextEdit]], Optional[int]]]


def parse_workspace_edit(workspace_edit: WorkspaceEdit) -> WorkspaceChanges:
Expand All @@ -24,7 +25,11 @@ def parse_workspace_edit(workspace_edit: WorkspaceEdit) -> WorkspaceChanges:
uri = text_document['uri']
version = text_document.get('version')
edits = document_change.get('edits')
changes.setdefault(uri, ([], version))[0].extend(edits)
for edit in edits:
if 'snippet' in edit:
debug('Ignoring unsupported SnippetTextEdit')
continue
changes.setdefault(uri, ([], version))[0].append(edit)
else:
raw_changes = workspace_edit.get('changes')
if isinstance(raw_changes, dict):
Expand Down
Loading

0 comments on commit 58d7c9f

Please sign in to comment.