Skip to content

Commit ef7c0fb

Browse files
committed
Add description about configuration in README.rst
This commit describes about not only features added by previous commits but also some underlying specifications.
1 parent addba28 commit ef7c0fb

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

README.rst

+96
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,98 @@ issue if you require assistance writing a plugin.
5656
Configuration
5757
-------------
5858

59+
Location of Configuration File
60+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61+
62+
There are three configuration levels below.
63+
64+
* user-level configuration (e.g. ~/.config/CONFIGFILE)
65+
* lsp-level configuration (via LSP didChangeConfiguration method)
66+
* project-level configuration
67+
68+
The latter level has priority over the former.
69+
70+
As project-level configuration, configurations are read in from files
71+
in the root of the workspace, by default. What files are read in is
72+
described after.
73+
74+
At evaluation of python source file ``foo/bar/baz/example.py`` for
75+
example, if there is any configuration file in the ascendant directory
76+
(i.e. ``foo``, ``foo/bar`` or ``foo/bar/baz``), it is read in before
77+
evaluation. If multiple ascendant directories contain configuration
78+
files, files only in the nearest ascendant directory are read in.
79+
80+
In some cases, automatically discovered files are exclusive with files
81+
in the root of the workspace.
82+
83+
Syntax in Configuration File
84+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
85+
86+
Configuration file should be written in "INI file" syntax.
87+
88+
Value specified in configuration file should be one of types below.
89+
90+
* bool
91+
* int
92+
* string
93+
* list
94+
95+
"List" value is string entries joined with comma. Both leading and
96+
trailing white spaces of each entries in a "list" value are trimmed.
97+
98+
Source Roots
99+
~~~~~~~~~~~~
100+
101+
"Source roots" is determined in the order below.
102+
103+
1. if ``pyls.source_roots`` (described after) is specified, its value
104+
is used as "source roots"
105+
2. if any of setup.py or pyproject.toml is found in the ascendant
106+
directory of python source file at evaluation, that directory is
107+
treated as "source roots"
108+
3. otherwise, the root of the workspace is treated as "source roots"
109+
110+
"Source roots" is used as a part of sys path at evaluation of python
111+
source files.
112+
113+
Python Language Server Specific Configuration
114+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
115+
116+
lsp-level and project-level configuration are supported for Python
117+
Language Server specific configuration.
118+
119+
For project-level configuration, setup.cfg and tox.ini are read in.
120+
Configuration files discovered automatically at evaluation of python
121+
source file are **not** exclusive with configuration files in the root
122+
of the workspace. Files in both locations are read in, and a
123+
configuration in the former files has priority over one in the latter.
124+
125+
Python Language Server specific configurations are show below.
126+
127+
* ``pyls.source_roots`` (list) to specify source roots
128+
* ``pyls.plugins.jedi.extra_paths`` (list) to specify extra sys paths
129+
130+
Relative path in these configurations is treated as relative to the
131+
directory, in which configuration file exists. For configuration via
132+
LSP didChangeConfiguration method, the root of the workspace is used
133+
as base directory.
134+
135+
Path in ``pyls.source_roots`` is ignored, if it refers outside of the
136+
workspace.
137+
138+
To make these configurations persisted into setup.cfg or tox.ini,
139+
describe them under ``[pyls]`` section like below.
140+
141+
.. code-block:: ini
142+
143+
[pyls]
144+
source_roots = services/foo, services/bar
145+
plugins.jedi.extra_paths = ../extra_libs
146+
147+
148+
Configuration at Source Code Evaluation
149+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
150+
59151
Configuration is loaded from zero or more configuration sources. Currently implemented are:
60152

61153
* pycodestyle: discovered in ~/.config/pycodestyle, setup.cfg, tox.ini and pycodestyle.cfg.
@@ -67,6 +159,10 @@ order to respect flake8 configuration instead.
67159
Overall configuration is computed first from user configuration (in home directory), overridden by configuration
68160
passed in by the language client, and then overriden by configuration discovered in the workspace.
69161

162+
Configuration files discovered in the workspace automatically at
163+
evaluation of python source file are exclusive with configuration
164+
files in the root of the workspace.
165+
70166
To enable pydocstyle for linting docstrings add the following setting in your LSP configuration:
71167
```
72168
"pyls.plugins.pydocstyle.enabled": true

0 commit comments

Comments
 (0)