Shougo / dpp.vim

Dark powered plugin manager for Vim/neovim
MIT License
128 stars 5 forks source link

The plugin will not be reflected unless you start it twice #8

Closed nabezokodaikon closed 10 months ago

nabezokodaikon commented 10 months ago

Warning: I will close the issue without the minimal init.vim and the reproduction instructions.

Problems summary

After installing dpp.vim, the plugin will not be reflected unless you start it twice by following the steps below from the first start.

Expected

After installing the plugin, restart neovim and the plugin will be reflected.

Environment Information

Provide a minimal init.vim/vimrc without plugin managers (Required!)

directory structure

~/.config
└── nvim
    ├── dpp.toml
    ├── dpp.ts
    └── init.lua

init.lua

vim.cmd('syntax off')
vim.cmd('filetype off')
vim.cmd('filetype plugin indent off')

local dpp_base = vim.env.HOME .. '/.cache/dpp'
local dpp_repo = dpp_base .. '/repos'

local dpp_src = dpp_repo .. '/github.com/Shougo/dpp.vim'
local denops_src = dpp_repo .. '/github.com/vim-denops/denops.vim'

vim.opt.runtimepath:prepend(dpp_src)

if vim.fn.isdirectory(dpp_src) ~= 1 then
  os.execute('git clone https://github.com/Shougo/dpp.vim ' .. dpp_src)
end

if vim.fn.isdirectory(denops_src) ~= 1 then
  os.execute('git clone https://github.com/vim-denops/denops.vim ' .. denops_src)
end

local plugins = {
  'Shougo/dpp-ext-installer',
  'Shougo/dpp-ext-local',
  'Shougo/dpp-ext-lazy',
  'Shougo/dpp-ext-toml',
  'Shougo/dpp-protocol-git',
}

for k, v in pairs(plugins) do
  local url = 'https://github.com/' .. v
  local repo = dpp_repo .. '/github.com/' .. v 
  vim.opt.runtimepath:append(repo)
  if vim.fn.isdirectory(repo) ~= 1 then
    os.execute('git clone ' .. url .. ' ' .. repo)
  end
end

if vim.call('dpp#min#load_state', dpp_base) then
  vim.opt.runtimepath:prepend(denops_src)
  vim.api.nvim_create_autocmd('User', {
    pattern = 'DenopsReady',
    callback = function()
      vim.call('dpp#make_state', dpp_base, '~/.config/nvim/dpp.ts')
    end,
  })
end

vim.o.background = 'dark'
vim.cmd('colorscheme gruvbox')

vim.cmd('syntax on')
vim.cmd('filetype on')
vim.cmd('filetype plugin indent on')

dpp.ts

import {
  BaseConfig,
  ContextBuilder,
  Dpp,
  Plugin,
} from "https://deno.land/x/dpp_vim@v0.0.7/types.ts";
import {
  Denops,
} from "https://deno.land/x/dpp_vim@v0.0.7/deps.ts";

export class Config extends BaseConfig {
  override async config(args: {
    denops: Denops;
    contextBuilder: ContextBuilder;
    basePath: string;
    dpp: Dpp;
  }): Promise<{
    plugins: Plugin[];
    stateLines: string[];
  }> {

    type Toml = {
      plugins: Plugin[];
    };

    type LazyMakeStateResult = {
      plugins: Plugin[];
      stateLines: string[];
    };

    args.contextBuilder.setGlobal({
      protocols: ["git"],
    });

    const [context, options] = await args.contextBuilder.get(args.denops);

    const tomls: Toml[] = [];

    tomls.push(
      await args.dpp.extAction(
        args.denops,
        context,
        options,
        "toml",
        "load",
        {
          path: `~/.config/nvim/dpp.toml`,
          options: {
            lazy: false,
          },
        },
      ) as Toml,
    );

    const recordPlugins: Record<string, Plugin> = {};

    tomls.forEach((toml) => {
      for (const plugin of toml.plugins) {
        recordPlugins[plugin.name] = plugin;
      }
    });

    const lazyResult = await args.dpp.extAction(
      args.denops,
      context,
      options,
      "lazy",
      "makeState",
      {
        plugins: Object.values(recordPlugins),
      },
    ) as LazyMakeStateResult;

    return {
      plugins: lazyResult.plugins,
      stateLines: lazyResult.stateLines,
    };
  }
}
[[plugins]]
repo = 'ellisonleao/gruvbox.nvim'

How to reproduce the problem from neovim/Vim startup (Required!)

  1. $ nvim (start neovim)
  2. :call dpp#async_ext_action('installer', 'install') (install plugin)
  3. :q (quit neovim)
  4. $nvim (start neovim again)
  5. Plugins are not reflected. (The sample code does not reflect the color scheme.) Furthermore, restart neovim and the plugin will be reflected.
Shougo commented 10 months ago

I will fix it later.

Shougo commented 10 months ago

Fixed. Please update.

nabezokodaikon commented 10 months ago

Confirmed. Thank you.