-
-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
/* … */
always split into multiple lines
#366
Comments
Other community support for hint prefixes can found floating around:
|
Note that alejandra currently does not handle these comments properly. See: kamadorueda/alejandra#366
nvim-treesitter also added support in nvim-treesitter/nvim-treesitter#3842 This format appears to be gaining traction and personally I'm a fan of it. Perhaps Alejandra could allow "short" comments to be kept inline? A simple definition of "short" might be the comment does not contain multiple words. Or alternatively perhaps a max char length? Some additional examples: mapping = {
"<CR>" = /* lua */ "cmp.mapping.confirm({ select = true })";
"C-y" = /* lua */ "cmp.mapping.confirm({ select = true })";
"<Tab>" = /* lua */ ''
function(fallback)
-- ...
end
'';
"<S-Tab>" = /* lua */ ''
function(fallback)
-- ...
end
'';
}; |
Would love support for this too. For now I'm working around this by using linewise comments instead: {
attribute =
# bash
''
echo "hello world"
'';
} It saves two whole lines compared to the way that inline comments are currently formatted, with a plus of better readability. But it still wastes two extra lines compared to the ideal format: {
attribute = /* bash */ ''
echo "hello world"
'';
} |
To make another case where avoiding the line break is useful, I have started to get in the habit of making block-comments that are togglable via a single line-comment, for example: {
/* <-- Toggling a # line comment at the beginning of this line toggles the whole block
services.xserver = {
enable = true;
layout = "us";
libinput.enable = true;
# Enable the KDE Desktop Environment.
displayManager.sddm.enable = true;
desktopManager.plasma5.enable = true;
};
# */
} Upon reformatting, Alejandra breaks the {
# /*
<-- Toggling a # line comment on this line toggles the whole block
services.xserver = {
enable = true;
layout = "us";
libinput.enable = true;
# Enable the KDE Desktop Environment.
displayManager.sddm.enable = true;
desktopManager.plasma5.enable = true;
};
#
*/
} I'm not sure if/how this would fit with the proposed "short comment" logic, but it's a really convenient way of quickly toggling on/off large code blocks which would be nice to support with the formatter. |
LnL7/vim-nix#28 proposes using inline comments as editor hints for highlighting foreign code blocks. But Alejandra doesn’t currently behave well with that. Here’s a before/after Alejandra excerpt from my experiment using that style:
This isn’t yet a settled convention, so raising it here for consideration as to whether supporting one-line
/* … */
in Alejandra is the way to go, or if there should be some other approach for handling foreign code blocks.The text was updated successfully, but these errors were encountered: