Skip to content

Commit 127c59b

Browse files
committed
Keep plugin id of cabal-fmt in sync with default config id
Add documentation to note that these values are to be kept in sync
1 parent e3a7df6 commit 127c59b

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

hls-plugin-api/src/Ide/Types.hs

+14-13
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ instance Default Config where
200200
-- , formattingProvider = "floskell"
201201
-- , formattingProvider = "stylish-haskell"
202202
, cabalFormattingProvider = "cabal-fmt"
203+
-- this string value needs to kept in sync with the value provided in HlsPlugins
203204
, maxCompletions = 40
204205
, plugins = mempty
205206
}
@@ -344,38 +345,38 @@ defaultConfigDescriptor =
344345
class HasTracing (MessageParams m) => PluginMethod (k :: MethodType) (m :: Method FromClient k) where
345346

346347
-- | Parse the configuration to check if this plugin is enabled.
347-
-- Perform sanity checks on the message to see whether plugin is enabled
348+
-- Perform sanity checks on the message to see whether the plugin is enabled
348349
-- for this message in particular.
349-
-- If a plugin is not enabled, its handlers, commands, etc... will not be
350+
-- If a plugin is not enabled, its handlers, commands, etc. will not be
350351
-- run for the given message.
351352
--
352-
-- Semantically, this method described whether a Plugin is enabled configuration wise
353+
-- Semantically, this method describes whether a plugin is enabled configuration wise
353354
-- and is allowed to respond to the message. This might depend on the URI that is
354-
-- associated to the Message Parameters, but doesn't have to. There are requests
355-
-- with no associated URI that, consequentially, can't inspect the URI.
355+
-- associated to the Message Parameters. There are requests
356+
-- with no associated URI that, consequentially, cannot inspect the URI.
356357
--
357-
-- Common reason why a plugin might not be allowed to respond although it is enabled:
358-
-- * Plugin can not handle requests associated to the specific URI
358+
-- A common reason why a plugin might not be allowed to respond although it is enabled:
359+
-- * The plugin cannot handle requests associated with the specific URI
359360
-- * Since the implementation of [cabal plugins](https://github.com/haskell/haskell-language-server/issues/2940)
360-
-- HLS knows plugins specific for Haskell and specific for [Cabal file descriptions](https://cabal.readthedocs.io/en/3.6/cabal-package.html)
361+
-- HLS knows plugins specific to Haskell and specific to [Cabal file descriptions](https://cabal.readthedocs.io/en/3.6/cabal-package.html)
361362
--
362363
-- Strictly speaking, we are conflating two concepts here:
363-
-- * Dynamically enabled (e.g. enabled on a per-message basis)
364+
-- * Dynamically enabled (e.g. on a per-message basis)
364365
-- * Statically enabled (e.g. by configuration in the lsp-client)
365366
-- * Strictly speaking, this might also change dynamically
366367
--
367-
-- But there is no use to split it up currently into two different methods for now.
368+
-- But there is no use to split it up into two different methods for now.
368369
pluginEnabled
369370
:: SMethod m
370371
-- ^ Method type.
371372
-> MessageParams m
372373
-- ^ Whether a plugin is enabled might depend on the message parameters
373-
-- eg 'pluginFileType' specifies what file extension a plugin is allowed to handle
374+
-- e.g. 'pluginFileType' specifies which file extensions a plugin is allowed to handle
374375
-> PluginDescriptor c
375-
-- ^ Contains meta information such as PluginId and what file types this
376+
-- ^ Contains meta information such as PluginId and which file types this
376377
-- plugin is able to handle.
377378
-> Config
378-
-- ^ Generic config description, expected to hold 'PluginConfig' configuration
379+
-- ^ Generic config description, expected to contain 'PluginConfig' configuration
379380
-- for this plugin
380381
-> Bool
381382
-- ^ Is this plugin enabled and allowed to respond to the given request

src/HlsPlugins.hs

+3-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,9 @@ idePlugins recorder = pluginDescToIdePlugins allPlugins
161161
let pId = "fourmolu" in Fourmolu.descriptor (pluginRecorder pId) pId:
162162
#endif
163163
#if hls_cabalfmt
164-
let pId = "cabalfmt" in CabalFmt.descriptor (pluginRecorder pId) pId:
164+
-- this pId needs to be kept in sync with the hardcoded
165+
-- cabalFormattingProvider in the Default Config
166+
let pId = "cabal-fmt" in CabalFmt.descriptor (pluginRecorder pId) pId:
165167
#endif
166168
#if hls_tactic
167169
let pId = "tactics" in Tactic.descriptor (pluginRecorder pId) pId:

0 commit comments

Comments
 (0)