Giter Club home page Giter Club logo

Comments (11)

marko-cerovac avatar marko-cerovac commented on June 13, 2024 5

Okay, it's done 🎉 . You can now officially use your own colors in material.nvim. Just define a variable like this:

vim.g.material_custom_colors = { bg = "#0F111A" , red = "#FF0000" } 

If you find any errors when using this option, please let me know, so I can fix it.
Hope you like it 😉

from material.nvim.

marko-cerovac avatar marko-cerovac commented on June 13, 2024 1

Well, I was following the official material theme palette to be as true to the original as possible so I never thought it would be necessary to change the color values. Of course, since there is a need, I will try to implement it. It will probably take a few days, but I'm pretty sure I can make it work.

from material.nvim.

rti avatar rti commented on June 13, 2024 1

You are right. Especially the backwards compatibility is a huge issue with setup function.

Sorry @svalaskevicius for hijacking your issue thread here.

from material.nvim.

svalaskevicius avatar svalaskevicius commented on June 13, 2024 1

Absolutely no problems for continuing the conversation! (from my side at least :)). I'm very new to this lua style plugins and themes so I don't have much input myself.

This ticket is merely an idea I had, for the author of the theme to look at, consider and decide :)

To add, I'm happy with any outcome, worst case I can periodically refresh my fork from here and have my adjusted colours that way - so just a question of convenience :)

Also thanks to @marko-cerovac for considering this idea!

from material.nvim.

svalaskevicius avatar svalaskevicius commented on June 13, 2024

Thanks! So far I came up with https://github.com/svalaskevicius/material.nvim/blob/b6e0241348eb81a17b5e85a17b3dbf2ea1343de8/lua/material/colors.lua#L46 (in combination with a teal variable colour) but I'm sure I'll be editing the shades as I code using it more :)

from material.nvim.

rti avatar rti commented on June 13, 2024

@svalaskevicius Thanks a lot for opening this issue. I thought about exactly the same thing as well already.

@marko-cerovac Great that you want to take a look into it. Thank you. When I thought about how to implement it I started to like the idea of a setup() function to init the plugin - as many other nvim lua plugins use it as well. Is there any reason material.nvim does not have such a function? I think it would be even simpler (and more common) to provide this function with a color map (and other config parameters).

Let me know if I can be of any help.

from material.nvim.

marko-cerovac avatar marko-cerovac commented on June 13, 2024

In the beginning, I also thought about implementing it with a setup function, but there is a problem. Unlike colorschemes, other plugins get loaded only once and they can be called from the setup function. It basically tells the plugin "load up with these settings". But with colorschemes, what happens when you switch to a different colorscheme and then back to material using the command :colorscheme material , or when you use the toggle_style() function? The whole plugin needs to be loaded again, but this time, you didn't pass it any setup parameters and it would just use the defaults, and not your custom settings. The most logical way to solve this is to use global variables, which don't go away even if you switch to another colorscheme. That's why every colorscheme out there uses global variables instead of a setup function.

from material.nvim.

rti avatar rti commented on June 13, 2024

Thanks for the explanation. I think I still do not really understand why we cannot have a setup function though. But I never wrote a vim plugin nor wrote a serious amount of lua. So please excuse me if I am on a completely wrong path.

If we take for example lualine: It creates a variable config here which actually just points to the config object in the config module. On setup, lualine sets the given user config which in turn stores it in the config object of the config module. Autocmds call a statusline() function whenever e.g. a buffer is entered or left (not only duing setup) and this statusline() function relies on values from the config object.

Isn't this basically the same thing we would need? Query the config object for color values and other settings as soon as toggle_style() is called at any point during editor runtime?

from material.nvim.

marko-cerovac avatar marko-cerovac commented on June 13, 2024

I guess it can be done, and I also like setting up plugins with setup functions and I think it looks really clean, but we need to weigh the pros and cons here. Global variables are meant to be used for this kind of stuff, and if you type :let g: and then hit tab to autocomplete, you will see that a lot of plugins use it exactly for this kind of configuration (indent-blankline, nvim-tree, dashboard, vsinp and many more..). They don't cause any performance issues for NeoVim and make writing plugins much easier. And the biggest issue is backwards compatibility. If I were to implement it, hundreds of users of this colorscheme would get errors after an update. I would have to make an in-between solution for a while where the theme could use global variables or a setup function to prevent it breaking for users, and that would be a really huge mess. The custom color injection can be solved pretty easily with a global table like in tokyonight.nvim. Also a majority of users still uses vim-script for configuration and don't plan on switching to lua. This makes the theme a lot more friendly and easier to configure for them. I'm sorry, but I just don't see any major reason to switch to a setup function right now, besides it looking kinda cool, and the drawbacks are really big. If I encounter a big problem in the future that requires me to switch to a setup function, I will, but for now, I think it's a bad idea.

from material.nvim.

svalaskevicius avatar svalaskevicius commented on June 13, 2024

Thanks!

from material.nvim.

svalaskevicius avatar svalaskevicius commented on June 13, 2024

I've enabled it and it's working fine - will close the issue :)

from material.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.