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

Feat: base16-vim integration #859

Closed
jonleopard opened this issue Oct 6, 2022 · 6 comments
Closed

Feat: base16-vim integration #859

jonleopard opened this issue Oct 6, 2022 · 6 comments
Labels
new feature New feature or feature request

Comments

@jonleopard
Copy link

Requested feature

base16-vim and base16-shell offer a suite of tools that allow automatic colorscheme switching in multiple environments (shell, tmux, vim, etc..). With base16-vim installed, neovim is aware of what theme is currently active and will set the theme accordingly.

Is there a way that we could use base16-vim instead of nvim-base16?

Ideally, it would be nice to tell lualine to use whatever base16 theme is currently active. This also opens up automatic theme switching for users that have base16-shell installed.

local current_theme_name = vim.g.colors_name

require 'lualine'.setup {
    options = {
        theme = current_theme_name
    }
}

Right now, this returns an error since its not aware of base16-vim's colorschemes.

Theme `base16-tokyo-night-dark` not found, falling back to `auto`. Check if spelling is right.

theme(base16): nvim-base16 is not currently present in your runtimepath, make sure it is properly installed, fallback to default colors.

Motivation

The base16 project is fairly centralized and themes are updated weekly. Instead of relying on another repository (nvim-base16) which might have out of date themes and no integration with the core suite of tools, I think integrating lualine to work with base16-vim would be cool/useful idea.

Thanks!

@jonleopard jonleopard added the new feature New feature or feature request label Oct 6, 2022
@shadmansaleh
Copy link
Member

It's possible to support base16-vim too. Some one just needs to import the colors from base16-vim when it's installed here And update the base16 conditions to check for base16-vim alongside base nvm-base16

@t3hpr1m3
Copy link

Slight necro here, but the issue is that base16-vim doesn't actually "load" any colors. It just sets colorscheme normally, and rtp logic loads the colors file. In essence, the correct behavior is just to use auto as the theme. Unfortunately, because the colorscheme contains base16 in the name, it triggers the nvim-base16 integration, which results in a LualineNotice because the plugin isn't loaded.

In looking at the way the logic is laid out in lualine.nvim, I'm not sure what the best fix would be, since the assumption is that if you're using a base16 theme, you have nvim-base16 installed (or at least something that behaves like it).

@olekspickle olekspickle mentioned this issue Jun 7, 2023
2 tasks
@titaniumtraveler
Copy link

@t3hpr1m3 Wouldn't the best option not be to just test if vim.g.base16_gui00 etc are set and if yes to just use that to create the colors table?
That way it should just work automatically.

@t3hpr1m3
Copy link

t3hpr1m3 commented Nov 17, 2023

@titaniumtraveler Sorry for the huge delay. That would work (and your PR looks like it would work). For transparency, this issue caused me to drop lualine and just put together a quick custom statusline, so somebody else might be able to verify.

@titaniumtraveler
Copy link

@titaniumtraveler Sorry for the huge delay. That would work (and your PR looks like it would work). For transparency, this issue caused me to drop lualine and just put together a quick custom statusline, so somebody else might be able to verify.

No problem. My solution for now, until the PR (#1081) is accepted,
is to just do the same thing I described as part of a colorscheme,
though sadly it doesn't reload when the colorscheme changes.

local function setup(colors)
  local theme = {
    normal = {
      a = { fg = colors.bg, bg = colors.normal },
      b = { fg = colors.light_fg, bg = colors.alt_bg },
      c = { fg = colors.fg, bg = colors.bg },
    },
    replace = {
      a = { fg = colors.bg, bg = colors.replace },
      b = { fg = colors.light_fg, bg = colors.alt_bg },
    },
    insert = {
      a = { fg = colors.bg, bg = colors.insert },
      b = { fg = colors.light_fg, bg = colors.alt_bg },
    },
    visual = {
      a = { fg = colors.bg, bg = colors.visual },
      b = { fg = colors.light_fg, bg = colors.alt_bg },
    },
    inactive = {
      a = { fg = colors.dark_fg, bg = colors.bg },
      b = { fg = colors.dark_fg, bg = colors.bg },
      c = { fg = colors.dark_fg, bg = colors.bg },
    },
  }

  theme.command = theme.normal
  theme.terminal = theme.insert

  return theme
end

local colors = {
  bg = vim.g.base16_gui01,
  alt_bg = vim.g.base16_gui02,
  dark_fg = vim.g.base16_gui03,
  fg = vim.g.base16_gui04,
  light_fg = vim.g.base16_gui05,
  normal = vim.g.base16_gui0D,
  insert = vim.g.base16_gui0B,
  visual = vim.g.base16_gui0E,
  replace = vim.g.base16_gui09,
}

return setup(colors)

@shadmansaleh
Copy link
Member

resolved with #1006

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants