Skip to content
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

FR: yaml value suggestions #74

Closed
chrisgrieser opened this issue Jan 23, 2022 · 23 comments
Closed

FR: yaml value suggestions #74

chrisgrieser opened this issue Jan 23, 2022 · 23 comments
Assignees
Labels
enhancement New feature or request

Comments

@chrisgrieser
Copy link

similar to #48, but only more general: enable yaml-key-specific complements. For example, if I regularly use 3-4 cssclass yaml values; so it would be nice if the plugin could simply show me a suggester with those 4.

Having autocomplete in the yaml frontmatter is quite valuable, since it ensures consistent assignment of yaml values.

@chrisgrieser
Copy link
Author

like here is also a nice idea, too: https://github.com/SkepticMystic/codeblock-completer

@tadashi-aikawa
Copy link
Owner

Hi, @chrisgrieser . Sorry for the late reply.

I think it is a little ways away, but I want to try it after #73, #16, #48, etc. :)

@tadashi-aikawa tadashi-aikawa self-assigned this Jan 29, 2022
@tadashi-aikawa tadashi-aikawa added the enhancement New feature or request label Jan 29, 2022
@chrisgrieser
Copy link
Author

no worries, it's just something for far down the line. :)

tadashi-aikawa added a commit that referenced this issue Feb 14, 2022
@tadashi-aikawa
Copy link
Owner

Hi, @chrisgrieser
I have released v5.6.0.beta3 🚀

It is a prototype version, so I think there are some bugs and points to improve. I don't often use YAML front matter (except for aliases), so your feedback would be helpful for me.

Kind regards :)

@chrisgrieser
Copy link
Author

thanks 🥰

So I gave it a spin and I see some things that could be improved:

  1. the file name should be made optional again, in many cases, I don't care where the suggestion comes from.
  2. it should only suggest individual values, not a list of values
  3. after completion, it should add , so you can keep on adding more values.
  4. it should suggest items immediately, not just after n letters (n being the number of letters you have set in the settings.) Reason being that yaml values are often highly standardized, so as opposed to normal text, autosuggestion disturb less and should start earlier.
  5. right now, only the values are autosuggested. However, it could also make sense to suggest keys itself when you are on a new line in the yaml? So I don't have to type out thinks like cssclass all the time.

Screenshot 2022-02-14 10 28 13

@tadashi-aikawa
Copy link
Owner

@chrisgrieser
Thanks for your feedback!

  1. the file name should be made optional again, in many cases, I don't care where the suggestion comes from.

Exactly. In the case of Front matter, I think it is not necessary to show a description.

  1. it should only suggest individual values, not a list of values

I couldn't reproduce it. Don't you write a list not supported for YAML format? (ex: key: value1, value2, value3)

  1. after completion, it should add , so you can keep on adding more values.

I'll consider it an option because it doesn't need a comma to write another YAML format of an array.

ex.

tags:
  - one
  - two
  1. it should suggest items immediately, not just after n letters (n being the number of letters you have set in the settings.) Reason being that yaml values are often highly standardized, so as opposed to normal text, autosuggestion disturb less and should start earlier.

I agree perfectly 👍

  1. right now, only the values are autosuggested. However, it could also make sense to suggest keys itself when you are on a new line in the yaml? So I don't have to type out thinks like cssclass all the time.

That is so useful 😄 I want to implement it after v5.6.0 :)

@tadashi-aikawa
Copy link
Owner

tadashi-aikawa commented Feb 14, 2022

Released v5.6.0.beta4 🚀

Fixed 1 and 4 🎉

@chrisgrieser
Copy link
Author

it should only suggest individual values, not a list of values
I couldn't reproduce it. Don't you write a list not supported for YAML format? (ex: key: value1, value2, value3)

see the screenshot above – key: value1, value2, value3 is what I do. And it suggests to my value1, value2, value3 instead of value1

@tadashi-aikawa
Copy link
Owner

tadashi-aikawa commented Feb 14, 2022

@chrisgrieser
It seems not a valid sequence format as far as I know. If you know the format is correct, it would be great to let me know the referenced document :)

image

by http://yaml-online-parser.appspot.com/

image

by https://onlineyamltools.com/convert-yaml-to-json

@chrisgrieser
Copy link
Author

yeah, but Obsidian is more lenient and accepts those kind of yaml, though:
Screenshot 2022-02-14 12 52 52

@tadashi-aikawa
Copy link
Owner

Thanks!

Considering other than Obsidian, it shouldn't, but Various Complements is a plugin for Obsidian, so I'll support it 👍

@tadashi-aikawa
Copy link
Owner

  • tags and tag are both valid
  • aliases and alias are both valid

Ah.. That is why there is a particular API only for tags and aliases. I understood.

@tadashi-aikawa
Copy link
Owner

@chrisgrieser
Released v5.6.0.beta5 🚀

It would support all cases for Tag and Alias 👍

tag: aaa, bbb
tag: [aaa, bbb]
tag:
  - aaa
  - bbb

tags: aaa, bbb
tags: [aaa, bbb]
tags:
  - aaa
  - bbb

alias: aaa, bbb
alias: [aaa, bbb]
alias:
  - aaa
  - bbb

aliases: aaa, bbb
aliases: [aaa, bbb]
aliases:
  - aaa
  - bbb

@chrisgrieser
Copy link
Author

thanks 🤩

btw, it's not only tags and aliases, I just tested it, this "loose" format is also supported for any yaml key you choose, so it might make sense to implement it for everything?

@tadashi-aikawa
Copy link
Owner

Yes, I have found that parseFrontMatterStringArray seems to make us possible 👍 just a moment please.

@tadashi-aikawa
Copy link
Owner

tadashi-aikawa commented Feb 14, 2022

Released v5.6.0.beta6 🚀

By the way, I'm worried about the performance a little. It is fine in my environment (indexing time is less than 10ms), but isn't it fine with much front matter in the vault?

image

It only indexes after changing an active file, so I think it is no problem if it can suppress less than 100ms 😇

@chrisgrieser
Copy link
Author

Well, I tried it out a bit, but I haven't noticed big problems yet regarding performance yet.

it works better now, but the non-tag-yaml keys suggest non-yaml values
Screenshot 2022-02-14 14 18 00


this leaves pretty much only 3 & 5, otherwise it's perfect already :)


also, another thing to think about is how would interact with other plugins that also autosuggest tags, like this one.

@tadashi-aikawa
Copy link
Owner

Well, I tried it out a bit, but I haven't noticed big problems yet regarding performance yet.

Thanks!

it works better now, but the non-tag-yaml keys suggest non-yaml values

It is what has been on my mind for some time. Suggesting other completion words might be noisy, but it also might be useful. It is possible not to suggest words except for corresponding key-values. I'll give it a try :)

also, another thing to think about is how would interact with other plugins that also autosuggest tags, like this one.

It would be hard to avoid conflict with other plugins that don't need to type a prefix word. Otherwise, I wouldn't have developed for this issue. Alternatively, I recommended using excellent other plugins together. 😃

@tadashi-aikawa
Copy link
Owner

Released v5.6.0.beta7 🚀

@chrisgrieser
Copy link
Author

works, well, haven't noticed anything for now :)

@tadashi-aikawa
Copy link
Owner

after completion, it should add , so you can keep on adding more values.

Added a Insert comma after completion option 👍

2022-02-19

@tadashi-aikawa
Copy link
Owner

Before the v5.6.0 official release, I have implemented the last improvement, which suggests property values even if we don't type anything yet.

It is helpful to see selections without filtering the first character. Primarily, In the case that there are not too many items.

2022-02-19

We don't need to worry about the performance because it merely suggest s items equals to Max number of suggestions.

tadashi-aikawa added a commit that referenced this issue Feb 19, 2022
…fter completion only if it doesn't input any word (#74)
@tadashi-aikawa
Copy link
Owner

I have released v5.6.0 🚀

Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

2 participants