restructure as a setuptools project
This commit is contained in:
parent
592bd8c628
commit
7a346a9185
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
*.egg-info
|
||||||
|
__pycache__
|
||||||
|
*.pyc
|
38
lsp_proxy/__init__.py
Executable file
38
lsp_proxy/__init__.py
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import inspect
|
||||||
|
|
||||||
|
from .lsp import LspServer, handler, method, command
|
||||||
|
from .java import Java
|
||||||
|
|
||||||
|
def find_server_classes (values=None):
|
||||||
|
values = values or globals()
|
||||||
|
return dict([(item[0].lower(), item[1]) for item in values.items() if inspect.isclass(item[1]) and LspServer in inspect.getmro(item[1])])
|
||||||
|
|
||||||
|
def select_server_class (argument):
|
||||||
|
classes = find_server_classes()
|
||||||
|
if argument.lower() in classes:
|
||||||
|
return classes[argument]
|
||||||
|
|
||||||
|
if os.path.isfile(argument):
|
||||||
|
script_locals = {
|
||||||
|
"LspServer": LspServer,
|
||||||
|
"handler": handler,
|
||||||
|
"method": method,
|
||||||
|
"command": command
|
||||||
|
}
|
||||||
|
|
||||||
|
with open(argument) as server_script:
|
||||||
|
exec(server_script.read(), script_locals)
|
||||||
|
|
||||||
|
return [item[1] for item in find_server_classes(script_locals).items() if not item[1] == LspServer][0]
|
||||||
|
|
||||||
|
def main ():
|
||||||
|
server_class = select_server_class(sys.argv[1])
|
||||||
|
server = server_class(sys.argv[2:])
|
||||||
|
|
||||||
|
try:
|
||||||
|
server.start()
|
||||||
|
except Exception as e:
|
||||||
|
server.close()
|
||||||
|
raise e
|
@ -1,6 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from .lsp import LspServer, command
|
||||||
|
|
||||||
FILE_URI = "file://"
|
FILE_URI = "file://"
|
||||||
|
|
||||||
def locate_product_directory (jdt_ls_path):
|
def locate_product_directory (jdt_ls_path):
|
32
lsp-proxy → lsp_proxy/lsp.py
Executable file → Normal file
32
lsp-proxy → lsp_proxy/lsp.py
Executable file → Normal file
@ -1,5 +1,3 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import inspect
|
import inspect
|
||||||
@ -106,33 +104,3 @@ class LspServer:
|
|||||||
if self.process:
|
if self.process:
|
||||||
self.process.terminate()
|
self.process.terminate()
|
||||||
|
|
||||||
def find_server_classes (values=None):
|
|
||||||
values = values or globals()
|
|
||||||
return dict([item for item in values.items() if inspect.isclass(item[1]) and LspServer in inspect.getmro(item[1])])
|
|
||||||
|
|
||||||
def select_server_class (argument):
|
|
||||||
classes = find_server_classes()
|
|
||||||
if argument in classes:
|
|
||||||
return classes[argument]
|
|
||||||
|
|
||||||
if os.path.isfile(argument):
|
|
||||||
script_locals = {
|
|
||||||
"LspServer": LspServer,
|
|
||||||
"handler": handler,
|
|
||||||
"method": method,
|
|
||||||
"command": command
|
|
||||||
}
|
|
||||||
|
|
||||||
with open(argument) as server_script:
|
|
||||||
exec(server_script.read(), script_locals)
|
|
||||||
|
|
||||||
return [item[1] for item in find_server_classes(script_locals).items() if not item[1] == LspServer][0]
|
|
||||||
|
|
||||||
server_class = select_server_class(sys.argv[1])
|
|
||||||
server = server_class(sys.argv[2:])
|
|
||||||
|
|
||||||
try:
|
|
||||||
server.start()
|
|
||||||
except Exception as e:
|
|
||||||
server.close()
|
|
||||||
raise e
|
|
17
setup.py
Normal file
17
setup.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
from distutils.core import setup
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name='lsp-proxy',
|
||||||
|
version='0.0.1',
|
||||||
|
description='lsp-proxy is a proxy for language servers.',
|
||||||
|
author='Adrian Malacoda',
|
||||||
|
packages=['lsp_proxy'],
|
||||||
|
install_requires=[],
|
||||||
|
entry_points={
|
||||||
|
'console_scripts': [
|
||||||
|
'lsp-proxy = lsp_proxy:main'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user