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

fix: use textEdit for completion items insertion #232

Merged
merged 4 commits into from
Sep 17, 2024
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
23 changes: 0 additions & 23 deletions docs/src/language-server/configure-a-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,6 @@ For example, while we may document `"somesass.loadPaths": []` (and write it this
}
```

### Server-only settings

In addition to [the user settings](../user-guide/settings.md), language clients may want to configure these server-only settings to tweak how certain features interact with your specific editor.

| Key | Description |
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `somesass.completion.afterModule` | Set this to the empty string if you end up with `module..$variable` after accepting a code suggestion item. If `module.` or `module` disappears, you can set it to `"{module}."` or `"{module}"` respectively. That is a "magic string" that will be replaced with the actual module name. |
| `somesass.completion.beforeVariable` | Set this to the empty string if you end up with `$$variable` after accepting a code suggestion item. |

For example:

```json
{
"settings": {
"somesass": {
"completion": {
"afterModule": "{module}"
}
}
}
}
```

## Existing clients

This list of [language client implementations][languageclients] may be a helpful starting point. You may also want to look at [existing clients](./existing-clients.md).
Expand Down
2 changes: 1 addition & 1 deletion docs/src/language-server/helix.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ You can configure new language servers in [`.config/helix/languages.toml`](https
[language-server.some-sass-language-server]
command = "some-sass-language-server"
args = ["--stdio"]
config = { somesass = { completion = { afterModule = "", beforeVariable = "" } } }
config = { somesass = { loadPaths = [] } }

[[language]]
name = "scss"
Expand Down
4 changes: 1 addition & 3 deletions packages/language-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ some-sass-language-server --stdio

### Workspace configuration

The language server requests [settings](../user-guide/settings.md) via the [`workspace/configuration` message](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_configuration), on the `somesass` key. All fields are optional.

See the [documentation for the available settings](https://wkillerud.github.io/some-sass/user-guide/settings.html).
See [how to configure a client](https://wkillerud.github.io/some-sass/language-server/configure-a-client.html) and the [documentation for the available settings](https://wkillerud.github.io/some-sass/user-guide/settings.html).

## Capabilities

Expand Down
2 changes: 0 additions & 2 deletions packages/language-server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ export class SomeSassServer {
suggestionStyle: settings.suggestionStyle,
suggestFunctionsInStringContextAfterSymbols:
settings.suggestFunctionsInStringContextAfterSymbols,
afterModule: settings.completion?.afterModule,
beforeVariable: settings.completion?.beforeVariable,
},
});
}
Expand Down
4 changes: 0 additions & 4 deletions packages/language-server/src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ export interface ISettings {
readonly suggestFromUseOnly: boolean;
readonly suggestFunctionsInStringContextAfterSymbols: " (+-*%";
readonly triggerPropertyValueCompletion: boolean;
readonly completion?: {
afterModule?: string;
beforeVariable?: string;
};
}

export interface IEditorSettings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ test("should suggest symbol from a different document via @use", async () => {
'<style lang="scss">',
'@use "./one" as ns;',
".foo {",
" color: ns.",
" color: ns.;",
"}",
"</style>",
],
Expand Down Expand Up @@ -124,11 +124,23 @@ test("should suggest symbol from a different document via @use", async () => {
commitCharacters: [";", ","],
documentation: "limegreen\n____\nVariable declared in one.scss",
filterText: "ns.$primary",
insertText: "$primary",
kind: CompletionItemKind.Color,
label: "$primary",
sortText: undefined,
tags: [],
textEdit: {
newText: "ns.$primary",
range: {
end: {
character: 11,
line: 9,
},
start: {
character: 8,
line: 9,
},
},
},
},
);
});
Loading
Loading