Repository: python-lsp/python-lsp-black (language: python)

Issue:
Configuration key and plugin name mismatch
This plugin is called `pylsp_black` and it's also the name that `pylsp` uses to load it:

```
INFO - pylsp.config.config - Loaded pylsp plugin pylsp_black from <module 'pylsp_black.plugin' from '/Users/rafal/Library/Caches/Sublime Text/Package Storage/LSP-pylsp/lib/python3.10/site-packages/pylsp_black/plugin.py'>
```

The settings it provides [use a `black` key](https://github.com/python-lsp/python-lsp-black/blob/master/pylsp_black/plugin.py#LL49C14-L49C19) though. This is problematic because that means that the `pylsp.plugins.black.enabled` key doesn't work and `pylsp` [expects](https://github.com/python-lsp/python-lsp-server/blob/b24ffd3939e35b3db8e45d06bf51b177c456574b/pylsp/config/config.py#L172-L175) `pylsp.plugins.pylsp_black.enabled` instead.

All configuration keys other than `enabled` work as expected because `pylsp` uses different code path for reading those.


Discussion / hints:

Fix patch:
diff --git a/setup.cfg b/setup.cfg
index 47510d5..e0f5dc9 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -22,7 +22,7 @@ install_requires = python-lsp-server>=1.4.0; black>=22.3.0; toml
 python_requires = >= 3.7
 
 [options.entry_points]
-pylsp = pylsp_black = pylsp_black.plugin
+pylsp = black = pylsp_black.plugin
 
 [options.extras_require]
 # add any types-* packages to .pre-commit-config.yaml mypy additional_dependencies


Test patch:
diff --git a/tests/test_plugin.py b/tests/test_plugin.py
index 2d60070..d9ef6db 100644
--- a/tests/test_plugin.py
+++ b/tests/test_plugin.py
@@ -19,6 +19,7 @@
     load_config,
     pylsp_format_document,
     pylsp_format_range,
+    pylsp_settings,
 )
 
 here = Path(__file__).parent
@@ -273,7 +274,7 @@ def test_load_config_defaults(config):
 
 def test_entry_point():
     distribution = pkg_resources.get_distribution("python-lsp-black")
-    entry_point = distribution.get_entry_info("pylsp", "pylsp_black")
+    entry_point = distribution.get_entry_info("pylsp", "black")
 
     assert entry_point is not None
 
@@ -327,3 +328,13 @@ def test_cache_config(config, unformatted_document):
     for _ in range(5):
         pylsp_format_document(config, unformatted_document)
     assert _load_config.cache_info().hits == 4
+
+
+def test_pylsp_settings(config):
+    plugins = dict(config.plugin_manager.list_name_plugin())
+    assert "black" in plugins
+    assert plugins["black"] not in config.disabled_plugins
+    config.update({"plugins": {"black": {"enabled": False}}})
+    assert plugins["black"] in config.disabled_plugins
+    config.update(pylsp_settings())
+    assert plugins["black"] not in config.disabled_plugins