'Setting up onedark as a colorscheme in Vim?

I'm trying to set up my color scheme on vim using onedark

I've cloned the repository and ran the following commands:

$ git clone https://github.com/joshdick/onedark.vim.git ~/onedark
$ cd ~/onedark
$ mkdir ~/.vim/colors
$ cp colors/onedark.vim ~/.vim/colors/
$ cp autoload/onedark.vim ~/.vim/autoload/

My .vimrc contains a few settings and I added

syntax on
colorscheme onedark

But my editor still shows like this:

enter image description here

Am I missing something?



Solution 1:[1]

You need to put this to your vimrc:

" Turns on syntax highlighting
syntax on

if has('termguicolors')
    " Turns on true terminal colors
    let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
    let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"

    " Turns on 24-bit RGB color support
    set termguicolors

    " Defines how many colors should be used. (maximum: 256, minimum: 0)
    set t_Co=256
endif

set background=dark
colorscheme onedark

However, if you want Color scheme work well you have to install any syntax highlighter, such as (most popular):

  1. nvim-treesitter for NeoVim
  2. vim-polyglot for Vim.
  3. Or, you can configure tree-sitter manually for Vim.

Solution 2:[2]

If you use Vim in a terminal, you will also have to install the appropriate color scheme for your terminal. For example, if you use iTerm then you will have to download and install the One Dark.itermcolors color scheme.

I advice you to read the Troubleshooting section, as there may be other issues with your setup.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 runar