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 initial implementation #1

Merged
merged 5 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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 .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"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.DS_Store
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8
10 changes: 10 additions & 0 deletions LSP-some-sass.sublime-commands
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"caption": "Preferences: LSP-some-sass Settings",
"command": "edit_settings",
"args": {
"base_file": "${packages}/LSP-some-sass/LSP-some-sass.sublime-settings",
"default": "// Settings in here override those in \"LSP-some-sass/LSP-some-sass.sublime-settings\"\n\n{\n\t$0\n}\n",
},
},
]
146 changes: 146 additions & 0 deletions LSP-some-sass.sublime-settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
{
"command": ["${node_bin}", "${server_path}", "--stdio"],
niksy marked this conversation as resolved.
Show resolved Hide resolved
"settings": {
"somesass.workspace.exclude": ["**/.git/**", "**/node_modules/**"],
"somesass.workspace.loadPaths": [],
"somesass.workspace.logLevel": "info",
"somesass.css.codeAction.enabled": true,
"somesass.css.completion.enabled": true,
"somesass.css.completion.css": true,
"somesass.css.completion.includeFromCurrentDocument": true,
"somesass.css.completion.completePropertyWithSemicolon": true,
"somesass.css.completion.triggerPropertyValueCompletion": true,
"somesass.css.colors.enabled": true,
"somesass.css.colors.includeFromCurrentDocument": true,
"somesass.css.definition.enabled": true,
"somesass.css.diagnostics.enabled": true,
"somesass.css.diagnostics.deprecation.enabled": true,
"somesass.css.diagnostics.lint.enabled": true,
"somesass.css.diagnostics.lint.compatibleVendorPrefixes": "ignore",
"somesass.css.diagnostics.lint.vendorPrefix": "warning",
"somesass.css.diagnostics.lint.duplicateProperties": "ignore",
"somesass.css.diagnostics.lint.emptyRules": "warning",
"somesass.css.diagnostics.lint.importStatement": "ignore",
"somesass.css.diagnostics.lint.boxModel": "ignore",
"somesass.css.diagnostics.lint.universalSelector": "ignore",
"somesass.css.diagnostics.lint.zeroUnits": "ignore",
"somesass.css.diagnostics.lint.fontFaceProperties": "warning",
"somesass.css.diagnostics.lint.hexColorLength": "error",
"somesass.css.diagnostics.lint.argumentsInColorFunction": "error",
"somesass.css.diagnostics.lint.unknownProperties": "warning",
"somesass.css.diagnostics.lint.validProperties": [],
"somesass.css.diagnostics.lint.ieHack": "ignore",
"somesass.css.diagnostics.lint.unknownVendorSpecificProperties": "ignore",
"somesass.css.diagnostics.lint.propertyIgnoredDueToDisplay": "warning",
"somesass.css.diagnostics.lint.important": "ignore",
"somesass.css.diagnostics.lint.float": "ignore",
"somesass.css.diagnostics.lint.idSelector": "ignore",
"somesass.css.diagnostics.lint.unknownAtRules": "warning",
"somesass.css.foldingRanges.enabled": true,
"somesass.css.highlights.enabled": true,
"somesass.css.hover.enabled": true,
"somesass.css.hover.documentation": true,
"somesass.css.hover.references": true,
"somesass.css.links.enabled": true,
"somesass.css.references.enabled": true,
"somesass.css.rename.enabled": true,
"somesass.css.selectionRanges.enabled": true,
"somesass.css.semanticTokens.enabled": true,
"somesass.css.signatureHelp.enabled": true,
"somesass.css.workspaceSymbol.enabled": true,
"somesass.css.customData": [],
"somesass.scss.codeAction.enabled": true,
"somesass.scss.completion.enabled": true,
"somesass.scss.completion.css": true,
"somesass.scss.completion.mixinStyle": "all",
"somesass.scss.completion.includeFromCurrentDocument": true,
"somesass.scss.completion.suggestFromUseOnly": false,
"somesass.scss.completion.triggerPropertyValueCompletion": true,
"somesass.scss.colors.enabled": true,
"somesass.scss.colors.includeFromCurrentDocument": true,
"somesass.scss.definition.enabled": true,
"somesass.scss.diagnostics.enabled": true,
"somesass.scss.diagnostics.deprecation.enabled": true,
"somesass.scss.diagnostics.lint.enabled": true,
"somesass.scss.diagnostics.lint.compatibleVendorPrefixes": "ignore",
"somesass.scss.diagnostics.lint.vendorPrefix": "warning",
"somesass.scss.diagnostics.lint.duplicateProperties": "ignore",
"somesass.scss.diagnostics.lint.emptyRules": "warning",
"somesass.scss.diagnostics.lint.importStatement": "ignore",
"somesass.scss.diagnostics.lint.boxModel": "ignore",
"somesass.scss.diagnostics.lint.universalSelector": "ignore",
"somesass.scss.diagnostics.lint.zeroUnits": "ignore",
"somesass.scss.diagnostics.lint.fontFaceProperties": "warning",
"somesass.scss.diagnostics.lint.hexColorLength": "error",
"somesass.scss.diagnostics.lint.argumentsInColorFunction": "error",
"somesass.scss.diagnostics.lint.unknownProperties": "warning",
"somesass.scss.diagnostics.lint.validProperties": [],
"somesass.scss.diagnostics.lint.ieHack": "ignore",
"somesass.scss.diagnostics.lint.unknownVendorSpecificProperties": "ignore",
"somesass.scss.diagnostics.lint.propertyIgnoredDueToDisplay": "warning",
"somesass.scss.diagnostics.lint.important": "ignore",
"somesass.scss.diagnostics.lint.float": "ignore",
"somesass.scss.diagnostics.lint.idSelector": "ignore",
"somesass.scss.diagnostics.lint.unknownAtRules": "warning",
"somesass.scss.foldingRanges.enabled": true,
"somesass.scss.highlights.enabled": true,
"somesass.scss.hover.enabled": true,
"somesass.scss.hover.documentation": true,
"somesass.scss.hover.references": true,
"somesass.scss.links.enabled": true,
"somesass.scss.references.enabled": true,
"somesass.scss.rename.enabled": true,
"somesass.scss.selectionRanges.enabled": true,
"somesass.scss.semanticTokens.enabled": true,
"somesass.scss.signatureHelp.enabled": true,
"somesass.scss.workspaceSymbol.enabled": true,
"somesass.scss.customData": [],
"somesass.sass.codeAction.enabled": true,
"somesass.sass.completion.enabled": true,
"somesass.sass.completion.css": true,
"somesass.sass.completion.mixinStyle": "all",
"somesass.sass.completion.includeFromCurrentDocument": true,
"somesass.sass.completion.suggestFromUseOnly": false,
"somesass.sass.completion.triggerPropertyValueCompletion": true,
"somesass.sass.colors.enabled": true,
"somesass.sass.colors.includeFromCurrentDocument": true,
"somesass.sass.definition.enabled": true,
"somesass.sass.diagnostics.enabled": true,
"somesass.sass.diagnostics.deprecation.enabled": true,
"somesass.sass.diagnostics.lint.enabled": true,
"somesass.sass.diagnostics.lint.compatibleVendorPrefixes": "ignore",
"somesass.sass.diagnostics.lint.vendorPrefix": "warning",
"somesass.sass.diagnostics.lint.duplicateProperties": "ignore",
"somesass.sass.diagnostics.lint.emptyRules": "warning",
"somesass.sass.diagnostics.lint.importStatement": "ignore",
"somesass.sass.diagnostics.lint.boxModel": "ignore",
"somesass.sass.diagnostics.lint.universalSelector": "ignore",
"somesass.sass.diagnostics.lint.zeroUnits": "ignore",
"somesass.sass.diagnostics.lint.fontFaceProperties": "warning",
"somesass.sass.diagnostics.lint.hexColorLength": "error",
"somesass.sass.diagnostics.lint.argumentsInColorFunction": "error",
"somesass.sass.diagnostics.lint.unknownProperties": "warning",
"somesass.sass.diagnostics.lint.validProperties": [],
"somesass.sass.diagnostics.lint.ieHack": "ignore",
"somesass.sass.diagnostics.lint.unknownVendorSpecificProperties": "ignore",
"somesass.sass.diagnostics.lint.propertyIgnoredDueToDisplay": "warning",
"somesass.sass.diagnostics.lint.important": "ignore",
"somesass.sass.diagnostics.lint.float": "ignore",
"somesass.sass.diagnostics.lint.idSelector": "ignore",
"somesass.sass.diagnostics.lint.unknownAtRules": "warning",
"somesass.sass.foldingRanges.enabled": true,
"somesass.sass.highlights.enabled": true,
"somesass.sass.hover.enabled": true,
"somesass.sass.hover.documentation": true,
"somesass.sass.hover.references": true,
"somesass.sass.links.enabled": true,
"somesass.sass.references.enabled": true,
"somesass.sass.rename.enabled": true,
"somesass.sass.selectionRanges.enabled": true,
"somesass.sass.semanticTokens.enabled": true,
"somesass.sass.signatureHelp.enabled": true,
"somesass.sass.workspaceSymbol.enabled": true,
"somesass.sass.customData": []
},
"selector": "source.scss"
}
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-some-sass",
"command": "edit_settings",
"args": {
"base_file": "${packages}/LSP-some-sass/LSP-some-sass.sublime-settings",
"default": "// Settings in here override those in \"LSP-some-sass/LSP-some-sass.sublime-settings\"\n\n{\n\t$0\n}\n",
},
},
],
},
],
},
],
},
],
},
]
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# LSP-some-sass

