-
Notifications
You must be signed in to change notification settings - Fork 2
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
Proposal: "Include" directive #40
Comments
Initial thoughts: We could use syntax like The alternative is to use some other special symbol to signal a processor directive, like Also, consideration must be given to the behavior of
|
Honestly, I'm not quite sure what to think of this suggestion; sure, it might be convenient, however I see a lot of shortcomings here. You already mentioned storing the preprocessed code to a new file, perhaps with a fitting suffix. However, I can see that adding overhead during development: When I save the file and the preprocessor triggers, it has to scan the code for any such Then there's another issue regarding portability: Not all (in fact, only a handful) YAGPDB-users do use (Neo)vim to write their custom commands, and the vast majority uses VSCode instead. If we implement such one preprocessor for Neovim, any contributions to one such repository with headers and preprocessing will not work with VSCode and require manual intervention. As you also already said, we'd have to find a way of signalling our software to replace this with something else -- finding some sensible approach that is a) non-intrusive and feels natural to the YAGPDB-syntax is indeed quite hard, and I cannot think of anything that meets these criteria. I've been thinking however about utilising comments with a special syntax; similar to jo3-l/cc-minifier. Lastly, we would have to find a way of implementing this; I highly doubt Vim script is capable of this task, so we'd have to either use the Python- or Lua-API provided by Neovim, which would bring up the issue of portability yet again. Though surely convenient and I quite like the idea behind the original suggestion, this simply does not seem feasible to me, especially for a plugin that is rarely used. However, I am as always open to discuss this and find a common denominator, if we and the community wish to implement something along these lines. |
Those are all certainly good points. Especially in light of the difficulty of actually implementing the replacement feature, I agree that it's probably best to hold off for now. A point of clarification, though: I don't think the replacement operation would incur that much overhead, if we set our requirements properly. For example, if the |
Regarding setting requirements properly, I was thinking about it for a few hours yesterday. Personally, I'd like to limit one such header file to 3 000 characters max (this is both arbitrary and also a reference to old YAGPDB custom commands), plus any actual custom command code must be inside a The relative path is for sure worthwhile and should make it easy for us to implement. However, I can imagine that especially larger project repositories have some sort of "global" header, for example for having some sort of standard leading comment. Our benefit here is that no such thing exists in YAGPDB, so we're basically free to specify the format to our liking, within reason. Let me know what you think. |
Those are relevant suggestions, though I do have some mixed feelings about them. On the one hand, requiring a Regarding character limits, though, I do think we should (at least) add a warning if the final generated file is larger than the CC char limit. Also, we'd previously discussed a configurable limit on |
Being closer to the C philosophy does indeed make sense, and -- as you said -- it's fair to assume Vim users would be comfortable with this approach.
I agree, a warning shall (must) be given when the generated file exceeds the character limit, but I still strongly think we should impose some sort of limits on these header files. Even with 3 000 characters available it is quite easy to exceed the limit of |
Maybe another warning, based on header size? Not to be a broken record, but I do think warnings are generally preferable to hard limits here. |
Description
This feature is not related to a problem, but does draw inspiration from a suggestion made in the YAGPDB support server:
Suggestion ID 528415266577842196, made on 05/15/2022
Solution
While it doesn't make much sense to implement this in Yag itself, file substitution (á la
#include
) would be quite doable for an editor plugin.We would simply define our own "include" directive, and when the appropriate action is triggered, replace instances of the directive with the specified file. The resulting processed code would be saved to a new location (probably using the original filename, plus a suffix of some sort).
Code of Conduct
The text was updated successfully, but these errors were encountered: