Skip to content

Commit

Permalink
💥 Update get_completion_list_by_enum()
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Dec 10, 2023
1 parent 31dfc34 commit d1eec6d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,27 @@
[![pypi/implementation](https://shields.io/pypi/implementation/tree-sitter-lsp)](https://pypi.org/project/tree-sitter-lsp/#files)
[![pypi/pyversions](https://shields.io/pypi/pyversions/tree-sitter-lsp)](https://pypi.org/project/tree-sitter-lsp/#files)

A library aimed to create language servers which connect:

- [tree-sitter](https://tree-sitter.github.io/tree-sitter/)
- [language server protocol](https://microsoft.github.io/language-server-protocol/specifications/specification-current)
- [json schema](https://json-schema.org/specification)

Some example language servers:
A core library to support many language servers:

- [termux-language-server](https://github.com/termux/termux-language-server/):
for some specific bash scripts:
- [`build.sh`](https://github.com/termux/termux-packages/wiki/Creating-new-package)
- [`PKGBUILD`](https://wiki.archlinux.org/title/PKGBUILD)
- [`*.ebuild`](https://dev.gentoo.org/~zmedico/portage/doc/man/ebuild.5.html)
- ...
- [mutt-language-server](https://github.com/neomutt/mutt-language-server):
for [(neo)mutt](https://github.com/neomutt/neomutt)'s (neo)muttrc
- [autotools-language-server](https://github.com/Freed-Wu/autotools-language-server/):
for `Makefile`
- [requirements-language-server](https://github.com/Freed-Wu/requirements-language-server/):
for `requirements.txt`
- [mutt-language-server](https://github.com/neomutt/mutt-language-server):
for [(neo)mutt](https://github.com/neomutt/neomutt)'s (neo)muttrc
- [zathura-language-server](https://github.com/Freed-Wu/zathura-language-server):
for [zathura](https://github.com/pwmt/zathura)'s zathurarc
- [bitbake-language-server](https://github.com/Freed-Wu/bitbake-language-server):
for [bitbake](https://docs.yoctoproject.org/bitbake/index.html)

Read
[![readthedocs](https://shields.io/readthedocs/tree-sitter-lsp)](https://tree-sitter-lsp.readthedocs.io)
to know more.
which connect:

- [tree-sitter](https://tree-sitter.github.io/tree-sitter/)
- [language server protocol](https://microsoft.github.io/language-server-protocol/specifications/specification-current)
- [json schema](https://json-schema.org/specification)
10 changes: 7 additions & 3 deletions src/tree_sitter_lsp/complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ def get_completion_list_by_enum(
text: str, property: dict[str, Any]
) -> CompletionList:
r"""Get completion list by enum. ``property.items`` must contains
``enum`` or ``oneOf.enum``. Not ``anyOf`` or ``allOf`` because ``enum``
shouldn't be satisfied with other conditions.
``enum``, ``oneOf.enum``, ``anyOf.enum`` or ``allOf``.
:param text:
:type text: str
Expand All @@ -32,7 +31,12 @@ def get_completion_list_by_enum(
"""
# if contains .items, it is an array
property = property.get("items", property)
enum = property.get("enum", property.get("oneOf", [{}])[0].get("enum", []))
enum = property.get(
"enum",
property.get(
"oneOf", property.get("anyOf", property.get("allOf", [{}]))
)[0].get("enum", []),
)
return CompletionList(
False,
[
Expand Down

0 comments on commit d1eec6d

Please sign in to comment.