mcauley-penney / tidy.nvim

A small Neovim plugin to remove trailing whitespace and empty lines at end of file on every save
107 stars 15 forks source link

Disable tidy for markdown #5

Closed greg0ire closed 2 years ago

greg0ire commented 2 years ago

Hi! I'm trying to migrate my vim config to lua, and stumbled upon this plugin, which looks great, except for one thing: it uses Markdown as an example for the main usage, and Markdown is the only file format I know for which trailing whitespace is meaningful. I don't use it and no longer work with people who do so I'm still going to use your plugin, but still, it would be nice to be able to disable this plugin for markdown only.

mcauley-penney commented 2 years ago

Several points:

  1. Firstly and most importantly to this issue, I think adding this config option will probably be useful to other users as well. I could never account for all of the use cases that a person might have and I assume that there are file types out there that I'm unfamiliar with where white space at the end of a file is useful or necessary. I'll add a configuration option for file types to ignore in the next day or two 👍🏻

  2. the file type being used in the video is actually a text file. The first file that is open in the bufferline is Markdown, that is true, but it isn't the one I was using. Tidy won't affect other open buffers and simply acts on the current one. I don't know if this point is really meaningful to the conversation, though, because you are right and Tidy doesn't check file type.

  3. The guide you linked uses the example

    
    First line with two spaces after.  
    And the next line.

First line with the HTML tag after.
And the next line.


which Tidy will not affect because it will not touch white space between text. I assume that you were using that example to display that white space is important to Markdown in general, so I hear you on that point, but that specific example isn't a useful one in my opinion. *If that example was being used to display that white space at the end of a Markdown file is significant, I didn't know that and that is a problem.* I've never run into that issue before, though. Here is a GIF displaying Tidy working on a Markdown file populated with this example:
![tidy_md](https://user-images.githubusercontent.com/59481467/173189657-d612ab47-cf38-4be6-87e6-8f8979eb9491.gif)
greg0ire commented 2 years ago
  1. Woops! Indeed, I got confused!
  2. I believe tidy will affect the 2 spaces at the end of this piece of text: First line with two spaces after. <-- here. In the example, the second part with the <br/> is html generated from the first part, which is markdown, and the <br/> is generated from the two spaces.

    If that example was being used to display that white space at the end of a Markdown file is significant, I didn't know that and that is a problem.

Yes, this is what the example is all about.

I found some online markdown processors, and only this one implements it, and for one space, not 2: https://markdown.pioul.fr So the issue is very minor, but still, I can imagine how spaces might be important in other languages I don't know. It is for sure a problem for https://en.wikipedia.org/wiki/Whitespace_%28programming_language%29 :laughing:

Peek 2022-06-11 18-07

mcauley-penney commented 2 years ago

I misunderstood! I thought you were talking about lines at the end of the file but I understand now. Because the syntax guide indicates that this is one the portable methods for creating line breaks, this should definitely be a case that is taken care of.

I will implement this soon

greg0ire commented 2 years ago

Thanks!

mcauley-penney commented 2 years ago

No problem, happy to help!