You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing module options, one ends up using various lib functions, such that using with lib; becomes tempting. Since large-scale with usage is generally considered bad practice, people sometimes opt for an alternative like this:
Since it's annoying to type this out by hand, it would be really nice if nil offered a code action to turn a with into this kind of let-inherit-in construct. It won't be perfect in the case of nested withs, but I think it'll still be worth it for the 80% case.
On top of that, nil could offer a code action similar to the "add to imports" of LSPs in other languages, to easily add new things to the construct. On every unknown symbol, provide code actions such as Inherit this symbol from lib, Inherit this symbol from lib.types for every inherit (from) expression in scope:
{lib, ... }:
letinherit(lib)mkOption;inherit(lib.types)attrsOf;in{options.example=mkOption{type=attrsOfstr;# <- unknown symbol "str"default={};# --[ Inherit "str" from lib ]};# ->[ Inherit "str" from lib.types ]}
The text was updated successfully, but these errors were encountered:
When writing module options, one ends up using various
lib
functions, such that usingwith lib;
becomes tempting. Since large-scalewith
usage is generally considered bad practice, people sometimes opt for an alternative like this:Since it's annoying to type this out by hand, it would be really nice if nil offered a code action to turn a
with
into this kind oflet-inherit-in
construct. It won't be perfect in the case of nestedwith
s, but I think it'll still be worth it for the 80% case.On top of that, nil could offer a code action similar to the "add to imports" of LSPs in other languages, to easily add new things to the construct. On every unknown symbol, provide code actions such as
Inherit this symbol from lib
,Inherit this symbol from lib.types
for everyinherit (from)
expression in scope:The text was updated successfully, but these errors were encountered: