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

✨feat: .selene.toml and selene.toml are now detected by order of priority #591

Open
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

Zeioth
Copy link

@Zeioth Zeioth commented Mar 10, 2024

This PR:

  • add 20 lines of code, but it keep all the original checkings.
  • I've tried it to look as similar to the original code as possible.
  • It should be obvious enough.

The feature has been tested on neovim + none-ls with:

  • No file.
  • .selene.toml
  • selene.toml
  • .selene.toml + wrong syntax
  • selene.toml + wrong syntax

Example of bad syntax
screenshot_2024-03-10_04-17-20_778230898

Example of file detected OK
screenshot_2024-03-10_04-18-01_912823820

Example of no config file
screenshot_2024-03-10_04-19-59_927521326

@Zeioth
Copy link
Author

Zeioth commented Mar 10, 2024

Also it closes #469

@Zeioth Zeioth changed the title ✨feat: selene.toml and .selene.toml are not detected by order of priority ✨feat: selene.toml and .selene.toml are now detected by order of priority Mar 10, 2024
Copy link
Collaborator

@chriscerie chriscerie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need changelog + docs.

selene/src/main.rs Outdated Show resolved Hide resolved
selene/src/main.rs Outdated Show resolved Hide resolved
selene/src/main.rs Outdated Show resolved Hide resolved
selene/src/main.rs Outdated Show resolved Hide resolved
selene/src/main.rs Outdated Show resolved Hide resolved
selene/src/main.rs Outdated Show resolved Hide resolved
@Zeioth
Copy link
Author

Zeioth commented Mar 11, 2024

@chriscerie I'm gonna try but this is my first contribution to a rust project and I'm not a expert in the language so I feeI might cause more noise than it's worth trying to apply the feedback.

If you want to co-author please go ahead.

@Zeioth Zeioth changed the title ✨feat: selene.toml and .selene.toml are now detected by order of priority ✨feat: .selene.toml and selene.toml are now detected by order of priority Mar 13, 2024
selene/src/main.rs Outdated Show resolved Hide resolved
@Zeioth
Copy link
Author

Zeioth commented Mar 18, 2024

Need changelog + docs.

Changelog: https://github.com/Zeioth/selene/blob/dot-selene-toml/CHANGELOG.md
Docs: Zeioth@e5fd4f0

More info

In the docs, I've just replaced every mention to selene.toml by .selene.toml since now .selene.toml has priority over selene.toml.

Only in src/usage/configuration we mention that we also accept selene.toml to avoid duplication.

@Zeioth
Copy link
Author

Zeioth commented Mar 18, 2024

The PR should be ready merge it. Please tell me if you would like some other changes.

Hopefully we can ship it relatively soon.

@chriscerie
Copy link
Collaborator

Thanks for working on this! Unfortunately I've closed the parent issue for now: #469 (comment)

This pr will still be very helpful if the issue gets reopened in the future. If that happens, this pr will also need to update the vscode extension with the new config resolution.

@chriscerie chriscerie closed this Mar 23, 2024
@chriscerie chriscerie reopened this Mar 26, 2024
@@ -16,7 +16,7 @@ FLAGS:

OPTIONS:
--color <color> [default: auto] [possible values: Always, Auto, Never]
--config <config> A toml file to configure the behavior of selene [default: selene.toml]
--config <config> A toml file to configure the behavior of selene [default: .selene.toml]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't technically accurate because the default is both selene.toml and .selene.toml.

Copy link
Author

@Zeioth Zeioth Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default is .selene.toml because it has precedence over selene.toml,
The only place where selene.toml is mentioned as a possible alternative is docs/src/usagi/configuration to avoid duplicity that might make the docs harder to understand.

If you want to have a different string there, please tell me exactly, or edit the PR.

selene/src/main.rs Outdated Show resolved Hide resolved
selene/src/main.rs Outdated Show resolved Hide resolved
selene/src/main.rs Outdated Show resolved Hide resolved
selene/src/main.rs Outdated Show resolved Hide resolved
selene/src/main.rs Outdated Show resolved Hide resolved
selene/src/main.rs Outdated Show resolved Hide resolved
selene/src/main.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@chriscerie chriscerie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also need relevant changes to vscode extension.

Zeioth and others added 3 commits March 26, 2024 18:16
Co-authored-by: Chris Chang <51393127+chriscerie@users.noreply.github.com>
Co-authored-by: Chris Chang <51393127+chriscerie@users.noreply.github.com>
@Zeioth
Copy link
Author

Zeioth commented Mar 26, 2024

chriscerie since there are no bugs, the code has already being refactored as specified, and all the new reviews are stylistic preferences, or would affect parts outside the PR, I'm gonna leave the code as it is. Feel free to co-author if you see something you would prefer to do in a different way.

The code is safe to merge.

@chriscerie
Copy link
Collaborator

I appreciate your contribution, but this pr can't be merged until these bugs are fixed (see above comments for root causes). I'm happy to step in and co-author to get this merged but as there are other selene features with higher priority, I make no promises on the timeline.

Config with invalid utf-8 character

Currently
image
New
image

Missing config

Currently
image
New
image

@Zeioth
Copy link
Author

Zeioth commented Mar 27, 2024

bad UTF-8 error is controlled now.
screenshot_2024-03-27_14-18-16_067338925

@Zeioth
Copy link
Author

Zeioth commented Mar 27, 2024

Missing file is also parsed correctly (this is my build, not the package manager one).
screenshot_2024-03-27_14-34-02_956661142

@Zeioth
Copy link
Author

Zeioth commented Mar 27, 2024

Relevant changes to vscode extension 47b0642

@chriscerie It should be ready but I have no clue how to test this on vscode. Could you test it or tell me how you test it so I can try to reproduce?

Copy link
Collaborator

@chriscerie chriscerie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing config

Before
image
Now
image

Permission denied

Before
image
Now
image

selene/src/main.rs Outdated Show resolved Hide resolved
selene/src/main.rs Outdated Show resolved Hide resolved
Zeioth and others added 10 commits May 7, 2024 18:18
…rors -> report error and exit.

* If path doesn't exist -> check next path.
* None of the paths exist? → It uses the default config correctly.
…f-8. Plus, doing so would return a different error than the orignal.
…ng config file: No such file or directory (os error 2)`
…eading config file: No such file or directory (os error 2)`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Selene should search for configuration files that begin with a dot
3 participants