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

zsh: plugins #55

Closed
dermetfan opened this issue Sep 3, 2017 · 3 comments
Closed

zsh: plugins #55

dermetfan opened this issue Sep 3, 2017 · 3 comments

Comments

@dermetfan
Copy link
Collaborator

dermetfan commented Sep 3, 2017

I recently extended the zsh module by a plugins option in my dotfiles:

programs.zsh.plugins = [
  {
    file = "zsh-256color.plugin.zsh";
    src = pkgs.fetchFromGitHub {
      owner = "chrissicool";
      repo = "zsh-256color";
      rev = "ae40a49ccfc7520d2d7b575aaea160ff876fe3dc";
      sha256 = "0c2yzbd4y0fyn9yycrxh32am27r0df0x3r526gf1pmyqiv49rg5z";
    };
  }
  {
    file = "fast-syntax-highlighting.plugin.zsh";
    src = pkgs.fetchFromGitHub {
      owner = "zdharma";
      repo = "fast-syntax-highlighting";
      rev = "5fab542516579bdea5cc8b94137d9d85a0c3fda5";
      sha256 = "1ff1z2snbl9rx3mrcjbamlvc21fh9l32zi2hh9vcgcwbjwn5kikg";
    };
  }
];

The result looks like this in .zshrc:

autoload -Uz compinit; compinit -iCd $HOME/.zcompdump
path+="/nix/store/w8jv67h8l60dj6fzm35q5sxdimi62bps-zsh-256color-ae40a49ccfc7520d2d7b575aaea160ff876fe3dc-src"
fpath+="/nix/store/w8jv67h8l60dj6fzm35q5sxdimi62bps-zsh-256color-ae40a49ccfc7520d2d7b575aaea160ff876fe3dc-src"
source "/nix/store/w8jv67h8l60dj6fzm35q5sxdimi62bps-zsh-256color-ae40a49ccfc7520d2d7b575aaea160ff876fe3dc-src/zsh-256color.plugin.zsh"
path+="/nix/store/13r11ycprwslr6851qr13pl6ms73906m-fast-syntax-highlighting-5fab542516579bdea5cc8b94137d9d85a0c3fda5-src"
fpath+="/nix/store/13r11ycprwslr6851qr13pl6ms73906m-fast-syntax-highlighting-5fab542516579bdea5cc8b94137d9d85a0c3fda5-src"
source "/nix/store/13r11ycprwslr6851qr13pl6ms73906m-fast-syntax-highlighting-5fab542516579bdea5cc8b94137d9d85a0c3fda5-src/fast-syntax-highlighting.plugin.zsh"

I also tried this syntax but the order is not preserved. Maybe when toposort is implemented in #50 we can use it here:

programs.zsh.plugins = with pkgs; {
  "zsh-256color".src = fetchFromGitHub {
    owner = "chrissicool";
    repo = "zsh-256color";
    rev = "ae40a49ccfc7520d2d7b575aaea160ff876fe3dc";
    sha256 = "0c2yzbd4y0fyn9yycrxh32am27r0df0x3r526gf1pmyqiv49rg5z";
  };

  "fast-syntax-highlighting".src = fetchFromGitHub {
    owner = "zdharma";
    repo = "fast-syntax-highlighting";
    rev = "5fab542516579bdea5cc8b94137d9d85a0c3fda5";
    sha256 = "1ff1z2snbl9rx3mrcjbamlvc21fh9l32zi2hh9vcgcwbjwn5kikg";
  };
};

In an attempt to reduce my zsh startup time I switched from oh-my-zsh to antigen to zr but I could not bring it below ~0.95 sec. Using the plugins option I get a consistent 0.05 sec with the same plugins loaded. I'm not sure what the cause is (may be related to #54) but I like the simple approach.

Would this be a desirable feature for home-manager?

@rycee
Copy link
Member

rycee commented Sep 3, 2017

I think this is separate from #50 but certainly related to topological sorting. Maybe could have a dependsOn field that can be used to produce a DAG that can be sorted using dagTopoSort? In any case, it seems to me like a neat idea but I don't use zsh so I don't have a strong opinion. Maybe @uvNikita has input to give?

@uvNikita
Copy link
Collaborator

uvNikita commented Sep 4, 2017

With the changes from #54, startup time for me dropped from 1.3s to 0.13s. And with disabling programs.zsh in the system (which will remove another unnecessary pollution of fpath) it dropped down to 0.066. So after PR will be merged, startup time with programs.zsh.oh-my-zsh enabled should be fast again.

But I also like the idea of being able to use vanilla zsh and extending it with plugins directly, so I think your changes would be a very useful extension of the current module.

@dermetfan
Copy link
Collaborator Author

Closing with #56.

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

No branches or pull requests

3 participants