Skip to content

Commit

Permalink
🔥 Remove CMakeLists.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Oct 26, 2023
1 parent 563c74e commit de3a5aa
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 159 deletions.
2 changes: 0 additions & 2 deletions .cmake-format.yaml

This file was deleted.

1 change: 0 additions & 1 deletion .cmakelintrc

This file was deleted.

62 changes: 35 additions & 27 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,47 @@ permissions:
contents: write

env:
CMAKE_GENERATOR: Ninja
PYTHONUTF8: "1"
python-version: 3.x
cache: pip

jobs:
build-wheels-and-test:
test:
strategy:
fail-fast: false
matrix:
runs-on:
- ubuntu-latest
- macos-latest
# OSError: [WinError 193] %1 is not a valid Win32 application
# https://github.com/tree-sitter/py-tree-sitter/issues/170
# - windows-latest
runs-on: ${{ matrix.runs-on }}
runs-on: ${{matrix.runs-on}}
steps:
- uses: actions/checkout@v3
- uses: docker/[email protected]
if: runner.os == 'Linux'
- uses: pypa/[email protected]
- uses: actions/upload-artifact@v3
- uses: actions/setup-python@v4
with:
path: |
wheelhouse/*.whl
python-version: ${{env.python-version}}
cache: ${{env.cache}}
cache-dependency-path: |-
requirements.txt
requirements/dev.txt
- name: Install dependencies
run: |
pip install -e '.[dev]'
- name: Test
run: |
pytest --cov
- uses: codecov/codecov-action@v3
build:
needs:
- build-wheels-and-test
runs-on: ubuntu-latest
needs: test
strategy:
fail-fast: false
matrix:
runs-on:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{matrix.runs-on}}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand All @@ -57,35 +68,32 @@ jobs:
- name: Install dependencies
run: |
pip install build
- name: Build sdist
- name: Build
run: |
pyproject-build -s
pyproject-build
- uses: pypa/gh-action-pypi-publish@release/v1
if: runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/')
with:
password: ${{secrets.PYPI_API_TOKEN}}
- uses: actions/upload-artifact@v3
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
if: runner.os == 'Linux' && ! startsWith(github.ref, 'refs/tags/')
with:
path: |
dist/*
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
if: runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/')
with:
# body_path: build/CHANGELOG.md
files: |
dist/*
- uses: pypa/gh-action-pypi-publish@release/v1
if: startsWith(github.ref, 'refs/tags/')
with:
password: ${{ secrets.PYPI_API_TOKEN }}
deploy-aur:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: Freed-Wu/[email protected]
if: startsWith(github.ref, 'refs/tags/')
with:
package_name: termux-language-server
ssh_private_key: ${{secrets.AUR_SSH_PRIVATE_KEY}}
Expand All @@ -99,5 +107,5 @@ jobs:
run: >
curl -X POST -d '{"ref":"main"}'
-H "Accept: application/vnd.github.v3+json"
-H "Authorization: Bearer ${{ secrets.GH_TOKEN }}"
-H "Authorization: Bearer ${{secrets.GH_TOKEN}}"
https://api.github.com/repos/Freed-Wu/nur-packages/actions/workflows/version.yml/dispatches
13 changes: 0 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,6 @@ repos:
- -cpyproject.toml
additional_dependencies:
- tomli
- repo: https://github.com/cmake-lint/cmake-lint
rev: 1.4.2
hooks:
- id: cmakelint
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
additional_dependencies:
- pyyaml
- id: cmake-lint
additional_dependencies:
- pyyaml

ci:
skip:
Expand Down
12 changes: 0 additions & 12 deletions CMakeLists.txt

This file was deleted.

40 changes: 7 additions & 33 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = ["scikit-build-core"]
build-backend = "scikit_build_core.build"
requires = ["setuptools_scm[toml] >= 6.2", "setuptools-generate >= 0.0.6"]
build-backend = "setuptools.build_meta"

# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
[project]
Expand All @@ -27,22 +27,7 @@ classifiers = [
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
]
# dynamic = ["version", "dependencies", "optional-dependencies"]
# https://github.com/pypa/twine/issues/753
dynamic = ["version"]
dependencies = [
"fqdn",
"platformdirs",
"rfc3987",
"tree-sitter-lsp",
]

[project.optional-dependencies]
colorize = ["tree-sitter-lsp[colorize]"]
dev = ["pytest-cov"]
misc = ["tree-sitter-lsp[misc]"]
# pyproject.toml doesn't support git+git://
pkgbuild = ["pyalpm"]
dynamic = ["version", "dependencies", "optional-dependencies"]

[[project.authors]]
name = "Wu Zhenyu"
Expand All @@ -65,16 +50,6 @@ portage-language-server = "termux_language_server.__main__:main"
[tool.scikit-build]
experimental = true

[tool.scikit-build.metadata.version]
provider = "scikit_build_core.metadata.setuptools_scm"

[tool.scikit-build.sdist]
include = ["src/termux_language_server/_version.py"]

[[tool.scikit-build.generate]]
path = "termux_language_server/_metainfo.py"
template-path = "templates/metainfo.py"

[tool.setuptools.dynamic.dependencies]
file = "requirements.txt"

Expand All @@ -92,6 +67,9 @@ file = "requirements/termux.txt"
[tool.setuptools_scm]
write_to = "src/termux_language_server/_version.py"

[tool.setuptools-generate]
write-to = "src/termux_language_server/_metainfo.py"

[tool.mdformat]
number = true

Expand Down Expand Up @@ -121,10 +99,6 @@ skips = ["*_test.py", "*/test_*.py"]

