danth / stylix

System-wide colorscheming and typography for NixOS
https://stylix.danth.me/
MIT License
902 stars 105 forks source link

vim: interface colorscheme #401

Closed NewDawn0 closed 4 weeks ago

NewDawn0 commented 1 month ago

Scope

This PR exposes the base16 colourscheme by using a Vimscript dictionary

Motivation

This change allow users to acess the colours within their Vim/NeoVim config, which is useful for example to set highlight groups for specific plugins

Changes Made

Example usage

g:colors['base00'] " Yields the hex code of base00

Or using lua

vim.g.colors.base00 -- Yields the hex code of base00
NewDawn0 commented 1 month ago

I just noticed that some indenting is wrong in my formatting commit, this is due to the fact that my own neovim config is currently broken and is not displaying tabs correctly. However, I did check that this does not affect the functionality of the code in this pr whatsoever, which is why I'm not making another PR. This comment is just to point out this minor error on my part here

NewDawn0 commented 1 month ago

I renamed the colors to stylixColors, as from what I've looked at in the stylix codebase, it mostly seems to be camel case which is why I've opted for this name out of the options you've kindly given me.

Again the indentation might be messed up, but I tried fixing it again with my new fix indendation commit, it should be the right amount of indentation but with the state of my current Neovim I cannot confirm if that is the case. If it is still messed up I'm assuming someone with a less broken neovim will fix it.

trueNAHO commented 1 month ago

I renamed the colors to stylixColors, as from what I've looked at in the stylix codebase, it mostly seems to be camel case which is why I've opted for this name out of the options you've kindly given me.

I was actually referring to the VIM naming convention rather than the Nix (Stylix) convention.

Again the indentation might be messed up, but I tried fixing it again with my new fix indendation commit, it should be the right amount of indentation but with the state of my current Neovim I cannot confirm if that is the case. If it is still messed up I'm assuming someone with a less broken neovim will fix it.

You can also start nvim without loading your configuration:

-u vimrc    Use  vimrc  instead  of  the default ~/.config/nvim/init.vim.  If
            vimrc is NORC, do not load any initialization files (except
            plugins).  If vimrc is NONE, loading plugins is also skipped.  :help
            initialization
NewDawn0 commented 1 month ago

I renamed the colors to stylixColors, as from what I've looked at in the stylix codebase, it mostly seems to be camel case which is why I've opted for this name out of the options you've kindly given me.

I was actually referring to the VIM naming convention rather than the Nix (Stylix) convention.

Again the indentation might be messed up, but I tried fixing it again with my new fix indendation commit, it should be the right amount of indentation but with the state of my current Neovim I cannot confirm if that is the case. If it is still messed up I'm assuming someone with a less broken neovim will fix it.

I checked the vim variable naming convention and will convert it to snake case

You can also start nvim without loading your configuration:

-u vimrc    Use  vimrc  instead  of  the default ~/.config/nvim/init.vim.  If
            vimrc is NORC, do not load any initialization files (except
            plugins).  If vimrc is NONE, loading plugins is also skipped.  :help
            initialization

Alright I'll do that to check if the indentation is good or needs fixing Thank you

NewDawn0 commented 1 month ago

I changed the name to snake case as per Vim variable naming convention and double checked the indentation withVvim by using vim -u NONE -U NONE -N -i NONE and it looks good

danth commented 1 month ago

Assuming you are configuring Vim/NeoVim through Home Manager, could you not simply use ${baseXX} to substitute the colors directly into your config?

trueNAHO commented 1 month ago

Assuming you are configuring Vim/NeoVim through Home Manager, could you not simply use ${baseXX} to substitute the colors directly into your config?

Initially, I had the same thought. Unlike NixVim users, I assume plenty of VIM and NeoVim users simply symlink their Vimscript or Lua configuration files with Nix. In that case, it might be nice to have these color variables injected. At least, that is my speculation.

NewDawn0 commented 4 weeks ago

Assuming you are configuring Vim/NeoVim through Home Manager, could you not simply use ${baseXX} to substitute the colors directly into your config?

I for example use mostly Lua in my NeoVim config, which means I'm unable to directly inject the variables directly from stylix. Even if that was not the case I still believe it is a good idea to be able to access these colours directly in Vimscript or Lua. This would especially be needed for custom vim plusings which don't have access to the stylix variables as plugins are usually purely just a collection of Lua or Vimscript files without nix.

And on a side note, do you have an estimate how long this will take to merge? So I can plan ahead when I need to switch the stylix input of my system flake from my fork to the official one.