Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support yaml config file #504

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
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