-
-
Notifications
You must be signed in to change notification settings - Fork 245
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
[feature] implement condition objects #612
[feature] implement condition objects #612
Conversation
Nice, I think that's it, not missing anything 👍 |
Lua 5.4 reference states that for
The for luajit more relevant Lua 5.1 reference contains no such statement (lua5.2 states In my tests this also holds. Lua seems to be doing something like In effect we cannot use
Nothing seems to be really fitting for the |
Should we add a composite test of multiple operators (including parentheses)? And if so any suggestions what expression might be interesting? |
9e5af54
to
70b1cfd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also in the spec, when you require stuff from luasnip.extras.expand_conditions
, the local var is currently always called cond
, I think it'd be more readable to have:
mkcond
when importingmake_condition
conds
for the moduleluasnip.extras.expand_conditions
Oh wow, that's unfortunate :/
Ah, One important fact:
Would be a bit nicer if all were in one common directory, so |
Ah tests, right: One fun way to test them would be running the same expression for all true/false combinations of their variables, and comparing that to the expected results (if it gets too complex, don't do it though :D) |
That's what I'm currently doing for the single operators.
Hm then I'll have to think of an expression. Well just thought of composite ones and there is work to do (currently these opterators simply return functions -> e.g, |
I agree. But I'm not sure as well whether not implement |
I'd be in favor of this. Whether we do this or not is your call though. |
Hah, Perfect :D
Ohh wow, yeah completely missed that as well 🤦
Only downside I can see is confusion as to what
Yeah let's do it backwards-compatibly, re-export |
Done.
What name exactly are you not happy with, |
Oh, just the |
Hm, I've got no really good idea as well. |
Okay, I think this is actually it, as far as functionality is concerned :D |
So just to summarize what is to be done until the merge:
(just summarizing as I can't do it right now (will be tomorrow), and we don't forget something) |
|
13801de
to
9b473f2
Compare
Ah, also: would you include a deprecation-notice for |
Phu I know no way how to cleanly split up the commit afterwards (would be interested though if you know one). So I'll just add the note in the commit message. |
Just the commit message 👍 Concerning the split yeeeah, that would be a bit involved, I think
But that's honestly too much work for the tiny benefit of having the commits techincally more "pure" (really a technicality, they're all merged at once anyway) |
… tests Works by - providing a factory `make_condition` which wraps functions as condition objects - providing two modules `conditions.show` and `condition.expand` which contain a collection of common conditions already wrapped as condition objects Weird might be the decision to use `%` as `==`-operator. This way chosen because we can`t use `__eq` as this automatically converts the return value to a boolean (we need to return condition objects). So we decided to use something which make ones head scratch and look it up in the docs (or simply don't use it) Note: one still can continue to use the `expand_conditions` module (just rediects to the `conditions/expand` module) for backwards compatibility. This is deprecated though.
this is fast enough due to luas behaviour of interning strings (-> simple check if pointers are equal)
014ce2c
to
9867a30
Compare
Is this what you had in mind? |
Yup, that's it 👍👍 |
It seems you haven't updated the default config file LuaSnip/lua/luasnip/config.lua Line 139 in aa7acef
|
Oh yes. Didn't thought of this file. Just noticed that the tests also still use the now deprecated module |
I think that's okay, I don't dislike having those as security that the functions can still be accessed via the deprecated way. About config.. we should change that some time, but there's no hurry |
Refer to #600 for most details. As it turned out that memoization is pretty hard to achive (moreover the invalidation) and we're not sure if it is worth it, we decided to do the basic condition objects (and ->
*
, or ->+
) in a separate PR.TODOs:
extras/conditions/
/ split into_expand
/_show
and_objects
Anything I'm missing?