Skip to content

Commit

Permalink
Add initial implementation (#1)
Browse files Browse the repository at this point in the history
Co-authored-by: Предраг Николић <[email protected]>
  • Loading branch information
niksy and predragnikolic authored Nov 14, 2024
1 parent d9efc4b commit 7460b5c
Show file tree
Hide file tree
Showing 13 changed files with 371 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-twiggy.sublime-commands
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"caption": "Preferences: LSP-twiggy Settings",
"command": "edit_settings",
"args": {
"base_file": "${packages}/LSP-twiggy/LSP-twiggy.sublime-settings",
"default": "// Settings in here override those in \"LSP-twiggy/LSP-twiggy.sublime-settings\"\n\n{\n\t$0\n}\n",
},
},
]
19 changes: 19 additions & 0 deletions LSP-twiggy.sublime-settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"settings": {
"twiggy.autoInsertSpaces": true,
"twiggy.inlayHints.macroArguments": true,
"twiggy.inlayHints.macro": true,
"twiggy.inlayHints.block": true,
"twiggy.phpExecutable": "php",
"twiggy.framework": "ignore",
"twiggy.symfonyConsolePath": "bin/console"
},
// File watching functionality only works with "LSP-file-watcher-chokidar" package installed.
"file_watcher": {
"patterns": [
"**/*.twig"
]
},
"command": ["${node_bin}", "${server_path}", "--stdio"],
"selector": "text.html.twig"
}
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-twiggy",
"command": "edit_settings",
"args": {
"base_file": "${packages}/LSP-twiggy/LSP-twiggy.sublime-settings",
"default": "// Settings in here override those in \"LSP-twiggy/LSP-twiggy.sublime-settings\"\n\n{\n\t$0\n}\n",
},
},
],
},
],
},
],
},
],
},
]
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# LSP-twiggy

Twig support for Sublime’s LSP.

Provided through [twiggy-language-server](https://github.com/moetelo/twiggy/tree/master/packages/language-server).

### Installation

* Install [LSP](https://packagecontrol.io/packages/LSP), [Twig Syntax](https://packagecontrol.io/packages/Twig) and [LSP-twiggy](https://packagecontrol.io/packages/LSP-twiggy) via Package Control.
* Restart Sublime.

### Configuration

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

- From `Preferences > Package Settings > LSP > Servers > LSP-twiggy`
- From the command palette `Preferences: LSP-twiggy Settings`
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"
]
}
}
130 changes: 130 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": "twiggy",
"private": true,
"dependencies": {
"twiggy-language-server": "^0.16.1"
}
}
16 changes: 16 additions & 0 deletions plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from lsp_utils import NpmClientHandler
import os


def plugin_loaded():
LspTwigPlugin.setup()


def plugin_unloaded():
LspTwigPlugin.cleanup()


class LspTwigPlugin(NpmClientHandler):
package_name = __package__
server_directory = 'language-server'
server_binary_path = os.path.join(server_directory, 'node_modules', 'twiggy-language-server', 'bin', 'server.js')
96 changes: 96 additions & 0 deletions sublime-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"contributions": {
"settings": [
{
"file_patterns": [
"/LSP-twiggy.sublime-settings"
],
"schema": {
"$id": "sublime://settings/LSP-twiggy",
"definitions": {
"PluginConfig": {
"properties": {
"settings": {
"additionalProperties": false,
"properties": {
"twiggy.autoInsertSpaces": {
"type": "boolean",
"default": true,
"markdownDescription": "Insert spaces inside of `{{ | }}` and `{% | %}`."
},
"twiggy.inlayHints.macroArguments": {
"type": "boolean",
"default": true,
"markdownDescription": "Inlay hints for macro arguments."
},
"twiggy.inlayHints.macro": {
"type": "boolean",
"default": true,
"markdownDescription": "Inlay hints for `{% endmacro %}`."
},
"twiggy.inlayHints.block": {
"type": "boolean",
"default": true,
"markdownDescription": "Inlay hints for `{% endblock %}`."
},
"twiggy.phpExecutable": {
"type": "string",
"scope": "resource",
"default": "php",
"markdownDescription": "Points to the PHP executable."
},
"twiggy.framework": {
"type": "string",
"scope": "resource",
"enum": [
"symfony",
"craft",
"ignore"
],
"markdownDescription": "Framework to use."
},
"twiggy.symfonyConsolePath": {
"type": "string",
"scope": "resource",
"default": "bin/console",
"markdownDescription": "Path to the Symfony console. See: https://symfony.com/doc/current/templates.html#inspecting-twig-information"
}
}
}
}
}
},
"type": "object",
"allOf": [
{
"$ref": "sublime://settings/LSP-plugin-base"
},
{
"$ref": "sublime://settings/LSP-twiggy#/definitions/PluginConfig"
}
]
}
},
{
"file_patterns": [
"/*.sublime-project"
],
"schema": {
"properties": {
"settings": {
"properties": {
"LSP": {
"properties": {
"LSP-twiggy": {
"$ref": "sublime://settings/LSP-twiggy#/definitions/PluginConfig"
}
}
}
}
}
}
}
}
]
}
}
24 changes: 24 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.

[tox]
envlist = py3
skipsdist = True

[pycodestyle]
max-line-length = 120

[flake8]
max-line-length = 120

[testenv]
deps =
flake8==3.7.9
mypy==0.750
yapf==0.29.0
commands =
mypy plugin.py
flake8 plugin.py tests
yapf --diff plugin.py

0 comments on commit 7460b5c

Please sign in to comment.