-
-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: add fallback if no paths are currently loaded #502
Conversation
Hey, thank you for participating, always happy to see some PRs from new ppl :) Creating new snippet-files via One downside I can see with this implementation is that it is not possible to add a personal snippet-file if there already is one for this filetype, provided by some collection. What do you think of, instead of For creating a new file, one could check the passed paths, if there is no item from the personal snippet-collection, an item for creating that file can be returned, maybe even with a hint that this selection creates a new file. |
How does this look? One thing I would say to note is that line 58 in loaders/init.lua will result in an error if the user-provided function does not return a table (e.g. it returns nil). This could be changed by adding |
BTW, this is an example of how I'm using it for reference: vim.api.nvim_create_user_command("LuaSnipEdit", function()
require("luasnip.loaders").edit_snippet_files {
extend = function(ft, paths)
if #paths == 0 then
return {
{ "$CONFIG/" .. ft .. ".snippets",
string.format("%s/%s.snippets", pc_path, ft) }
}
end
return {}
end
}
end, {}) |
Looks great, I've no complaints 👍
It's okay, as long as the doc specifies that |
Sounds good. I won't be able to get to this for a while (probably at least a week and a half), just so you're aware why there isn't any progress. |
Take your time 👍 |
Hey, will you have time to finish this feature in the near future? |
It's still my intention to get to it eventually, but I'm not sure when. I was on vacation in August, and life's been busy since getting back. TBH I haven't turned my workstation computer on since I got back. So yes, but I'm not sure I can give you a timeline. I won't be offended if you just take over now, but I'm still willing to get to it eventually if you don't. Completely up to you. |
Ahh, alright :D |
Updated docs, added assert for |
Ah nice 👍 |
How's this? |
Very nice, great work 👍 |
(oh, and maybe rebase, that would be nice :D) |
Lol, I don't actually know how to do that...I'm still learning how to use git properly. I will google it and get back with you. Or you're welcome to tell me how to do it too, that way I know for sure I'm doing the right thing. Up to you. |
I'm always squashing via Regarding the rebase on the master branch, I'd recommend to read on that (but from a users perspective it's not that different from a merge Important: |
(I'd do that stuff myself, but if I rebase, the commits would seem to be made by me, not you) |
Auto generate docs feat: extend instead of fallback Auto generate docs fix: return empty table in default extend function otherwise, if user doesn't specify an extend function, the default returns nil, and we get an error when we try to loop through the result. Format with stylua Update documentation. fix: assert type of exteded is table fix: various problems mentioned by @L3MON4D3 See: L3MON4D3#502 (review) Auto generate docs Format with stylua Auto generate docs Format with stylua
Ok, finally got around to this. Sorry for the wait (again 👀). Did I do everything right? Is there anything else you need before merging? |
Oh, I think something went wrong, theres some difference between this branch and master 250 commits ago, which should not be the case. |
I think that the merge commit is breaking the history, it will be cleaner to remake the branch starting from the current master and cherry-pick the commit with the wanted changes only. |
1c92701
to
20cb1c7
Compare
That did it 👍 |
Looks good to me 👍 |
Also sorry about this. Glad you figured it out ;-). |
Wonderful! |
Awesome! Sorry again for the long waiting periods and for the noobishness lol. Thanks for bearing with me...this was the first major project I've contributed to, and it was a great first experience. I learned a lot. Thanks again! |
Oh wow, thank you, that's great to hear :D |
This PR adds a fallback if no files are found in the current cache. This allows configs like the following:
Pretty minor change, should be self explanatory - basically it calls the fallback function, passing in the chosen filetype and the edit function. Main use case is to add file for current filetype if it does not already exist, but could be used for other things as well.
I made this because there was no easy way to tell if a file already exists and add it if it doesn't (at least not that I could tell). If I'm mistaken about this, I'd be interested in what the current preferred method is for this.
If I need to add docs or anything, just let me know!