GithubHelp home page GithubHelp logo

navarasu / onedark.nvim Goto Github PK

View Code? Open in Web Editor NEW
1.4K 11.0 146.0 183 KB

One dark and light colorscheme for neovim >= 0.5.0 written in lua based on Atom's One Dark and Light theme. Additionally, it comes with 5 color variant styles

License: MIT License

Lua 100.00%
neovim treesitter dark-theme neovim-theme lua nvim vim onedark theme

onedark.nvim's Introduction

Dark and Light Themes for neovim >= 0.5 based on Atom One Dark & Atom One Light theme written in lua with TreeSitter syntax highlight.

For Vim / Neovim < 0.5, prefer joshdick/onedark.vim

For latest TreeSitter syntax highlight, upgraded to Neovim 0.8.0 or later built with tree-sitter 0.20.3+

Features

  • 8 theme styles (One Dark + 5 variants) and (One Light + 1 variant)
  • Supporting multiple plugins with hand picked proper colors
  • Customize Colors, Highlights and Code style of the theme as you like (Refer Customization)
  • Toggle the theme style without exiting Neovim using toggle_style_key (Refer Config)

Themes

Onedark - dark Onedark - darker

Onedark - cool Onedark - deep

Onedark - warm Onedark - warmer

Installation

Install via your favourite package manager

" Using Vim-Plug
Plug 'navarasu/onedark.nvim'
-- Using Packer
use 'navarasu/onedark.nvim'

Configuration

Enable theme

-- Lua
require('onedark').load()
" Vim
colorscheme onedark

Change default style

-- Lua
require('onedark').setup {
    style = 'darker'
}
require('onedark').load()
" Vim
let g:onedark_config = {
    \ 'style': 'darker',
\}
colorscheme onedark

Options: dark, darker, cool, deep, warm, warmer, light

Default Configuration

-- Lua
require('onedark').setup  {
    -- Main options --
    style = 'dark', -- Default theme style. Choose between 'dark', 'darker', 'cool', 'deep', 'warm', 'warmer' and 'light'
    transparent = false,  -- Show/hide background
    term_colors = true, -- Change terminal color as per the selected theme style
    ending_tildes = false, -- Show the end-of-buffer tildes. By default they are hidden
    cmp_itemkind_reverse = false, -- reverse item kind highlights in cmp menu

    -- toggle theme style ---
    toggle_style_key = nil, -- keybind to toggle theme style. Leave it nil to disable it, or set it to a string, for example "<leader>ts"
    toggle_style_list = {'dark', 'darker', 'cool', 'deep', 'warm', 'warmer', 'light'}, -- List of styles to toggle between

    -- Change code style ---
    -- Options are italic, bold, underline, none
    -- You can configure multiple style with comma separated, For e.g., keywords = 'italic,bold'
    code_style = {
        comments = 'italic',
        keywords = 'none',
        functions = 'none',
        strings = 'none',
        variables = 'none'
    },

    -- Lualine options --
    lualine = {
        transparent = false, -- lualine center bar transparency
    },

    -- Custom Highlights --
    colors = {}, -- Override default colors
    highlights = {}, -- Override highlight groups

    -- Plugins Config --
    diagnostics = {
        darker = true, -- darker colors for diagnostic
        undercurl = true,   -- use undercurl instead of underline for diagnostics
        background = true,    -- use background color for virtual text
    },
}

Vimscript configuration

Onedark can be configured also with Vimscript, using the global dictionary g:onedark_config. NOTE: when setting boolean values use v:true and v:false instead of 0 and 1

Example:

let g:onedark_config = {
  \ 'style': 'deep',
  \ 'toggle_style_key': '<leader>ts',
  \ 'ending_tildes': v:true,
  \ 'diagnostics': {
    \ 'darker': v:false,
    \ 'background': v:false,
  \ },
\ }
colorscheme onedark

Customization

Example custom colors and Highlights config

require('onedark').setup {
  colors = {
    bright_orange = "#ff8800",    -- define a new color
    green = '#00ffaa',            -- redefine an existing color
  },
  highlights = {
    ["@keyword"] = {fg = '$green'},
    ["@string"] = {fg = '$bright_orange', bg = '#00ff00', fmt = 'bold'},
    ["@function"] = {fg = '#0000ff', sp = '$cyan', fmt = 'underline,italic'},
    ["@function.builtin"] = {fg = '#0059ff'}
  }
}

Note that TreeSitter keywords have been changed after neovim version 0.8 and onwards. TS prefix is trimmed and lowercase words should be used separated with '.'

The old way before neovim 0.8 looks like this. For all keywords see this file from line 133 to 257

require('onedark').setup {
  colors = {
    bright_orange = "#ff8800",    -- define a new color
    green = '#00ffaa',            -- redefine an existing color
  },
  highlights = {
    TSKeyword = {fg = '$green'},
    TSString = {fg = '$bright_orange', bg = '#00ff00', fmt = 'bold'},
    TSFunction = {fg = '#0000ff', sp = '$cyan', fmt = 'underline,italic'},
    TSFuncBuiltin = {fg = '#0059ff'}
  }
}

Plugins Configuration

Enable lualine

To Enable the onedark theme for Lualine, specify theme as onedark:

require('lualine').setup {
  options = {
    theme = 'onedark'
    -- ... your lualine config
  }
}

Plugins Supported

Reference

Contributing

Pull requests are welcome 🎉👍.

License

MIT

onedark.nvim's People

Contributors

aymanbagabas avatar baco-ceg avatar black-desk avatar c373 avatar chomosuke avatar classabbyamp avatar cljoly avatar d0ot avatar dav-cho avatar doctoromer avatar flleonx avatar hezhizhen avatar jackm245 avatar julpikar avatar matthewgrossman avatar matthewswitzer avatar mchekardov avatar mfauzaan avatar navarasu avatar neylix avatar programfan avatar ribru17 avatar rubixdev avatar scallaway-uipath avatar schardev avatar taketwo avatar tinusgraglin avatar utilyre avatar vpavliashvili avatar xeluxee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

onedark.nvim's Issues

don't enable theme at setup

I think its better to provide an api like onedark.load() rather than enable the theme at require('onedark').setup(). Other colorschemes don't typically load the colorscheme at setup(), I think its best if onedark can behave similarly too.

Strange color SCSS

I don't understand why i didn't have the same color :
Vscode One Dark Pro SCSS:
image

onedark nvim :
image

I use neovim v0.6.1
Lastest Treesitter and onedark.nvim (no custom config)

Could you help me please ?

Gdiffsplit colours in light style are "a bit off" ;)

Thanks for that beautiful colour scheme! The cool style is my absolute favourite at the moment :)
The light is a different story though. At first sight it looks nice but if I invoke Gdiffsplit it's quite a difference ...
A screenshot says much more in this case I guess:
scrot-2022-02-24-10:52

transparent = false does not work

The following config does not disable transparency

require('onedark').setup({
    style = 'darker',
    transparent = false,
})

However the deprecated option does turn off transparency.

vim.g.onedark_style = 'darker'

Invalid configuration: Unknown function onedark#GetColors

Hello... I cannot for the life of me figure out what the issue is. I know (and honestly hope) that this is an incredibly stupid error on my part. Would very much appreciate any advice you can give :)

"Invalid configuration: ...site/pack/packer/start/onedark.nvim/lua/onedark/init.lua:95: Vim(let):E117: Unknown function: onedark#GetColors" file="init.lua",

Very minor typo in README

There is a minor typo here: Default Configuration
I was wondering why comment = "none" (under code_style) does not work. It turns out that it should be comments, I had to look at the source code to figure this one out 😂

Disabling italics does not apply to all languages

Thanks for this project.

I want to disable italics but it is not working. Steps to repro:

  1. Create a minimal config init.vim:
call plug#begin('~/.config/nvim/plugged') " change here to your plugins folder
    Plug 'navarasu/onedark.nvim'
call plug#end()

" This is a comment
" Note how italic font appears even though I have disable it

let g:onedark_italic_comment = 0
colorscheme onedark
  1. Execute nvim -u init.vim init.vim (open init.vim with minimal config)
  2. You should see the comments in italic

This is happening with Cascadia Code font (https://github.com/microsoft/cascadia-code).

Note that for JetBrains Mono for example this does not happen.

Change cursorline highlight color

When using the cursorline option in vim, the background color of the current cursor line is the same of visual selection background color.

style option doesn't work

I changed the default theme to 'light', but it doesn't when I reopen nvim, it always chooses the 'dark' as the default.
I can switch theme through the 'toggle style key ts'

image

Is there any way to debug/fix this?

Doesn't work with neo vim

E5105: Error while calling lua chunk: [string ""]:5: attempt to index field 'g' (a nil value)

Neovim

Provide a theme for vim-airline?

onedark.nvim does not provide any theme for vim-airline. Switching to this theme makes airline stick to the default themes and it looks ugly.

Support for bold text (such as for function names)

Hi there! Thank you so much for this theme!

I was wondering, would it be possible to add support for bold text? For example, to have method names in bold.

Thanks again!

Here's an example from a one dark theme for VS Code:

image

Override Colors on Per Theme Basis

Thanks for this plug. It works really well. Is there a way to override colors on a per-theme basis?

Example: I'd like to override bg1 but only on the dark theme and leave the light theme as default.

require("onedark").setup({
    style = "dark",
    toggle_style_list = { "dark", "light" },
    colors = {
        bg0 = (vim.g.onedark_config.style == "dark") and "#1a1c23" or "#fafafa",
    },
}

This obviously doesn't work because setup configs are only evaluated upon initialization. But some way to do this would be nice.

Thanks!

Correct way to enable the theme in Lua

I'm calling require'onedark'.setup() to enable the colorscheme, as said in the docs, but I'm experiencing some broken highlights and missing colors. That doesn't happen when I call colorscheme onedark instead. Am I doing something wrong?

FWIW, I use Packer as my plugin manager:

init.lua

require'packer'.startup(function(use)
...
  use {'navarasu/onedark.nvim', config = 'require"plugins/onedark"'}
})

plugins/onedark.lua

local g = vim.g
g.onedark_style = 'dark'
g.onedark_disable_toggle_style = 1
g.onedark_italic_comment = false
g.onedark_darker_diagnostics = false
require'onedark'.setup()

Variable and parameters are off-colour

OS: macOS Big Sur 11.4
nvim: 0.5.0
terminal: Alacritty 0.8.0

The issue is not with your plugin. Many thanks for your effort in creating this updated theme.

Disable italic comments not found

Good morning, I'm having trouble changing the settings to disable italicized comments on nvim running on termux

  • When I ran this piece of code
" Theme:
" A comment...
let g:onedark_style = 'darker'
let g:onedark_italic_comment = 0
colorscheme onedark
Neovim Version
NVIM v0.5.1
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: /home/builder/.termux-build/_cache/android-r21d-api-24-v5/bin/clang -march=armv7-a -mfpu=neon -mfloat-abi=softfp -mthumb -fstack-protector-strong -Oz --target=armv7a-linux-androideabi24 -I/data/data/com.termux/files/usr/include -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/builder/.termux-build/neovim/build/config -I/home/builder/.termux-build/neovim/src/src -I/data/data/com.termux/files/usr/include -I/home/builder/.termux-build/neovim/build/src/nvim/auto -I/home/builder/.termux-build/neovim/build/include
Compiled by builder@1ebcb695cc80

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/data/data/com.termux/files/usr/share/nvim"

Run :checkhealth for more info
Screenshot

Screenshot_Termux

Toggle transparent property

Hi, first of all, thank you for this amazing theme 🍺

I have a function to toggle transparency.

function M.toggle_transparency()
  vim.g.onedark_transparent_background = not vim.g.onedark_transparent_background
  vim.cmd[[colorscheme onedark]]
end

This global propertyonedark_transparent_background has present in ce49cf3.

I tried with require('onedark').set_options('transparent', true) but with no success.

My question is, how can I achieve this behavior in new version?

Error while calling lua chunk

Hi there 👋 !
Not sure if it's related with the theme but I have the following error after source my config:
E5105: Error while calling lua chunk: ...s/.config/nvim/plugged/onedark.nvim/lua/onedark/init.lua:2: attempt to index field 'g' (a nil value)

My only plugin is ondark.vim:

call plug#begin('~/.config/nvim/plugged')
Plug 'navarasu/onedark.nvim'
call plug#end()

Thanks in advance if you think this is related

LspReference background colors do not toggle.

Hi, thanks for your great color schemes!

I am tweaking some settings for the LSP reference highlights as I prefer a subtle background over an underline. My relevant setup is as follows:

require("onedark").setup({
    highlights = {
        LspReferenceText = { fmt = "none", bg = "$bg2" },
        LspReferenceWrite = { fmt = "none", bg = "$bg2" },
        LspReferenceRead = { fmt = "none", bg = "$bg2" },
    },
})

Now when I switch from dark to light (or vice versa) by either toggling or using :set bg=light, the LspReference* highlights keep the previous background, e.g. after switching from warmer to light:
image

After sourcing the config manually, the correct backgrounds are set. Not a big issue to me, but I thought I'd let you know anyway.

Using custom colors not working

Hello 👋🏼

I'm trying to customize the colorschem. However, I cannot create custom colors, as when nvim is opened, it shows: onedark.nvim: unknown colors "<custom color name>".

I have also tried using the default config, given in the README, yet it does still not work:

require('onedark').setup {
  colors = {
    bright_orange = "#ff8800",    -- define a new color
    green = '#00ffaa',            -- redefine an existing color
  },
  highlights = {
    TSKeyword = {fg = '$green'},
    TSString = {fg = '$bright_orange', bg = '#00ff00', fmt = 'bold'},
    TSFunction = {fg = '#0000ff', sp = '$cyan', fmt = 'underline,italic'},
  }
}

-- It returns onedark.nvim: unknown color "bright_orange"

How can I solve such issue or provide anything to help debug this issue?

Italic comment doesn't work

Screenshot:
Screenshot from 2021-08-19 21-31-55

My neovim configuration:

vim.g.onedark_transparent_background = true;
require('onedark').setup();

Overriding terminal cursor color

I'm not sure if this is intended or something specific to my configuration, but both the cursor and search highlight color (i.e. matches on a / command) are a pale yellow. They are not exactly the same, but they are close enough to make it quite difficult to identify the cursor location when iterating through search results.

I'm not doing much else that I'd think would interact with the colorscheme, just setting termguicolors.

If this is intended, is there a recommended way to adjust the cursor color to something else otherwise consistent with the theme? If it is not normal behavior, how could I go about debugging or fixing this issue?

Changing the option changes nothing

Hey! I'm new to nvim and a fan of One Dark theme, so I have decided to install this theme. I like it, but I can't switch to other options, because changes in ~/.config/nvim/init.vim do nothing. Please, help, what might be wrong? My config:

 call plug#begin()
 Plug 'navarasu/onedark.nvim'
 call plug#end()

  let g:onedark_config = {
     \ 'style': 'deep',
 \}
 colorscheme onedark

My nvim is 0.7.0.

comments in python are not italicised

First off, super well done on the many variations!

One thing I seem to be missing is the ability to display comments (in python) in italics --a common style. Am I missing a config option? I'm not super able to understand how the code works but I do see mentions of italics so I have a feeling it's something that's maybe there.

Let me know if you need more info

Terminal Color

Hi I'm using ubuntu terminal and zsh. zsh provides suggestions when changing paths or entering commands based on the history. These are barely readable in the neovim terminal
I've changed the color for terminal_color_8 from black to grey in terminal.lua
vim.g.terminal_color_8 = c.grey
Now the terminal in neovim behaves the same as the native terminal.

I'm unsure if this is a change to be done generally or if I shall do it locally in my config.

Showcase

terminal_color_8 = c.black
onedark_terminal_8_black
terminal_color_8 = c.grey
original_behaviour_and_terminal_8_grey

vim config

Do you mind sharing your .vimrc/init.vm? I am interested in your highlighting setting, directory tree and status line.
FYI, I just started using neovim

Slightly changed colors in the terminal

Hi, recently I've tried to switch to neovims builtin terminal, but I've noticed that the colors are a bit different than in the terminal outside the neovim. Is there a way to easily override colors in the console, or get corresponding elements Highlight groups?

Outside:
image

Neovims terminal:
image

autocmd group 'colorscheme' is not triggered when using lua to initialize onedark

When using lua to configure onedark with require("onedark").setup() as recommended in the README, I noticed that icons from nvim-web-devicons were never colored, due to their highlight groups being cleared. As far as I know, the icons plugin sets its highlights in an augroup ColorScheme callback to be able to reconfigure highlights based on the specific colorscheme (light / dark).

The problem can be fixed by additionally calling vim.cmd "colorscheme onedark" immediately after running the setup function. My suspicion is that neovim's internal colorscheme command correctly triggers these augroups, while onedarks setup function doesn't. I'm not familiar enough with how colorschemes work internally to suggest a better way of handling things, or whether it is even desirable to completely skip the colorscheme command in lua based configurations. I suppose this has to be fixed in onedark's setup function, or at least hinted at in the README.

Cannot disable italic for comments

Hello,

After #42 was merged, I've tried disabling italic for comments like so:

-- init.lua

require 'paq' {
  {'navarasu/onedark.nvim'},
}

require('onedark').setup {
  code_style = {comments = 'none'},
}

vim.opt.termguicolors = true
vim.cmd 'colorscheme onedark'

But nothing happens, comments are still in italic. Using the old config way works though. @xeluxee maybe you'll be interested in this.

`setup()` refactoring

Hi
I think we should improve setup function to let users configure the entire plugin with it, using a config dictionary as argument
However, since the plugin should be configurable trough vimscript too, I think we could do keep a dictionary called g:onedark_setup, to be configured before calling the setup function.
All options would then be moved under this dictionary, except for onedark_style
Also custom highlights should be added as a setup option, solving issues #35, maybe #33, #23, maybe #17 and #12

@navarasu if you agree with these changes or you have some suggestion let me know, so I'll make a PR

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.