Skip to content

Commit

Permalink
fix(nvim): load colorscheme after sourcing .project.vim
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangyinzuo committed Apr 8, 2024
1 parent 8359e8c commit b470048
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
3 changes: 2 additions & 1 deletion root/.config/nvim/lazy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ if not vim.loop.fs_stat(lazypath) then
end
vim.opt.rtp:prepend(lazypath)

vim.g.project_load_post_hook = { ':lua require("plugins_setup").vimrc_load_colorscheme()' }

-- https://gist.github.com/BlueDrink9/474b150c44d41b80934990c0acfb00be
require("lazy").setup("plugins", {
root = vim.g.vim_plug_dir,
Expand All @@ -30,4 +32,3 @@ require("lazy").setup("plugins", {
vim.cmd[[set packpath+=~/.vim]]

-- load colorscheme at the end to avoid black background on startup
require("plugins_setup").colorscheme()
22 changes: 16 additions & 6 deletions root/.config/nvim/lua/plugins_setup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,23 @@ function M.auto_session()
require('auto-session').setup(opts)
end

local colorscheme_loaded = false
function M.colorscheme()
-- make winbar background transparent
vim.cmd([[
set termguicolors
colorscheme solarized
hi WinBar guibg=NONE
]])
if not colorscheme_loaded then
-- make winbar background transparent
vim.cmd([[
set termguicolors
colorscheme solarized
hi WinBar guibg=NONE
]])
colorscheme_loaded = true
end
end

function M.vimrc_load_colorscheme()
if vim.g.vimrc_load_colorscheme == nil or vim.g.vimrc_load_colorscheme then
M.colorscheme()
end
end

return M
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ augroup END

let g:project_vimrc = get(g:, 'project_vimrc', '.project.vim')
call LoadProjectConfigEachTab()

if exists('g:project_load_post_hook')
for hook in g:project_load_post_hook
execute hook
endfor
endif
2 changes: 1 addition & 1 deletion root/.vim/vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ if has('autocmd') " vim-tiny does not have autocmd

let g:project_vimrc = '.project.vim'
" do not add too much root marks, it will slow down search performance
let g:RootMarks = ['.git', g:project_vimrc, '.root']
let g:RootMarks = ['.git', g:project_vimrc, '.root', '.noterepo', '.coderepo']

" vimplug.vim 可能会改变g:no_plug的值
let g:no_plug = (glob(g:vim_plug_dir) == "") || &loadplugins == 0
Expand Down

0 comments on commit b470048

Please sign in to comment.