-
Notifications
You must be signed in to change notification settings - Fork 15
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
Not working in the presence of a .editorconfig
file
#17
Comments
Thank you for opening an issue! I don't think I've ever used an editorconfig file for anything other than implementing functionality for this plugin, so this is an area that I like to have issues for. Yes, if an editorconfig file is present, tidy is disabled (see this PR). Given that I don't have cause to use this feature often, I deferred to the judgement of users of the plugin for how it should behave when an editorconfig file is present. iiuc, the functionality that tidy provides can also be had through editorconfig functionality. What do you think about all of this? |
To be honest I just heard about the EditorConfig and it was very convenient to fix the tab sizes that vim-sleuth was getting wrong, although it seems to be able to handle much more than that. Thus, while I think it was a safe move to disable the plugin in its presence, we may get into this corner case where, e.g., I want to use editorconfig to set tab sizes but still want tidy to clean my files. Since you asked, I think it would be nice to use editorconfig to decide how tidy would work. This would be nice given that it is something neovim already supports and could act as some kind of plugin configuration, but I don't know how hard it would be to do and maintain. (If going with this route, apparently the I would be happy to serve as a guinea pig to test some it if you decide to implement it. Alternatively, I am also okay with an option to completely ignore the editorconfig and keep working as usual. We could see conflicts in the previous two configurations but as long as this is documented and disabled by default it should be fine. |
To clarify the requirements, you'd like something where if Example 1You have an
So, tidy sees this and detects that trimming whitespace and leaving the last newline are not defined. In that case, you'd like for tidy to continue with all of its normal behavior Example 2Given the below
You'd like tidy to detect these settings and remove newlines except for the last one and not trim whitespace? Is this accurate? All of this can be done pretty easily. |
An update since my last comment: I've implemented the changes and pushed them to a branch called
All of this behavior is opt-in, so it is off by default. Tidy will continue to default to just not running at all if an If this fits your needs and it works well, I will merge this into main. |
Hey, I am sorry for the late reply, but I managed to test the plugin on I tested on a R language file because it is one example when my tree-sitter does not respect the recommended indentation (it adds 8 spaces on indent instead of 2). For reference, my nvim pertaining configuration is: {
'mcauley-penney/tidy.nvim',
config = true,
branch = 'provide-undefined-editorconfig-behavior',
opts = {
provide_undefined_editorconfig_behavior = true,
},
} (I use Lazy to manage plugins) and I created the following [*.R]
indent_style = space
indent_size = 2 I noticed that:
So thanks a lot for your work and response! In my view this is good to be merged. |
To be explicit, does this appear to be coming from Tidy or is this the same behavior that you get with treesitter even without Tidy? If this is the plugin's fault, I'll happily look into before merging. |
Oh no, sorry, I didn't express myself correctly. The wrong indentation is not related to The initial issue was |
For sure, no worries! Thank you for clarifying 💯 In that case, I will look at merging this later today and I'm glad to hear that its working for your use case |
I can also confirm this works as expected. @mcauley-penney was there some blocker for this not being merged to |
I think I just forgot tbh. I'll merge it now so I don't forget again 👍🏻 thanks for mentioning it! |
Closed by 58fcc63 |
No, thank you for making an already awesome plugin even more awesome! |
Hi, I use vim-sleuth to automatically define the file indentation. Since it was erroneously setting indentation for R files, I included a EditorConfig file in my root directory. While this fixed the indentation, I noticed the whitespaces and blank lines were not being removed anymore.
At first I thought this was something with the R language, but it happens consistently with files of any extension I put in this directory. And, if I remove the
.editorconfig
file, tidy starts working again.The smallest project to replicate the issue is with an empty folder with a
.editorconfig
file with the contents:and any files with any extension in this folder or any subfolder stop getting tidied on save.
I checked the plugin is still loaded with
Lazy
, and even by runninglua require("tidy").run()
manually nothing happens when theeditorconfig
file is there.Is this something expected? I noticed this line in the code apparently disabling it in the presence of this file, but I am not that fluent in Lua to ensure my analysis is correct.
The text was updated successfully, but these errors were encountered: