Replies: 3 comments 14 replies
-
|
I'll give my opinions on your suggested standards first:
I disagree with this one, it should be 3-dash all the time, I checked several repos on LuaCATS and none
I'm fine with this one. My research suggests this is mostly how it's done.
Agree. Given there's no easy quick-win like a 'fire-and-forget' formatter The lua-language-server repo has a tools folder, which has some scripts On the formatting note, I think we should just use whatever stylua defaults are and be done with it 🤷 |
Beta Was this translation helpful? Give feedback.
-
I am yet unsure about the behaviour of aliases with descriptions. Take, for instance,
Very well then. We should then rework the existing ones and apply this for the future ones. If using Bash, I have this script that must be called while in the root of the repo (USAGE INCLUDED)#!/usr/bin/env bash
# Print to `STDERR`, separate each arg with newline
error() {
local TXT=("$@")
printf "%s\n" "${TXT[@]}" >&2
return 0
}
# Check whether a console command (or multiple) exists
# Returns 0 if all commands are found
# Returns 1 if at least one command is not found
# Returns 127 if no arguments were given
_cmd() {
[[ $# -eq 0 ]] && return 127
local EC=0
while [[ $# -gt 0 ]]; do
if ! command -v "$1" &> /dev/null; then
EC=1
break
fi
shift
done
return "$EC"
}
# Terminate the script, optionally set the exit code and abort message
die() {
local EC=1
if [[ $# -ge 1 ]] && [[ $1 =~ ^(0|-?[1-9][0-9]*)$ ]]; then
EC=$1
shift
fi
if [[ $# -ge 1 ]]; then
local TXT=("$@")
if [[ $EC -eq 0 ]]; then
printf "%s\n" "${TXT[@]}"
else
error "${TXT[@]}"
fi
fi
exit "$EC"
}
! _cmd 'find' && die 127 "\`find\` is not in PATH."
[[ $# -eq 0 ]] && die 127 "No arguments were given. Aborting"
EC=0
while [[ $# -gt 0 ]]; do
if ! [[ "$1" =~ ^s/.+/.*/g?.*$ ]] ; then
error "Pattern \`$1\` not valid. Skipping..."
EC=1
shift
continue
fi
REGEX="$1"
printf "\n%s\n" "Applying regex ${REGEX}:"
for F in $(find . -type f -regex '.*\.lua$' | cut -d '/' -f2-); do
echo -e " ==> ${F}"
if ! sed -i "${REGEX}" "$F"; then
error "Unable to replace contents of file \`$F\`. Skipping file"
EC=1
continue
fi
done
shift
done
die "$EC"USAGE: $ ./script_name 's/^--\s/---/g'
StyLua barely benefits us since they're mostly annotations. It is there for our workflow to avoid anyone pushing badly formatted files. If we were to transition to Definition Files, only some line_endings = "Unix"
collapse_simple_statement = "Always"Tangent: welp, gotta change Lua version in our |
Beta Was this translation helpful? Give feedback.
-
Addendum@craigmac Also, if you want to discuss about this in more detail and more fluidly, you can send me an email to get in touch, if you're so inclined. |
Beta Was this translation helpful? Give feedback.





Uh oh!
There was an error while loading. Please reload this page.
-
Description
I am concerned about how we will do our field descriptions, so I'd like every maintainer / collaborator that's interested
to join in on this discussion (@craigmac && @TheLeoP , I'm pinging you (sorry) if you have any feedback).
My Suggested Standard
---@comments should go with three dashes, while any other description should go with only two dashesFind and Replace operations (
:%s, Vim users will get it) might benefit from this by differentiating and avoiding mistakes.Also it makes description comments much easier to spot for manual searching.
No inline
---@fielddescriptionsThis is because LuaLS supports Markdown comments1.
Having inline comments not only makes the comments harder to navigate through,
it also limits what we can write (say, lists/tables/sections/etc.)
In descriptions, any identifier, type and/or value should be enclosed like in Markdown
This is because it lets users spot important info much faster when hovering.
leader_key,1.0,"FOO"- SuggestedFootnotes
Annotation Formatting ↩
Beta Was this translation helpful? Give feedback.
All reactions