Comments (11)
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.
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.
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.
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.
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.
@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.
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.
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.
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.
Thanks!
from material.nvim.
I've enabled it and it's working fine - will close the issue :)
from material.nvim.
Related Issues (20)
- New material `colors.editor.fg_dark` too dark HOT 3
- Add vim-treesitter-context support HOT 4
- Add highlights for flash.nvim HOT 10
- Tab colours aren't in Material colours HOT 2
- List chars HOT 2
- Indent-Blankline V3 support HOT 1
- Plugin doesn't work at all; nothing is highlighted HOT 7
- The colors are different from the colors in vscode HOT 1
- plugin breaks kitty protocol (existing workaround) HOT 2
- Automatic enabling of plugin support HOT 3
- Can't see text in `neotree` if not run `colorscheme material-darker` HOT 5
- How can I disabled underline like this? HOT 3
- tree-sitter highlights broken since introduction of Neovim (nightly) default colourscheme HOT 3
- Noice colour scheme not working HOT 2
- captures changed in nvim-treesitter HOT 3
- Unable to Remove Bold Text Styling in Neovim Configuration HOT 2
- Feature Request: Provide option to highlight diagnostic virtual text HOT 6
- Add Support for `CocHighlight{Text,Read,Write}` Highlight Groups HOT 2
- Broken syntax support for python file. HOT 2
- style fg color not working but bg does work HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from material.nvim.