Integrate my python-lsp-server PR
This commit is contained in:
parent
1a206381d7
commit
939f003c0c
17
README.org
17
README.org
@ -4403,17 +4403,16 @@ agree with [[https://black.readthedocs.io/en/stable/index.html][black's uncompro
|
|||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
[[https://jedi.readthedocs.io/en/latest/][Jedi]] provides grammar checking and completion candidates to [[https://github.com/python-lsp/python-lsp-server][python-lsp-server]].
|
[[https://jedi.readthedocs.io/en/latest/][Jedi]] provides grammar checking and completion candidates to [[https://github.com/python-lsp/python-lsp-server][python-lsp-server]].
|
||||||
Only [[https://jedi.readthedocs.io/en/latest/docs/changelog.html][jedi-0.18.1]] works with for instance [[https://numpy.org/][numpy-1.23.3]] in the sense that it does
|
Only [[https://jedi.readthedocs.io/en/latest/docs/changelog.html][jedi-0.18.1]] works with for instance [[https://numpy.org/][numpy-1.23.4]] in the sense that it does
|
||||||
not choke on universal functions provided that [[https://jedi.readthedocs.io/en/latest/][jedi]] does not parse but import
|
not choke on universal functions provided that [[https://jedi.readthedocs.io/en/latest/][jedi]] does not parse but import
|
||||||
[[https://numpy.org/][numpy-1.23.3]] (see [[https://github.com/davidhalter/jedi/issues/1744][jedi issue #1744]], [[https://github.com/davidhalter/jedi/issues/1745][#1745]], and [[https://github.com/davidhalter/jedi/issues/1746][#1746]]). Since the universal
|
[[https://numpy.org/][numpy-1.23.4]] (see [[https://github.com/davidhalter/jedi/issues/1744][jedi issue #1744]], [[https://github.com/davidhalter/jedi/issues/1745][#1745]], and [[https://github.com/davidhalter/jedi/issues/1746][#1746]]). Since the universal
|
||||||
functions are neither builtin methods nor data instances but a kind of "callable
|
functions are neither builtin methods nor data instances but a kind of "callable
|
||||||
instances", the [[https://docs.python.org/3/library/inspect.html][Python inspect]] module also fails to handle the universal
|
instances", the [[https://docs.python.org/3/library/inspect.html][Python inspect]] module also fails to handle the universal
|
||||||
functions properly.
|
functions properly.
|
||||||
|
|
||||||
Listing [[lst:make-pylsp-server-patch]] generates and listing
|
Listing [[lst:make-pylsp-server-patch]] generates the patch to make [[https://jedi.readthedocs.io/en/latest/][jedi]] import
|
||||||
[[lst:show-pylsp-server-patch]] shows the patch to make [[https://jedi.readthedocs.io/en/latest/][jedi]] import [[https://numpy.org/][numpy-1.23.3]] in
|
[[https://numpy.org/][numpy-1.23.4]] in order to obtain the necessary information to make
|
||||||
order to obtain the necessary information to make [[https://github.com/python-lsp/python-lsp-server][python-lsp-server]] handle
|
[[https://github.com/python-lsp/python-lsp-server][python-lsp-server]] handle universal functions.
|
||||||
universal functions.
|
|
||||||
|
|
||||||
#+caption[Make =pylsp-auto-import-modules.patch= listing]:
|
#+caption[Make =pylsp-auto-import-modules.patch= listing]:
|
||||||
#+caption: Make =pylsp-auto-import-modules.patch= listing.
|
#+caption: Make =pylsp-auto-import-modules.patch= listing.
|
||||||
@ -4422,12 +4421,6 @@ universal functions.
|
|||||||
git -C $HOME/VCS/python-lsp-server diff >pylsp-auto-import-modules.patch
|
git -C $HOME/VCS/python-lsp-server diff >pylsp-auto-import-modules.patch
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+attr_latex: :options breaklines
|
|
||||||
#+caption[Show =pylsp-auto-import-modules.patch=]:
|
|
||||||
#+caption: Show =pylsp-auto-import-modules.patch=.
|
|
||||||
#+name: lst:show-pylsp-server-patch
|
|
||||||
#+include: "pylsp-auto-import-modules.patch" src diff
|
|
||||||
|
|
||||||
*** [[https://jedi.readthedocs.io/en/latest/][Jedi]]
|
*** [[https://jedi.readthedocs.io/en/latest/][Jedi]]
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
:CUSTOM_ID: sec:jedi
|
:CUSTOM_ID: sec:jedi
|
||||||
|
@ -1,5 +1,17 @@
|
|||||||
|
diff --git a/CONFIGURATION.md b/CONFIGURATION.md
|
||||||
|
index 61d500b..4cff0c9 100644
|
||||||
|
--- a/CONFIGURATION.md
|
||||||
|
+++ b/CONFIGURATION.md
|
||||||
|
@@ -16,6 +16,7 @@ This server can be configured using the `workspace/didChangeConfiguration` metho
|
||||||
|
| `pylsp.plugins.flake8.indentSize` | `integer` | Set indentation spaces. | `null` |
|
||||||
|
| `pylsp.plugins.flake8.perFileIgnores` | `array` of `string` items | A pairing of filenames and violation codes that defines which violations to ignore in a particular file, for example: `["file_path.py:W305,W304"]`). | `[]` |
|
||||||
|
| `pylsp.plugins.flake8.select` | `array` of unique `string` items | List of errors and warnings to enable. | `null` |
|
||||||
|
+| `pylsp.plugins.jedi.auto_import_modules` | `array` of `string` items | List of module names for jedi.settings.auto_import_modules. | `["numpy"]` |
|
||||||
|
| `pylsp.plugins.jedi.extra_paths` | `array` of `string` items | Define extra paths for jedi.Script. | `[]` |
|
||||||
|
| `pylsp.plugins.jedi.env_vars` | `object` | Define environment variables for jedi.Script and Jedi.names. | `null` |
|
||||||
|
| `pylsp.plugins.jedi.environment` | `string` | Define environment for jedi.Script and Jedi.names. | `null` |
|
||||||
diff --git a/pylsp/config/schema.json b/pylsp/config/schema.json
|
diff --git a/pylsp/config/schema.json b/pylsp/config/schema.json
|
||||||
index bb82145..3c40d6a 100644
|
index ee27b63..d210d0d 100644
|
||||||
--- a/pylsp/config/schema.json
|
--- a/pylsp/config/schema.json
|
||||||
+++ b/pylsp/config/schema.json
|
+++ b/pylsp/config/schema.json
|
||||||
@@ -87,6 +87,14 @@
|
@@ -87,6 +87,14 @@
|
||||||
@ -8,7 +20,7 @@ index bb82145..3c40d6a 100644
|
|||||||
},
|
},
|
||||||
+ "pylsp.plugins.jedi.auto_import_modules": {
|
+ "pylsp.plugins.jedi.auto_import_modules": {
|
||||||
+ "type": "array",
|
+ "type": "array",
|
||||||
+ "default": ["numpy", "gi"],
|
+ "default": ["numpy"],
|
||||||
+ "items": {
|
+ "items": {
|
||||||
+ "type": "string"
|
+ "type": "string"
|
||||||
+ },
|
+ },
|
||||||
@ -18,14 +30,14 @@ index bb82145..3c40d6a 100644
|
|||||||
"type": "array",
|
"type": "array",
|
||||||
"default": [],
|
"default": [],
|
||||||
diff --git a/pylsp/workspace.py b/pylsp/workspace.py
|
diff --git a/pylsp/workspace.py b/pylsp/workspace.py
|
||||||
index bf312f6..4758b53 100644
|
index bf312f6..5e91221 100644
|
||||||
--- a/pylsp/workspace.py
|
--- a/pylsp/workspace.py
|
||||||
+++ b/pylsp/workspace.py
|
+++ b/pylsp/workspace.py
|
||||||
@@ -14,6 +14,8 @@ from . import lsp, uris, _utils
|
@@ -14,6 +14,8 @@ from . import lsp, uris, _utils
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
+DEFAULT_AUTO_IMPORT_MODULES = ["numpy", "gi"]
|
+DEFAULT_AUTO_IMPORT_MODULES = ["numpy"]
|
||||||
+
|
+
|
||||||
# TODO: this is not the best e.g. we capture numbers
|
# TODO: this is not the best e.g. we capture numbers
|
||||||
RE_START_WORD = re.compile('[A-Za-z_0-9]*$')
|
RE_START_WORD = re.compile('[A-Za-z_0-9]*$')
|
||||||
@ -39,3 +51,16 @@ index bf312f6..4758b53 100644
|
|||||||
environment_path = jedi_settings.get('environment')
|
environment_path = jedi_settings.get('environment')
|
||||||
extra_paths = jedi_settings.get('extra_paths') or []
|
extra_paths = jedi_settings.get('extra_paths') or []
|
||||||
env_vars = jedi_settings.get('env_vars')
|
env_vars = jedi_settings.get('env_vars')
|
||||||
|
diff --git a/pyproject.toml b/pyproject.toml
|
||||||
|
index 8607548..8cce90e 100644
|
||||||
|
--- a/pyproject.toml
|
||||||
|
+++ b/pyproject.toml
|
||||||
|
@@ -53,7 +53,7 @@ test = [
|
||||||
|
"pytest",
|
||||||
|
"pytest-cov",
|
||||||
|
"coverage",
|
||||||
|
- "numpy<1.23",
|
||||||
|
+ "numpy",
|
||||||
|
"pandas",
|
||||||
|
"matplotlib",
|
||||||
|
"pyqt5",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user