Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pyls/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import logging.config
import sys
import yaml
from .python_ls import start_io_lang_server, start_tcp_lang_server, PythonLanguageServer

LOG_FORMAT = "%(asctime)s UTC - %(levelname)s - %(name)s - %(message)s"
Expand All @@ -30,6 +31,10 @@ def add_arguments(parser):
"and auto shut down language server process when parent process is not alive."
"Note that this may not work on a Windows machine."
)
parser.add_argument(
'-c', '--conf',
help='Pass a YAML file containing PYLS settings'
)

log_group = parser.add_mutually_exclusive_group()
log_group.add_argument(
Expand All @@ -54,6 +59,10 @@ def main():
args = parser.parse_args()
_configure_logger(args.verbose, args.log_config, args.log_file)

if args.conf:
with open(args.conf, 'r') as f:
PythonLanguageServer.INITIAL_CONFIG = yaml.load(f)

if args.tcp:
start_tcp_lang_server(args.host, args.port, PythonLanguageServer)
else:
Expand Down
4 changes: 3 additions & 1 deletion pyls/python_ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ class PythonLanguageServer(MethodDispatcher):
""" Implementation of the Microsoft VSCode Language Server Protocol
https://github.com/Microsoft/language-server-protocol/blob/master/versions/protocol-1-x.md
"""

# pylint: disable=too-many-public-methods,redefined-builtin

INITIAL_CONFIG = {}

def __init__(self, rx, tx, check_parent_process=False):
self.workspace = None
self.config = None
Expand Down Expand Up @@ -154,6 +155,7 @@ def m_initialize(self, processId=None, rootUri=None, rootPath=None, initializati

self.workspace = Workspace(rootUri, self._endpoint)
self.config = config.Config(rootUri, initializationOptions or {}, processId)
self.config.update(PythonLanguageServer.INITIAL_CONFIG)
self._dispatchers = self._hook('pyls_dispatchers')
self._hook('pyls_initialize')

Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
'futures; python_version<"3.2"',
'jedi>=0.13.2',
'python-jsonrpc-server>=0.1.0',
'pluggy'
'pluggy',
'pyyaml'
],

# List additional groups of dependencies here (e.g. development
Expand Down