-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
449 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
r"""This module can be called by | ||
`python -m <https://docs.python.org/3/library/__main__.html>`_. | ||
""" | ||
|
||
from argparse import ArgumentParser, RawDescriptionHelpFormatter | ||
from contextlib import suppress | ||
from datetime import datetime | ||
|
||
from make_language_server import __version__ | ||
|
||
from . import FILETYPE | ||
from . import __name__ as NAME | ||
|
||
NAME = NAME.replace("_", "-") | ||
VERSION = rf"""{NAME} {__version__} | ||
Copyright (C) {datetime.now().year} | ||
Written by Wu Zhenyu | ||
""" | ||
EPILOG = """ | ||
Report bugs to <wuzhenyu@ustc.edu>. | ||
""" | ||
|
||
|
||
def get_parser(): | ||
r"""Get a parser for unit test.""" | ||
parser = ArgumentParser( | ||
epilog=EPILOG, | ||
formatter_class=RawDescriptionHelpFormatter, | ||
) | ||
with suppress(ImportError): | ||
import shtab | ||
|
||
shtab.add_argument_to(parser) | ||
parser.add_argument("--version", version=VERSION, action="version") | ||
parser.add_argument( | ||
"--generate-schema", | ||
choices=FILETYPE.__args__, # type: ignore | ||
help="generate schema json", | ||
) | ||
parser.add_argument( | ||
"--indent", | ||
type=int, | ||
default=2, | ||
help="generated json's indent", | ||
) | ||
parser.add_argument( | ||
"--color", | ||
choices=["auto", "always", "never"], | ||
default="auto", | ||
help="when to display color", | ||
) | ||
return parser | ||
|
||
|
||
def main(): | ||
r"""Parse arguments and provide shell completions.""" | ||
parser = get_parser() | ||
args = parser.parse_args() | ||
|
||
if args.generate_schema: | ||
from lsp_tree_sitter.utils import pprint | ||
|
||
from .misc import get_schema | ||
|
||
pprint(get_schema(args.generate_schema), indent=args.indent) | ||
exit() | ||
|
||
from .server import AutoconfLanguageServer | ||
|
||
AutoconfLanguageServer(NAME, __version__).start_io() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.