DEV Community

uuta
uuta

Posted on

1

How to override the colors of NeoSolarized in NeoVim

Recently, I’d like to alter a theme with a new one in NeoVim. The onedarkpro is a fantastic theme that I’ve used for a long time, but it’s difficult to defeat the temptation to try out another theme like NeoSolarized.

https://user-images.githubusercontent.com/70003855/235333907-c064208a-3975-404d-874b-58e5c52ee5f0.png

First, I installed NeoSolarized.nvim via lazy.nvim, so the code would be simple like the following one.

return {
    {
        "Tsuzat/NeoSolarized.nvim",
        config = function()
            local neosolarized = require('NeoSolarized')
            neosolarized.setup {
                transparent = true,
            }
        end
    }
}

Enter fullscreen mode Exit fullscreen mode

But I wanted to customize it more.

Image description

There was no explicit description in README to modify styles, but referring theme.lua in NeoSolarized, colors can be overridden.

return {
    {
        "Tsuzat/NeoSolarized.nvim",
        config = function()
            -- https://github.com/Tsuzat/NeoSolarized.nvim/blob/208e65a3ede945b8a1d00104a4441217c5e23509/lua/NeoSolarized/theme.lua#L1-L11
            local neosolarized = require('NeoSolarized')
            local cls = require("NeoSolarized.colors")
            local config = require("NeoSolarized.config")
            local options = config.options
            local theme = {config = options, colors = cls.setup()}

            local c = theme.colors
            c.green = '#40f7d2'
            c.yellow = '#eaea8a'
            c.red = '#ea4481'
            c.blue = '#2bb3d8'
            c.fg0 = '#dde8d5'
            c.orange = '#dd9f4d'
            neosolarized.setup {
                transparent = true,
                -- https://github.com/Tsuzat/NeoSolarized.nvim/blob/208e65a3ede945b8a1d00104a4441217c5e23509/lua/NeoSolarized/theme.lua#L748
                styles = {
                    comments = {italic = false},
                    keywords = {italic = false, bold = true},
                    string = {italic = false}
                },
                on_highlights = function(highlights, colors)
                    -- highlights.Include.fg = colors.red -- Using `red` foreground for Includes
                end
            }
        end
    }
}
Enter fullscreen mode Exit fullscreen mode

Image description

Image of Datadog

How to Diagram Your Cloud Architecture

Cloud architecture diagrams provide critical visibility into the resources in your environment and how they’re connected. In our latest eBook, AWS Solution Architects Jason Mimick and James Wenzel walk through best practices on how to build effective and professional diagrams.

Download the Free eBook

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more