Sass support for Sublime’s LSP.

Provided through [Some Sass language server](https://github.com/wkillerud/some-sass/tree/main/packages/language-server).

### Installation

* Install [LSP](https://packagecontrol.io/packages/LSP) and `LSP-some-sass` via Package Control.
* Install [Sass syntax higlight package](https://packagecontrol.io/packages/Sass).
* Restart Sublime.

### Configuration

There are some ways to configure the package and the language server.

- From `Preferences > Package Settings > LSP > Servers > LSP-some-sass`
- From the command palette `Preferences: LSP-some-sass Settings`

### FAQ

### Using with Vue SFC

When working with Vue SFC, LSP-volar is usually used to provide LSP capabilities to every part of component.

Since LSP-some-sass can be used to process `style[lang="scss"]` blocks in SFCs, CSS language features from LSP-volar
will clash with LSP-some-sass since both are trying to provide information at the same time.

To resolve this, it’s best to disable certain LSP-volar CSS language features and let LSP-some-sass handle that.

* In `LSP-some-sass.sublime-settings` set `selector` to handle Vue SFC:

```json
{
"selector": "source.scss | text.html.vue"
}
```

* In `LSP-volar.sublime-settings` disable Sass features:

```json
{
"settings": {
"scss.hover.documentation": false,
"scss.hover.references": false
}
}
```

Beware that there are certain features that can’t be disabled currently (duplicate color provider references).
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"
]
}
}
23 changes: 23 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.

