Skip to content

Commit

Permalink
Add initial implementation (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
niksy authored Oct 24, 2024
1 parent 3c424b2 commit 61730fa
Show file tree
Hide file tree
Showing 13 changed files with 1,214 additions and 0 deletions.
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 @@
{
"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": []
},
"command": ["${node_bin}", "${server_path}", "--stdio"],
"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"
]
}
}
24 changes: 24 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.

7 changes: 7 additions & 0 deletions language-server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "some-sass",
"private": true,
"dependencies": {
"some-sass-language-server": "^2.0.2"
}
}
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'
Loading

0 comments on commit 61730fa

Please sign in to comment.