Skip to content

Commit bc89ac4

Browse files
authored
Add --version CLI argument and return version in InitializeResult (#44)
1 parent 34be02a commit bc89ac4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

pylsp/__main__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
from .python_lsp import (PythonLSPServer, start_io_lang_server,
1616
start_tcp_lang_server)
17+
from ._version import __version__
1718

1819
LOG_FORMAT = "%(asctime)s {0} - %(levelname)s - %(name)s - %(message)s".format(
1920
time.localtime().tm_zone)
@@ -57,6 +58,10 @@ def add_arguments(parser):
5758
help="Increase verbosity of log output, overrides log config file"
5859
)
5960

61+
parser.add_argument(
62+
'-V', '--version', action='version', version='%(prog)s v' + __version__
63+
)
64+
6065

6166
def main():
6267
parser = argparse.ArgumentParser()

pylsp/python_lsp.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from . import lsp, _utils, uris
1515
from .config import config
1616
from .workspace import Workspace
17+
from ._version import __version__
1718

1819
log = logging.getLogger(__name__)
1920

@@ -225,7 +226,13 @@ def watch_parent_process(pid):
225226
self.watching_thread.daemon = True
226227
self.watching_thread.start()
227228
# Get our capabilities
228-
return {'capabilities': self.capabilities()}
229+
return {
230+
'capabilities': self.capabilities(),
231+
'serverInfo': {
232+
'name': 'pylsp',
233+
'version': __version__,
234+
},
235+
}
229236

230237
def m_initialized(self, **_kwargs):
231238
self._hook('pylsp_initialized')

0 commit comments

Comments
 (0)