savq / melange-nvim

🗡️ Warm color scheme for Neovim and beyond
MIT License
732 stars 55 forks source link

Add 'setup' function and 'config' table; Refactor colors/melange.lua #66

Closed SollyCB closed 1 year ago

SollyCB commented 1 year ago

Move everything from colors/melange.lua to 'M.setup(config)' function in lua/melange/init.lua; here add 'M.config' table to set font variants. Remove vim.g.melange_enable_font_variants; replace with 'config_set' variable.

Usage: Call 'require("melange").setup(config)' before setting colo to enable config options; if 'setup' is not called, 'config_set' remains false and all options are enabled, keeping with the default behaviour of the theme before my changes.

Checklist for Plugins

Paste link to documentation listing highlight groups:

Checklist for Terminal Emulators


SollyCB commented 1 year ago

Idk if you will care for these changes, but using tmux and alacritty I get awful highlighting issues because of font-variant support. Rather than try to setup my environment differently, I really wanted to just toggle what was not working. The global toggle was fine, but I wanted to test what would and would not work. I only added the ability to set more specific configuration options. But I did move everything from colors/melange.lua into lua/melange/init.lua to make calling the setup function more ergonomic (this mirrors ellisonleao/gruvbox.nvim).

Hopefully you like it...

SollyCB commented 1 year ago

Specifically I moved all of your code into a setup function in the init file. This is described in the commit message.

savq commented 1 year ago

using tmux and alacritty I get awful highlighting issues because of font-variant support.

Does set -g default-terminal "tmux" work? See the tmux FAQ.

I did move everything from colors/melange.lua into lua/melange/init.lua to make calling the setup function more ergonomic

This isn't really necessary. Since Lua modules are cached, you can check whether the user has required a module:

-- in `colors/melange.lua`
if package.loaded['melange'] then
  local melange = require 'melange' -- References an already instantiated module 
  -- read config
else
  -- set defaults
end

Module caching is actually the reason I keep the highlight groups in colors/melange.lua. Files in colors/ are always reloaded, which makes it easier to try things out.


I did notice a mistake in the logic for font variants (Lua false didn't work) and I fixed that in https://github.com/savq/melange-nvim/commit/8de8df55f091fabf9b5e9d39761dfa9617b0c182

SollyCB commented 1 year ago

Ye I didn't know about the caching, good to find out. I just made a super naive implementation, apologies if I wasted your time with this code 😂. I know nothing about neovim lua, so I just reimplemented what I saw in the gruvbox repo. I will get back to u on the tmux config, but I'm sure it does work. (I also just wanted some config options as I like bold but not italic 😝, the hl bugs just made me jump to implementing it)