Skip to content

Commit 45b067c

Browse files
committed
Introduce config source for "pyls"
1 parent 48eedea commit 45b067c

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

pyls/config/config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ def __init__(self, root_uri, init_opts, process_id, capabilities):
4040
except ImportError:
4141
pass
4242

43+
from .pyls_conf import PylsConfig
44+
self._config_sources['pyls'] = PylsConfig(self._root_path)
45+
4346
self._pm = pluggy.PluginManager(PYLS)
4447
self._pm.trace.root.setwriter(log.debug)
4548
self._pm.enable_tracing()
@@ -104,7 +107,7 @@ def settings(self, document_path=None):
104107
settings.cache_clear() when the config is updated
105108
"""
106109
settings = {}
107-
sources = self._settings.get('configurationSources', DEFAULT_CONFIG_SOURCES)
110+
sources = self._settings.get('configurationSources', DEFAULT_CONFIG_SOURCES) + ['pyls']
108111

109112
for source_name in reversed(sources):
110113
source = self._config_sources.get(source_name)

pyls/config/pyls_conf.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import logging
2+
from pyls._utils import find_parents
3+
from .source import ConfigSource
4+
5+
log = logging.getLogger(__name__)
6+
7+
CONFIG_KEY = 'pyls'
8+
PROJECT_CONFIGS = ['setup.cfg', 'tox.ini']
9+
10+
OPTIONS = [
11+
]
12+
13+
14+
class PylsConfig(ConfigSource):
15+
"""Parse pyls configuration"""
16+
17+
def user_config(self):
18+
# pyls specific configuration mainly focuses on per-project
19+
# configuration
20+
return {}
21+
22+
def project_config(self, document_path):
23+
files = find_parents(self.root_path, document_path, PROJECT_CONFIGS)
24+
config = self.read_config_from_files(files)
25+
return self.parse_config(config, CONFIG_KEY, OPTIONS)

0 commit comments

Comments
 (0)