maxmx03.solarized.nvim/README.md
2024-08-25 14:40:08 -03:00

8.6 KiB

solarized-yinyang

Solarized

Neovim LICENSE

Solarized is a sixteen color palette (eight monotones, eight accent colors) designed for use with terminal and gui applications. click here to learn more

Solarized

Features

  • Support for Treesitter
  • Support for Semantic highlight
  • Customizability: styles, colors and highlights can all be modified
  • Plugin compatibility
  • Provides users with the option to enable or disable highlight groups
  • Selenized color palette

Requirements

Before using the Solarized Colorscheme, please make sure you have the following requirements installed:

Install from package manager

Download using your preferred package manager.

lazy

return {
  'maxmx03/solarized.nvim',
  lazy = false,
  priority = 1000,
  ---@type solarized.config
  opts = {},
  config = function(_, opts)
    vim.o.termguicolors = true
    vim.o.background = 'light'
    require('solarized').setup(opts)
    vim.cmd.colorscheme 'solarized'
  end,
}

packer

use {
    'maxmx03/solarized.nvim',
    config = function()
      vim.o.background = 'dark'
      ---@type solarized
      local solarized = require('solarized')
      vim.o.termguicolors = true
      vim.o.background = 'dark'
      solarized.setup({})
      vim.cmd.colorscheme 'solarized'
    end
}

Solarized's Annotations

Using lspconfig

  local lsp_config = require 'lspconfig'
  lsp_config.lua_ls.setup {
    settings = {
      Lua = {
        hint = {
          enable = true,
        },
        runtime = {
          version = 'LuaJIT',
        },
        workspace = {
          checkThirdParty = true,
          library = {
            vim.env.VIMRUNTIME,
            '~/.local/share/nvim/lazy/solarized.nvim',
          },
        },
      },
    },
  }

Using .luarc.json

{
  "workspace.library": ["/path/to/nvim/runtime", "/path/to/solarized.nvim"]
}

Manual Installation

To manually install Solarized, follow these steps:

  1. Download the stable release of Solarized.
  2. Extract the contents of the release.
  3. Locate the following folders in the extracted files: after, colors, lua, plugin.
  4. Copy these folders to the ~/.config/nvim directory.

Docs

Use :h solarized.nvim.txt to see docs

Commands

  • :Solarized colors - Display the Solarized palette in a new buffer

Default Config

vim.o.background = 'dark'

-- default config
require('solarized').setup({
  transparent = false, -- false | true
  on_highlights = nil,
  on_colors = nil,
  palette = 'solarized', -- solarized (default) | selenized
  styles = {
    types = {},
    functions = {},
    parameters = {},
    comments = {},
    strings = {},
    keywords = {},
    variables = {},
    constants = {},
  },
  plugins = {
    treesitter = true,
    lspconfig = true,
    navic = true,
    cmp = true,
    indentblankline = true,
    neotree = true,
    nvimtree = true,
    whichkey = true,
    dashboard = true,
    gitsigns = true,
    telescope = true,
    noice = true,
    hop = true,
    ministatusline = true,
    minitabline = true,
    ministarter = true,
    minicursorword = true,
    notify = true,
    rainbowdelimiters = true,
    bufferline = true,
    lazy = true,
  },
})

vim.cmd.colorscheme = 'solarized'

Config Styles

The styles config allows you to customize the style of a highlight group.

---@type solarized.styles
local styles = {
      comments = { italic = true, bold = false },
      functions = { italic = true },
      variables = { italic = false },
}
require('solarized').setup({
    styles = styles,
})

Config Highlights

The highlights config allows you to customize the highlights groups.

example:

require('solarized').setup {
    on_highlights = function (colors, color)
        local darken = color.darken
        local lighten = color.lighten
        local blend = color.blend
        local shade = color.shade
        local tint = color.tint

        ---@type solarized.highlights
        local groups = {
            Visual = { bg = colors.base02, standout = true },
            Function = { fg = colors.yellow },
            IncSearch = { fg = colors.orange, bg = colors.mix_orange },
            Search = { fg = colors.violet, bg = shade(colors.violet, 5),
            NormalFloat = { bg = darken(colors.base03, 25) }
        }

       return groups
    end
}

Config Colors

The colors config allows you to extend or modify the color palette used by solarized.

Tip

Use :Solarized colors to see available colors.

example:

require('solarized').setup {
    on_colors = function(colors, color)
        local lighten = color.tint
        local darken = color.darken

        return {
            fg = lighten(colors.base00, 2),
            bg = darken(colors.base03, 30)
        }
    end,
    highlights = function(colors)
        return {
            Normal = { fg = colors.fg, bg = colors.bg }
        }
    end
}

Config Plugins

The plugins config allows you to enable or disable solarized support for spefic plugins or neovim's default highlights

example:

return {
  'maxmx03/solarized.nvim',
  lazy = false,
  priority = 1000,
  ---@type solarized.config
  opts = {
    plugins = {
        navic = false,
        nvimtree = false,
        dashboard = false,
        noice = false,
        ministatusline = false,
        minitabline = false,
        ministarter = false,
        rainbowdelimiters = false,
    }
  },
  config = function(_, opts)
    require('solarized').setup(opts)
    vim.cmd.colorscheme 'solarized'
  end,
}

Lualine

require('lualine').setup {
  options = {
    theme = 'solarized',
    -- theme = 'selenized',
    disabled_filetypes = {
        'NvimTree',
    },
  },
}

Alternatively, to utilize Lualine's Solarized theme:

require('lualine').setup {
    options = {
      theme = require('lualine.themes.solarized')
    }
}

To use the Solarized theme showcased in the screenshot for Lualine click here

Barbecue

require('barbecue').setup {
  theme = 'solarized',
}

Api

Get Colors

---@type solarized.palette
local colors = {}

if vim.o.background == 'dark' then
   highlights = require 'solarized.highlights'
   local palette = require 'solarized.palette'
   colors = palette['solarized']
else
   highlights = require 'solarized.highlights.solarized-light'
   local palette = require 'solarized.palette.solarized-light'
   colors = palette['selenized']
end

Color utils

local color = require('solarized.utils.colors')

-- Convert a hex color code to RGB
color.hex_to_rgb('#ffffff')

-- Darken a color by a specified percentage
color.darken('#ffffff', 100)
color.shade('#ffffff', 10)

-- Lighten a color by a specified percentage
color.lighten('#000000', 100)
color.tint('#000000', 10)

-- Blend two colors with a specified ratio
color.blend('#ffffff', '#000000', 0.15)

Contributing

Pull requests are welcome and appreciated.

Designed by

Ethan Schoonover

Ethan Schoonover

Credits and Reference 🎉