-
Notifications
You must be signed in to change notification settings - Fork 1
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
Customizable formatters #1
Comments
Hello @Gelio, is this still being worked on? I really need a way to auto-complete dates in a specific format for me since im using neovim with obsidian. I may be able to contribute since this seems entry level enough for me to learn when i get a chance |
Hey hey, thanks for reaching out! I didn't plan on working on it since the existing features cover my use-cases (including Obsidian, which I am also using). Feel free to create a PR if you manage to get it working. I can also fill in some bits that you are unsure about. Don't hesitate to ask questions. By the way, what date format are you looking for when working with Obsidian? I'm asking since I'm curious and maybe I am missing some cool plugin 😄 |
Sure, once i put some time together this week or the next, ill see if i can put in the forrmatter. Thanks for being so responsive! Im not using any cool plugin. If anything im trying to keep it as the bare minimum since Im trying to use nvim to write those daily notes, already modified it to hide all the dataview stuff. Im just using |
I see. What are you looking to get from custom formatters in I guess you could configure the day formatter to also output the I am asking to understand the problem you are having and to also understand whether adding custom formatters will help you solve it. If you could add an example Markdown file and places where you expect these completions (whether they are inside I wouldn't want to you spend time contributing a feature that ends up not solving your problem 🙂 |
Yes, the dddd part for sure. Im unsure how the timestamp is served by cmp-natdat, but if it follows ISO 8601, i should just as easily be able to format a time into the YYYY-ww format, right? This format is not going to be super helpful to me anyway, was just trying to get my feet wet into lua plugins for neovim, and this seems like a good opportunity thats not very overwhelming. Can you give me an example for the markdown solution? Thanks |
Yeah, you could change it so that any date will turn to Besides, if you wanted to have All in all, I am not sure implementing this feature (#1) will solve your problems, but I don't mind you trying anyway 😄
I'm not following what you are asking for here 😅 |
Hey, thanks again for being so helpful. Your lua-snip suggestion makes a lot more sense. I didn't think about the snippet engine. And you are absolutely right about the formatter that once its set, you need to reload it. Dont worry about the followup, you answered it with luasnip. Thank you very much sir! |
Let's refactor the way formatting is done to allow users to plug in their own formatters if they do not like the default formatting.
This would involve:
Creating a
natdat.Formatter
type with methods for formatting different structsCreating 2 formatters:
ISOFormatter
with methods from existingformat_iso
LabelFormatter
with methods from existingformat_original
Replacing the
format_iso
andformat_original
methods on structures with a singleformat fun(formatter: natdat.Formatter): string
. Each such method would call a correspondingformatter
method.Accepting a
formatter
for theinsertText
in thecmp_natdat
source. By default, it would be theISOFormatter
The text was updated successfully, but these errors were encountered: