-
Notifications
You must be signed in to change notification settings - Fork 32
Enhancement: Language Protocol Server for SDoc text language #577
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
Comments
Tutorial: How to set up an SDoc LSP using textX-LSResources
from os.path import dirname, join
from textx import language, metamodel_from_file, metamodel_from_str
from tx_strictdoc.grammar import STRICTDOC_GRAMMAR
from tx_strictdoc.type_system import (
STRICTDOC_BASIC_TYPE_SYSTEM,
)
@language("Strictdoc", "*.sdoc")
def strictdoc():
"A language for writing technical specifications."
return metamodel_from_file(join(dirname(__file__), "strictdoc.tx")) #use this line preferably
#return metamodel_from_str(STRICTDOC_GRAMMAR + STRICTDOC_BASIC_TYPE_SYSTEM) #use this line if you are going to use the py grammar definition files diretly (not recommended) The advantage of using the strict.tx file instead of the py grammar definition files is that it is possible to generate the textmate files necessary for syntax highlightning.
import codecs
import os
from setuptools import find_packages, setup
PACKAGE_NAME = "tx-strictdoc"
VERSION = "0.1.0"
AUTHOR = "Michael Naderhirn"
AUTHOR_EMAIL = "[email protected]"
DESCRIPTION = "The strictdoc language for writing technical specifications"
KEYWORDS = "textX DSL python domain specific languages"
LICENSE = "MIT"
URL = "https://github.com/Strumenta/textx-tutorial"
setup(
name=PACKAGE_NAME,
version=VERSION,
description=DESCRIPTION,
url=URL,
author=AUTHOR,
author_email=AUTHOR_EMAIL,
keywords=KEYWORDS,
license=LICENSE,
packages=find_packages(),
include_package_data=True,
package_data={"": ["*.tx"]},
install_requires=["textx_ls_core"],
entry_points={"textx_languages": ["strictdoc = tx_strictdoc:strictdoc"]},
classifiers=[
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"Topic :: Software Development :: Libraries :: Python Modules",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
],
) Resulting project folder:
pip install . //language is installed now
Go to https://tomassetti.me/domain-specific-languages-in-python-with-textx/ See section Integrating with Visual Studio Code
go to https://github.com/eclipse/lsp4e/tree/master/documentation for testing purposes follow the tutorial important is step 7 which is used in step 3 of the above documentation optional arguments: |
This feature is suggested by @mnaderhirn who has created a work proof-of-concept based on https://github.com/textX/textX-LS which is
Language server for domain specific languages based on textX
(the attached comment will contain a short tutorial that was created by him and that is confirmed to work in Eclipse).An alternative option is to use the underlying building block of textX-LS: https://github.com/openlawlibrary/pygls which is a Python library for creating language servers.
The text was updated successfully, but these errors were encountered: