Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theme doesn't load on startup #117

Open
faraazahmad opened this issue Nov 17, 2021 · 5 comments
Open

Theme doesn't load on startup #117

faraazahmad opened this issue Nov 17, 2021 · 5 comments

Comments

@faraazahmad
Copy link

I'm using Lua and Packer to setup my Neovim 0.5. The theme installs and works great but when I launch nvim it gives this error

Vim(colorscheme):E185: Cannot find color scheme 'onehalfdark'

the weird thing is that the theme loads when I do :source $MYVIMRC

At first I thought it was because the scheme was being set before packer can load it (#104) but that solution didn't work for me. Now I think it has something to do with my runtimepath.

Here's my config

init.lua

local cmd = vim.cmd
local opt = vim.opt

require('plugins')

-- set editor options
opt.termguicolors = true
-- opt.number = true
opt.smartindent = true
opt.tabstop = 4
opt.shiftwidth = 4

-- treesitter config
local ts = require('nvim-treesitter.configs')
ts.setup { ensure_installed = 'maintained', highlight = { enable = true }}

-- personalisation
cmd [[syntax on]]
cmd [[set t_Co=256]]
cmd [[set cursorline]]
cmd [[colorscheme onehalfdark]]

lua/plugins.lua

local fn = vim.fn
local cmd = vim.cmd


-- install packer if not present
local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if fn.empty(fn.glob(install_path)) > 0 then
    packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
end

cmd([[
  augroup packer_user_config
    autocmd!
    autocmd BufWritePost plugins.lua source <afile> | PackerCompile
  augroup end
]])

-- set up packer package manager
return require('packer').startup(function(use)
    -- packer can manager itself
    use { 'wbthomason/packer.nvim' }

    -- fzf with preview window
    -- use {'junegunn/fzf', dir = '~/.fzf', run = './install --all' }
    --use {'junegunn/fzf.vim'}

    -- treesitter
    use { 'nvim-treesitter/nvim-treesitter', run = ':TSUpdate' }

    -- themes
    use { 'morhetz/gruvbox' }
    use { 'sonph/onehalf', rtp = 'vim'}

    if packer_bootstrap then
        require('packer').sync()
    end
end)
@faraazahmad
Copy link
Author

PS: I dont get this issue when I keep everything the same but set gruvbox as colorscheme instead of onehalfdark. which is why I think runtimepath could be an issue

@zorgick
Copy link

zorgick commented Jan 15, 2022

@faraazahmad unfortunately this theme cannot be used in lua config, because 'rtp' option in packer will make it look for onehalf/vim/?.lua or onehalf/vim/init.lua. This is just how lua language works. I really like this theme, but without an entry point for lua interpreter it won't work. Plus, I doubt that this theme supports treesitter

@zorgick
Copy link

zorgick commented Jan 15, 2022

@faraazahmad you can check the alternative though, please write back, if you have any success with it https://github.com/CodeGradox/onehalf-lush

@zorgick
Copy link

zorgick commented Jan 30, 2022

@faraazahmad I tried the suggested to you theme, I can 100% say that it is robust. I compared it to a popular dracula theme, that some developers of treesitter use. Onehalf-lush gave me more clear syntax in tsx and typescript files. It was clear from far away what is html element, what is React Component, what is method call, what is constant, what is Type, what are JS keywords and operators. With the limited colorset of the onehalf theme I consider onehalf-lush theme do be a very good plugin

Treesitter config:

    ensure_installed = {
      "javascript",
      "typescript",
      "tsx",
      "lua",
    },
    highlight = {
      enable = true,
      additional_vim_regex_highlighting = false,
    },

@fabius
Copy link

fabius commented Mar 23, 2022

As a workaround, you run can leverage packer's config stanza

use {
    "sonph/onehalf",
    rtp = "vim/",
    config = function() vim.cmd("colorscheme onehalflight") end
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants