onedarkpro.nvim

repository·main·Indexed 22 days ago

https://github.com/olimorris/onedarkpro.nvim

A highly customizable Neovim colorscheme based on Atom's One Dark theme. It features full Tree-sitter and LSP semantic token support, automatic caching for performance, and extensive plugin integration. Includes multiple built-in themes such as Onedark, Onelight, Onedark Vivid, Onedark Dark, and Vaporwave. Requires Neovim 0.9.2 or higher.

Tokens
4.7K
Snippets
15
Records
20
Agent score
28%

What's inside onedarkpro.nvim

  1. Configure onedarkpro.nvim via setup()

    main

    Use require("onedarkpro").setup({...}) to customize the theme. You only need to call this function if you wish to change the default settings. The configuration object supports overriding colors, highlights, styles, filetypes, plugins, and options.

    require("onedarkpro").setup({
      colors = {},
      highlights = {},
      styles = {
        types = "NONE",
        -- ... other style keys
      },
      filetypes = {
        lua = true,
        -- ... other filetype keys
      },
      plugins = {
        nvim_lsp = true,
        -- ... other plugin keys
      },
      options = {
        cursorline = false,
        transparency = false,
        terminal_colors = true,
        lualine_transparency = false,
        highlight_inactive_windows = false,
      }
    })
  2. Install and use onedarkpro.nvim

    main

    Install onedarkpro.nvim using your preferred Neovim package manager. To apply the theme, execute the command colorscheme onedark in your configuration.

    -- Lazy
    {
      "olimorris/onedarkpro.nvim",
      priority = 1000, -- Ensure it loads first,
    }
    
    -- somewhere in your config:
    vim.cmd("colorscheme onedark")
    
    -- Packer
    use "olimorris/onedarkpro.nvim"
    
    -- somewhere in your config:
    vim.cmd("colorscheme onedark")
    
    -- Vim-Plug
    Plug "olimorris/onedarkpro.nvim"
    
    -- somewhere in your config:
    colorscheme onedark
  3. Requirements for onedarkpro.nvim

    main

    To ensure full functionality, the following requirements must be met:

    • Neovim 0.9.2 or higher
    • termguicolors enabled in Neovim for true color support
    • tree-sitter installed for full syntax highlighting
    • An LSP server that supports semantic tokens (for semantic token support)
  4. Define custom themes

    main

    You can create your own themes by defining a local file that implements the required theme structure and referencing it in your onedarkpro setup.

    -- In your main Neovim configuration:
    require("onedarkpro").setup({
      themes = {
        vaporwave = "~/.config/nvim/lua/plugins/colors/vaporwave.lua",
      },
    })
    vim.cmd([[colorscheme vaporwave]])
    
    -- In your custom theme file (~/.config/nvim/lua/plugins/colors/vaporwave.lua):
    require("onedarkpro.config").set_theme("vaporwave")
    require("onedarkpro").load()
  5. Configure filetype highlighting

    main

    The theme provides opinionated highlighting for many filetypes. You can enable or disable specific filetypes in the filetypes table. You can also use the all key to disable everything and then selectively enable specific ones.

    -- Disable specific filetypes
    require("onedarkpro").setup({
      filetypes = {
        markdown = false,
        ruby = false,
      }
    })
    
    -- Disable all filetypes
    require("onedarkpro").setup({
      filetypes = {
        all = false
      }
    })
    
    -- Disable all, then enable specific ones
    require("onedarkpro").setup({
      filetypes = {
        all = false,
        markdown = true,
        ruby = true,
      }
    })
    
    -- Add custom filetype highlights (e.g. Tree-sitter groups)
    require("onedarkpro").setup({
      highlights = {
        ["@field.yaml"] = { fg = "${blue}", italic = true }
      }
    })
  6. Configure colors and palettes

    main

    You can override default colors or create new ones in the colors table. New colors can be merged into the theme's palette and later referenced in highlight groups using the ${color_name} syntax.

    You can also specify colors based on a specific theme name or the theme's background type (dark or light).

    -- Override an existing color
    require("onedarkpro").setup({
      colors = {
        red = "#FF0000"
      }
    })
    
    -- Create a new color (can use helpers)
    require("onedarkpro").setup({
      colors = {
        my_new_red = "#f44336",
        my_new_green = "require('onedarkpro.helpers').darken('green', 10, 'onedark')"
      }
    })
    
    -- Reference new colors in highlights
    require("onedarkpro").setup({
      highlights = {
        Error = {
          fg = "${my_new_red}",
          bg = "${my_new_green}"
        }
      }
    })
    
    -- Specify colors by theme name
    require("onedarkpro").setup({
      colors = {
        onedark = { bg = "#FFFF00" },
        onelight = { bg = "#00FF00" }
      }
    })
    
    -- Specify colors by background type (dark/light)
    require("onedarkpro").setup({
      colors = {
        dark = { bg = "#FFFF00" },
        light = { bg = "#00FF00" }
      }
    })
  7. Configure theme options

    main

    Use the options table to toggle specific theme behaviors:

    • cursorline: Enables/disables cursorline highlighting.
    • transparency: Enables a transparent background for Normal, Folded, SignColumn, Statusline, and Tabline.
    • terminal_colors: If true, applies theme colors to Neovim's :terminal.
    • lualine_transparency: Controls center bar transparency.
    • highlight_inactive_windows: Changes the background of windows when they lose focus.
    -- Example: Enabling cursorline and transparency
    require("onedarkpro").setup({
      colors = {
        cursorline = "#FF0000"
      },
      options = {
        cursorline = true,
        transparency = true,
        terminal_colors = false,
        highlight_inactive_windows = true
      }
    })
  8. Configure highlight groups

    main

    Customize or override highlight groups in the highlights table. You can use hex colors, reference palette colors with ${name}, link to other groups using link, or extend existing groups using extend = true.

    -- Using hex and styles
    require("onedarkpro").setup({
      highlights = {
        Comment = { fg = "#FF0000", bg = "#FFFF00", italic = true }
      }
    })
    
    -- Referencing palette colors
    require("onedarkpro").setup({
      highlights = {
        Comment = { fg = "${my_new_red}", bg = "${yellow}", italic = true }
      }
    })
    
    -- Linking to other groups
    require("onedarkpro").setup({
      highlights = {
        Comment = { link = "Substitute" }
      }
    })
    
    -- Extending existing groups
    require("onedarkpro").setup({
      highlights = {
        Comment = { underline = true, extend = true }
      }
    })
    
    -- Creating new groups or disabling existing ones (e.g. LSP semantic tokens)
    require("onedarkpro").setup({
      highlights = {
        MyNewHighlightGroup = { fg = "${red}" },
        ["@lsp.type.comment"] = {}
      }
    })
    
    -- Using namespaces (ns_id)
    require("onedarkpro").setup({
      highlights = {
        Comment = { ns_id = 1, fg = "${light_gray}" }
      }
    })
  9. Configure plugin highlighting

    main

    The theme includes support for various plugins. You can enable or disable these highlight groups in the plugins table. You can also disable all plugin highlights at once using all = false.

    -- Disable specific plugins
    require("onedarkpro").setup({
      plugins = {
        nvim_lsp = false,
        polygot = false,
        treesitter = false
      }
    })
    
    -- Disable all plugins
    require("onedarkpro").setup({
      plugins = {
        all = false
      }
    })
    
    -- Disable all, then enable specific ones
    require("onedarkpro").setup({
      plugins = {
        all = false,
        nvim_lsp = true,
        treesitter = true
      }
    })
  10. Override or add custom colors

    main

    You can modify the existing color palette or introduce new colors by providing a colors table in your configuration.

    • To override an existing core color, use its name (e.g., red) as the key and provide a new hex code.
    • To add a new color to the palette, provide a new name (e.g., my_new_red) and a hex code. These custom colors can then be referenced when creating custom highlight group overrides.
    colors = {
      -- Overriding an existing color
      red = "#FF0000",
      
      -- Creating a new custom color
      my_new_red = "#f44336"
    }