Skip to content

Commit 7bc9670

Browse files
authored
Introduce LspPlugin API (#2739)
1 parent 1737936 commit 7bc9670

27 files changed

Lines changed: 1317 additions & 224 deletions

boot.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
from .plugin.api import AbstractPlugin
44
from .plugin.api import g_plugins
5-
from .plugin.api import register_plugin
5+
from .plugin.api import LspPlugin
6+
from .plugin.api import register_plugin_impl
67
from .plugin.code_actions import LspCodeActionsCommand
78
from .plugin.code_actions import LspRefactorCommand
89
from .plugin.code_actions import LspSourceActionCommand
@@ -180,15 +181,16 @@ def _get_final_subclasses(derived: list[type], results: list[type]) -> None:
180181

181182

182183
def _register_all_plugins() -> None:
183-
plugin_classes: list[type[AbstractPlugin]] = []
184+
plugin_classes: list[type[AbstractPlugin | LspPlugin]] = []
184185
_get_final_subclasses(AbstractPlugin.__subclasses__(), plugin_classes)
186+
_get_final_subclasses(LspPlugin.__subclasses__(), plugin_classes)
185187
for plugin_class in plugin_classes:
186188
try:
187-
if not plugin_class.name():
189+
if issubclass(plugin_class, AbstractPlugin) and not plugin_class.name():
188190
continue
189191
except NotImplementedError:
190192
continue
191-
register_plugin(plugin_class, notify_listener=False)
193+
register_plugin_impl(plugin_class, notify_listener=False)
192194

193195

194196
def _unregister_all_plugins() -> None:

docs/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ nav:
6161
- Keyboard Shortcuts: keyboard_shortcuts.md
6262
- Client Configuration: client_configuration.md
6363
- Troubleshooting: troubleshooting.md
64+
- Migration to LspPlugin: migrating_to_lsp_plugin.md
6465

6566
extra:
6667
social:

docs/src/client_configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Below is an example configuration for the [Phpactor](https://phpactor.readthedoc
3434
| initialization_options | options to send to the server at startup |
3535
| priority_selector | Used to prioritize a certain language server when choosing which one to query on views with multiple servers active. Certain LSP actions have to pick which server to query and this setting can be used to decide which one to pick based on the current scopes at the cursor location. For example when having both HTML and PHP servers running on a PHP file, this can be used to give priority to the HTML one in HTML blocks and to PHP one otherwise. That would be done by setting "priority_selector" to `text.html` for HTML server and `source.php` to PHP server.
3636
| diagnostics_mode | Set to `"workspace"` (default is `"all_files"`) to ignore diagnostics for files that are not within the project (window) folders. If project has no folders then this option has no effect and diagnostics are shown for all files. |
37+
| markdown_language_map | A mapping of markdown language identifiers to aliases and Sublime Text syntaxes, used for syntax-highlighting fenced code blocks in popups. Each key is a fenced-code-block language tag (e.g. `"js"`). Each value is a two-element array: the first element is an array of additional aliases, and the second is an array of Sublime Text syntaxes associated with that language (e.g. `["MyPackage/MySyntaxLanguage"]`) or `scope:BASE_SCOPE` selectors (e.g. `["scope:source.js"]`). See [mdpopups `sublime_user_lang_map`](https://facelessuser.github.io/sublime-markdown-popups/settings/#mdpopupssublime_user_lang_map) for the full format description. |
3738
| tcp_port | see instructions below |
3839
| experimental_capabilities | Turn on experimental capabilities of a language server. This is a dictionary and differs per language server |
3940
| disabled_capabilities | Disables specific capabilities of a language server. This is a dictionary with key being a capability key and being `true`. Refer to the `ServerCapabilities` structure in [LSP capabilities](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#initialize) to find capabilities that you might want to disable. Note that the value should be `true` rather than `false` for capabilites that you want to disable. For example: `"signatureHelpProvider": true` |

0 commit comments

Comments
 (0)