5 changes: 5 additions & 0 deletions language-server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"some-sass-language-server": "^2.0.2"
}
niksy marked this conversation as resolved.
Show resolved Hide resolved
}
20 changes: 20 additions & 0 deletions plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from lsp_utils import NpmClientHandler
import os


def plugin_loaded():
LspSassPlugin.setup()


def plugin_unloaded():
LspSassPlugin.cleanup()


class LspSassPlugin(NpmClientHandler):
package_name = __package__
server_directory = 'language-server'
server_binary_path = os.path.join(server_directory, 'node_modules', 'some-sass-language-server', 'bin', 'some-sass-language-server')

@classmethod
def required_node_version(cls) -> str:
return '>=20'
Comment on lines +19 to +20
Copy link
Member

@rchl rchl Oct 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not work with v18?
We are currently including 18 with lsp_utils so it would be quite inconvenient if it wouldn't work with that.

(that said, it's probably a good time to update to 20 in lsp_utils)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m following what is defined in language server package.json engines field: https://github.com/wkillerud/some-sass/blob/main/packages/language-server/package.json#L14

I suppose it could work with Node 18, I know I’ve used it before I switched to Node 20.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then it's time to update node version in lsp_utils I think.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing in sublimelsp/lsp_utils#125.

We should release those at the same time (or lsp_utils first).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve update PR description to reflect this.

Loading