steelbrain / linter-ui-default

Default UI for the Atom Linter package
MIT License
85 stars 47 forks source link

Request: do not store panelHeight within config.cson #435

Open caleb531 opened 7 years ago

caleb531 commented 7 years ago

Hi, @steelbrain.

I am a frequent Atom and Linter user. I have all of my ~/.atom config (*.cson files) stored in my dotfiles repository for easy management and syncing across my two machines. However, I am often committing changes to config.cson because the panelHeight for linter-ui-default has changed:

screen shot 2017-09-13 at 2 54 31 pm screen shot 2017-09-13 at 2 58 21 pm

I suspect this happens because my panel height on one machine differs from the panel height on my other machine. Regardless, I'd much prefer if the value for this field was stored outside of config.cson (maybe in the storage/ directory or something). config.cson should really only be for non-volatile configuration, but panelHeight definitely feels like a volatile (i.e. easily-changing) field.

Thanks, Caleb

jeannnemelanie commented 3 years ago

Any update on this subject ? This really anoying when using dotfiles to sync atom configs between devices. Thanks!

caleb531 commented 3 years ago

@jeannnemelanie Fortunately, I've discovered a clever workaround by using some git config:

.gitattributes

First, create a file called .gitattributes in the same directory as your atom config.cson

# Ignore linter-ui-default's panelHeight setting in Atom config
config.cson filter=strip-panel-height

.gitconfig

Secondly, add the following lines to your global .gitconfig

# Ignore linter-ui-default's panelHeight setting in Atom config
[filter "strip-panel-height"]
    clean = sed '/  panelHeight:/d'

You can also set this from the Terminal if you don't have a global gitconfig already managed in your dotfiles:

git config --global filter.strip-panel-height.clean "sed '/  panelHeight:/d'"

Git should now ignore changes to any line containing panelHeight in config.cson.

aminya commented 3 years ago

Currently, panelHeight is editable when you resize it. This is a config that is set by you. If we don't store this in the config.cson, it will become only a local value. Is this desirable?

jeannnemelanie commented 3 years ago

@caleb531 thanks for the tip! I've never used .gitattributes. I will give it a try for sure!

@aminya in my case, I never decided to set panelHeight. I actually ticked alwaysTakeMinimumSpace and hidePanelWhenEmpty. Of course alwaysTakeMinimumSpace and hidePanelWhenEmpty should be stored in config.cson but I don't think it's relevant for panelHeight whose value is changing all the time (depending on the file I'm working on and even the errors/warnings on the files). As @caleb531 said, storage directory (or something like that) looks like a better solution for this special case.

aminya commented 3 years ago

OK. Thanks for providing more context.

We should use LocalStorage instead.

wjandrea commented 3 years ago

@caleb531 Thanks for that git config! That's almost exactly what I was looking for. I just wanted to point out two things:

  1. It doesn't have to be the global gitconfig. I put mine in local.
    • Edit: I just realized local doesn't sync, so you put it in your global because it's stored in the same repo
  2. Quote the clean command. I tried to add a semicolon to the sed script, but it wouldn't work and it took me a while to figure out the problem.

    [filter "strip-panel-height"]
        clean = "sed '/  panelHeight:/d'"

I noticed that the showPanel setting is also volatile (FYI @aminya), so I excluded it as well like this:

.gitattributes

in the same directory as config.cson

config.cson filter=strip-Atom-config-volatile-settings

git config

in .git/config

[filter "strip-Atom-config-volatile-settings"]
    # Ignore linter-ui-default's panelHeight and showPanel settings in Atom config
    clean = "sed '/\\spanelHeight:/d; /\\sshowPanel:/d'"
    # Based on caleb531's comment on GitHub:
    # https://github.com/steelbrain/linter-ui-default/issues/435#issuecomment-778731834

(I also switched the spaces to \s (whitespace) just in case of hard tabs in config.cson.)