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
Hi, I'm using nix and hence I write commands like this very often: nix <command> <some-flake>#<output>. The issue here is the # which gets interpreted as a comment in nu.
Is it possible to turn off this behavior or somehow make it such that the comment syntax is indeed \s# like in other shells?
putting everything in " is a huge PITA.
Requiring the space before end of line comments in the lexer would certainly be a breaking change for some people that have put (doc)comments directly after the documented item.
Personally having the space is pleasant style to me, so I wouldn't oppose making that change.
I don't know if we have any technical hurdles to making that change.
The only nushell design goal that might be a bit at odds with it is our desire to be less sensitive to whitespace mistakes as bash (looking at you test[[ -w tf ]] syntax) and everything that looks ok whitespace wise should also be valid nu code.
Mmmh, i kinda expected that this was going to be the answer. Consider that this is quite limiting to nix users… idk how the plugin system works, yet, but is it perhaps possible to add one that allows # to be used like this?
We are pre-1.0, so I would say we make this change, but we shouldn't add a setting that mucks with how the parser behaves. Code snippets should generally work independent of your config. The config should be there to improve your interactive experience or deal with specific behavior of your system.
Activity
sholderbach commentedon Feb 20, 2023
Duplicate of #6335
Requiring the space before end of line comments in the lexer would certainly be a breaking change for some people that have put (doc)comments directly after the documented item.
Personally having the space is pleasant style to me, so I wouldn't oppose making that change.
I don't know if we have any technical hurdles to making that change.
The only nushell design goal that might be a bit at odds with it is our desire to be less sensitive to whitespace mistakes as bash (looking at you
test[[ -w tf ]]syntax) and everything that looks ok whitespace wise should also be valid nu code.MangoIV commentedon Feb 20, 2023
Mmmh, i kinda expected that this was going to be the answer. Consider that this is quite limiting to nix users… idk how the plugin system works, yet, but is it perhaps possible to add one that allows # to be used like this?
sholderbach commentedon Feb 20, 2023
Plugins can only contribute commands at the moment and do not positively interact with the parser logic so that is a no.
I think the answer to this problem is to change the lexer/parser and see what the blast radius of the change would be.
MangoIV commentedon Feb 20, 2023
Perhaps it can be added as a setting? Are there already settings that somehow interact with the parser?
sholderbach commentedon Feb 20, 2023
We are pre-1.0, so I would say we make this change, but we shouldn't add a setting that mucks with how the parser behaves. Code snippets should generally work independent of your config. The config should be there to improve your interactive experience or deal with specific behavior of your system.
MangoIV commentedon Feb 20, 2023
mmmh, so the change seems to be rather simple (deleting one line). It now works as I'd expect it to.
MangoIV commentedon Feb 20, 2023
it seems to me as this is behavior is not tested for as all tests still pass after adding this change.
MangoIV commentedon Feb 20, 2023
This is the commit that fixes the behaviour: 4d5317d
fix: fix lexing of comments, such that a#b becomes a coherent Item (#…