Skip to content

[plugin][refine-import] add configuration allowing refining into Internal namespace #2521

Open
@Anton-Latukha

Description

@Anton-Latukha

Feature request

Currently, the plugin requires people to manually refine imports if user wants to depend on Internal uncontrolled API.

#1832 (comment)

Solution

It should not be too hard to add the option into the plugin:
An example of Properties in type lenses plugin:

descriptor :: PluginId -> PluginDescriptor IdeState
descriptor plId =
(defaultPluginDescriptor plId)
{ pluginHandlers = mkPluginHandler STextDocumentCodeLens codeLensProvider
, pluginCommands = [PluginCommand (CommandId typeLensCommandId) "adds a signature" commandHandler]
, pluginRules = rules
, pluginConfigDescriptor = defaultConfigDescriptor {configCustomConfig = mkCustomConfig properties}
}
properties :: Properties '[ 'PropertyKey "mode" ('TEnum Mode)]
properties = emptyProperties
& defineEnumProperty #mode "Control how type lenses are shown"
[ (Always, "Always displays type lenses of global bindings")
, (Exported, "Only display type lenses of exported global bindings")
, (Diagnostics, "Follows error messages produced by GHC about missing signatures")
] Always
codeLensProvider ::
IdeState ->
PluginId ->
CodeLensParams ->
LSP.LspM Config (Either ResponseError (List CodeLens))
codeLensProvider ideState pId CodeLensParams{_textDocument = TextDocumentIdentifier uri} = do
mode <- usePropertyLsp #mode pId properties

Alternatives solution

The current design can be seen as a good design, as it encourages best practices & discourages the use of uncontrolled Internal API: http://nikita-volkov.github.io/internal-convention-is-a-mistake.

But, still, people may have strong reasons & requirements to be able to refine into Internal modules when they need.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions