Shougo / dpp.vim

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

Fails to load a state file when an `on_cmd` entry contains any wildcard #12

Closed hasundue closed 9 months ago

hasundue commented 9 months ago

Problems summary

When I add a plugin with an on_cmd entry including a wildcard like 'Floaterm*', the plugin manager fails to load a state file with dpp#min#load_state.

Expected

Vim launches without any error.

Environment Information

deno 1.38.0 (release, x86_64-unknown-linux-gnu)
v8 12.0.267.1
typescript 5.2.2
hasundue@x1carbon ~> hostnamectl
...
Operating System: NixOS 23.11 (Tapir)
          Kernel: Linux 6.1.62
    Architecture: x86-64
...
hasundue@x1carbon ~> vim --version
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Jan 01 1980 00:00:00)
Included patches: 1-2048
...

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

.vimrc

set nocompatible

const s:cache = expand('~/.cache')
const s:dpp_base = s:cache .. '/dpp'

if !(s:dpp_base->isdirectory())
  call mkdir(s:dpp_base, 'p')
endif

function s:add(plugin)
  const dir = s:dpp_base.. '/repos/github.com/' .. a:plugin

  if !(dir->isdirectory())
    execute '!git clone https://github.com/' .. a:plugin dir
  endif

  execute 'set runtimepath^='
        \ .. dir->fnamemodify(':p')->substitute('[/\\]$', '', '')
endfunction

call s:add('Shougo/dpp.vim')
call s:add('Shougo/dpp-ext-lazy')

const s:dpp_name = has('nvim') ? 'nvim' : 'vim'
const s:dpp_state = s:dpp_base .. '/' .. s:dpp_name .. '/state.vim'

if dpp#min#load_state(s:dpp_base, s:dpp_name)
  echomsg '[dpp] Creating ' .. s:dpp_state .. '...'

  call s:add('vim-denops/denops.vim')
  runtime! plugin/denops.vim

  autocmd User DenopsReady
    \ call dpp#make_state(s:dpp_base, '~/.vim/rc/dpp/config.ts')

  autocmd User Dpp:makeStatePost
    \ echomsg '[dpp] Created ' .. s:dpp_state
else
  echomsg '[dpp] Loaded ' .. s:dpp_state
endif

~/.vim/rc/dpp/config.ts

import { exists } from "https://deno.land/std@0.207.0/fs/exists.ts";
import {
  BaseConfig,
  ConfigArguments,
  Plugin,
} from "https://deno.land/x/dpp_vim@v0.0.7/types.ts";

interface LazyMakeStateResult {
  plugins: Plugin[];
  stateLines: string[];
}

export class Config extends BaseConfig {
  override async config(args: ConfigArguments) {
    const [context, options] = await args.contextBuilder.get(args.denops);

    const plugins = [
      {
        name: "vim-floaterm",
        repo: "voldikss/vim-floaterm",
        path: args.basePath + "/repos/github.com/voldikss/vim-floaterm",
        on_cmd: ["Floaterm*"],
      },
    ];

    for (const plugin of plugins) {
      if (await exists(plugin.path) === false) {
        await new Deno.Command("git", {
          args: ["clone", `https://github.com/${plugin.repo}`, plugin.path],
        }).output();
      }
    }

    const state = await args.dpp.extAction(
      args.denops,
      context,
      options,
      "lazy",
      "makeState",
      { plugins },
    ) as LazyMakeStateResult;

    return {
      plugins: state.plugins,
      stateLines: state.stateLines,
    };
  }
}

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

  1. Make sure to clear the existing state (e.g. rm -rf ~/.cache/dpp/vim)
  2. Launch Vim to create a state (this succeeds)
  3. Exit Vim
  4. Re-launch Vim

Screenshot (if possible)

Upload the log messages by :redir and :message (if errored)

:message

[dpp] Loading state error: Vim(command):E182: Invalid command name
[dpp] Creating /home/hasundue/.cache/dpp/vim/state.vim...
[dpp] Created /home/hasundue/.cache/dpp/vim/state.vim
Press ENTER or type command to continue
Shougo commented 9 months ago

This is dpp-ext-lazy's issue instead.

hasundue commented 9 months ago

Sorry, recreated: https://github.com/Shougo/dpp-ext-lazy/issues/4