[tool.cibuildwheel]
archs = ["all"]
# jsonschema depends on rpds-py which depends on cargo
# disable *-musllinux_*
# Fatal Python error: Segmentation fault
# disable pp*
skip = "*37-* *38-* *39-* *-musllinux_* pp*"
skip = "*37-* *38-* *39-*"
before-test = "pip install -rrequirements.txt -rrequirements/dev.txt"
test-command = "pytest {project}"
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
# https://python-jsonschema.readthedocs.io/en/stable/validate/#validating-formats
# hostname
fqdn
# get nvim-tree-sitter's parser
# ~/.config/pacman/template.md.j2
platformdirs
# uri
rfc3987
tree-sitter-languages
tree-sitter-lsp
11 changes: 8 additions & 3 deletions src/termux_language_server/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,21 @@ def main():

pprint(get_schema(args.generate_schema), indent=args.indent)
exit()
from tree_sitter_languages import get_parser as _get_parser
from tree_sitter_lsp.diagnose import check
from tree_sitter_lsp.format import format

from .finders import DIAGNOSTICS_FINDER_CLASSES, FORMAT_FINDER_CLASSES
from .parser import parse
from .utils import get_filetype

format(args.format, parse, FORMAT_FINDER_CLASSES, get_filetype)
parser = _get_parser("bash")
format(args.format, parser.parse, FORMAT_FINDER_CLASSES, get_filetype)
result = check(
args.check, parse, DIAGNOSTICS_FINDER_CLASSES, get_filetype, args.color
args.check,
parser.parse,
DIAGNOSTICS_FINDER_CLASSES,
get_filetype,
args.color,
)
if args.format or args.check:
exit(result)
Expand Down
43 changes: 0 additions & 43 deletions src/termux_language_server/parser.py

This file was deleted.

7 changes: 5 additions & 2 deletions src/termux_language_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
TextEdit,
)
from pygls.server import LanguageServer
from tree_sitter_languages import get_parser
from tree_sitter_lsp.diagnose import get_diagnostics
from tree_sitter_lsp.finders import PositionFinder
from tree_sitter_lsp.format import get_text_edits
Expand All @@ -38,7 +39,6 @@
PackageFinder,
)
from .packages import search_package_document, search_package_names
from .parser import parse
from .utils import get_filetype, get_schema


Expand All @@ -54,6 +54,7 @@ def __init__(self, *args: Any) -> None:
"""
super().__init__(*args)
self.trees = {}
self.parser = get_parser("bash")

@self.feature(TEXT_DOCUMENT_DID_OPEN)
@self.feature(TEXT_DOCUMENT_DID_CHANGE)
Expand All @@ -68,7 +69,9 @@ def did_change(params: DidChangeTextDocumentParams) -> None:
if filetype == "":
return None
document = self.workspace.get_document(params.text_document.uri)
self.trees[document.uri] = parse(document.source.encode())
self.trees[document.uri] = self.parser.parse(
document.source.encode()
)
diagnostics = get_diagnostics(
document.uri,
self.trees[document.uri],
Expand Down
20 changes: 0 additions & 20 deletions templates/metainfo.py

This file was deleted.

4 changes: 2 additions & 2 deletions tests/test_schema.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
r"""Test schema."""
import os

from tree_sitter_languages import get_parser
from tree_sitter_lsp.finders import SchemaFinder

from termux_language_server.parser import parse
from termux_language_server.schema import BashTrie
from termux_language_server.utils import get_filetype, get_schema

Expand All @@ -24,7 +24,7 @@ def test_SchemaFinder() -> None:
assert filetype == "build.sh"
with open(path, "rb") as f:
text = f.read()
tree = parse(text)
tree = get_parser("bash").parse(text)
finder = SchemaFinder(get_schema(filetype), BashTrie)
diagnostics = finder.get_diagnostics(path, tree)
assert len(diagnostics) > 0

0 comments on commit de3a5aa

Please sign in to comment.