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

Flexible TMux Configuration Load #143

Merged
merged 3 commits into from
Nov 7, 2018
Merged

Conversation

weilbith
Copy link
Contributor

@weilbith weilbith commented Nov 2, 2018

The current implementation is hard-coded about where to get the TMux configuration file for read in the listed plugins.
But TMux could be started with a different configuration file. Following the XDG Directory Specification for TMux as also suggested in the ArchWiki, the default location does not fit anymore. In that case the plugin manager is unusable.
To provide a more configurable solution, I've added a new function to search for the TMux configuration in prioritized order.

  • First I've defined the optional environment variable TMUX_PLUGIN_MANAGER_CONFIG_LOCATION, which has the highest priority and can be set by the user to anything, regardless if it exists or not.
  • On second place the XDG_CONFIG_HOME directory is searched for an TMux entry.
  • At least the default one at $HOME/.tmux.conf is taken.

The implementation is super simple, but allows user like me to be more flexible.

Add function `_get_user_tmux_conf` to helper script `plugin_functions`.
Function is searching for the users tmux configuration on multiple
places by a prioritized order.
The response is used within`_tmux_conf_contents` to read in the content
as normally.
Add new environment variable `TMUX_PLUGIN_MANAGER_CONFIG_LOCATION` which
is optional to be defined.
If so it has the highest priority to be loaded, despite if the file
exist or not.
XDG directory support has been added as well by the second priority
location at `$XDG_CONFIG_HOME/tmux/tmux.conf`.
@bruno-
Copy link
Member

bruno- commented Nov 2, 2018

I glanced at the PR and it looks good. I have 2 questions:

  • Do we really need TMUX_PLUGIN_MANAGER_CONFIG_LOCATION? I'd rather wait someone requests that feature, than implementing it just because "it might make sense".
  • Can you please update indentation? This plugin uses tabs.

Thanks!

@weilbith
Copy link
Contributor Author

weilbith commented Nov 4, 2018

Tabs/Spaces
Sry for that. Have reconstruct them on the recent commit. Maybe it would be wise to set this Vim configuration as comment? 🤔

Variable
I thought it would be nice to make it as easy for the user as possible. First I just implemented the XDG compatibility. Then I recognized, that some applications still use dotted files within XDG_CONFIG_HOM like Zsh for example. So I thought users can stuck again by that (with dot or not). After all I thought it would be the easiest solution for all cases to provide this configurable option.
But I've you don't like it, I can simply remove it.

@bruno-
Copy link
Member

bruno- commented Nov 6, 2018

@weilbith yea, let's remove the TMUX_PLUGIN_MANAGER_CONFIG_LOCATION variable for now. Let's wait for users to request that feature before implementing it. And returning this functionality (if needed) should be easy.

It has been decided that this feature should been removed until it will be requested.
@weilbith
Copy link
Contributor Author

weilbith commented Nov 7, 2018

Okay, done.

Open questions:

  1. Where should I extend the documentation? For example the alternative installation place instructions are not in the default README.
  2. Am I allowed to add a Vim configuration comment at the bottom to force the using of tabs? Cause I guess I will not be the only one doing this without purpose.

@bruno- bruno- merged commit 0128e36 into tmux-plugins:master Nov 7, 2018
@bruno-
Copy link
Member

bruno- commented Nov 7, 2018

@weilbith thanks!

Where should I extend the documentation?

I just added a short note via 42bb2bf. If you have a better idea feel free to open another PR. If the docs are more than a paragraph I'd prefer if it's placed in docs/ dir so it doesn't clutter the README.

Am I allowed to add a Vim configuration comment

I'm a heavy vim user, but I prefer not doing this in any of my public projects. I feel this discriminates all other editors, by indicating preference to vim. Contributors usually figure out the spacing. Having set list in vim could be useful for this.
Also, I kinda regret using tabs for all the plugins. I had "a reason" why I went with it, but now I think the convenience of two-space indentation would be better.

@gnumoksha
Copy link

Hi. This improvement came at the right moment for me, but I'm struggling to make this work. Is expected that ~/.tmux/plugins continue being created?

@weilbith
Copy link
Contributor Author

@gnumoksha u can do so manually by following this documentation. This is not done automatically by where-your-tmux-config-is.

@gnumoksha
Copy link

@weilbith this made the job, thanks!

One thing I would like to add is that someone can expect TMUX_PLUGIN_MANAGER_PATH to be changed according to $XDG_CONFIG_HOME.

@weilbith
Copy link
Contributor Author

@gnumosksha
How do you expect that this works?
If TPM finds the tmux.conf inside $XDG_CONFIG_HOME directory, it should set $TMUX_PLUGIN_MANAGER_PATH to the same location automatically?

@dsifford
Copy link

dsifford commented Feb 11, 2019

Does this PR resolve the issue involving nonstandard tmux paths? (#57)

Can those of us who use tmux by calling it with tmux -f "$XDG_CONFIG_HOME"/tmux/tmux.conf, now use the newer set -g @plugin [...] syntax without issue?

Edit: Just tried and the answer is, yes we can.

karbobc pushed a commit to karbobc/tpm that referenced this pull request Nov 4, 2022
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.

4 participants