Shougo / dpp.vim

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

denops managed by dpp is not loaded with a state file created #17

Closed kenji0923 closed 7 months ago

kenji0923 commented 7 months ago

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

Problems summary

I configure that denops is managed by dpp. After an initial launch of vim, cache and state files are created with the former (cache.vim) including something about denops, but in the next launch of vim, in which dpp#min#load_state() returns 0, denops is not loaded. denops seems to be not cached in s:dpp_base/Vim/.dpp. Thank you in advance, and for creating many highly flexible plugins.

Expected

denops is loaded by dpp with the cached state file.

Environment Information

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

" My minimal init.vim/vimrc
set nocompatible

" dpp

const s:dpp_config = '~/.config/vim/dpp.ts'

" Set dpp base path (required)
const s:dpp_base = '~/.cache/dpp/'

" Set dpp source path (required)
const s:denops_repo = 'vim-denops/denops.vim'
const s:dpp_repo = 'Shougo/dpp.vim'

const s:dpp_addon = [
            \ 'Shougo/dpp-protocol-git',
            \ 'Shougo/dpp-ext-toml'
            \ ]

const s:dpp_manual_repo = [
            \ s:denops_repo,
            \ s:dpp_repo,
            \ ]

const s:dpp_manual_repo_source_url = 'github.com/'

const s:denops_src = s:dpp_base . s:dpp_manual_repo_source_url . s:denops_repo
const s:dpp_src = s:dpp_base . s:dpp_manual_repo_source_url . s:dpp_repo

for repositry in (s:dpp_manual_repo + s:dpp_addon)
    if ! isdirectory(s:dpp_base . s:dpp_manual_repo_source_url . repositry)
        call mkdir(expand(s:dpp_base . s:dpp_manual_repo_source_url), "p")
        call system('git clone https://' . s:dpp_manual_repo_source_url . repositry . ' ' . s:dpp_base . s:dpp_manual_repo_source_url . repositry)
    endif
endfor

" Set dpp runtime path (required)
execute 'set runtimepath^=' .. s:dpp_src
for dpp_addon_path in s:dpp_addon
    execute 'set runtimepath^=' .. s:dpp_base . s:dpp_manual_repo_source_url . dpp_addon_path
endfor

if s:dpp_base->dpp#min#load_state()
    " NOTE: dpp#make_state() requires denops.vim
    execute 'set runtimepath^=' .. s:denops_src
    autocmd User DenopsReady call dpp#make_state(s:dpp_base, s:dpp_config)
endif

filetype indent plugin on

if has('syntax')
    syntax on
endif

.config/vim/dpp.ts

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

type Toml = {
    hooks_file?: string;
    ftplugins?: Record<string, string>;
    plugins: Plugin[];
};

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

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

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

        // Load toml plugins
        const tomls: Toml[] = [];

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

        // Merge toml results
        const recordPlugins: Record<string, Plugin> = {};
        const ftplugins: Record<string, string> = {};
        const hooksFiles: string[] = [];

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

            if (toml.ftplugins) {
                for (const filetype of Object.keys(toml.ftplugins)) {
                    if (ftplugins[filetype]) {
                        ftplugins[filetype] += `\n${toml.ftplugins[filetype]}`;
                    } else {
                        ftplugins[filetype] = toml.ftplugins[filetype];
                    }
                }
            }

            if (toml.hooks_file) {
                hooksFiles.push(toml.hooks_file);
            }
        }

        return {
            plugins: Object.values(recordPlugins),
            stateLines: []
        };
    }
}

~/.config/vim/dpp_plugin.toml

[[plugins]]
repo="vim-denops/denops.vim"

Created cache.vim

[{"denops.vim":{"lazy":false,"repo":"vim-denops/denops.vim","name":"denops.vim","path":"/Users/kshu/.cache/dpp//repos/github.com/vim-denops/denops.vim","protocol":"git","sourced":false,"rtp":"/Users/kshu/.cache/dpp//repos/github.com/vim-denops/denops.vim","merged":true}},{},{"extOptions":{},"extParams":{},"hooksFileMarker":"{{{,}}}","inlineVimrcs":[],"protocolOptions":{},"protocolParams":{},"protocols":["git"]},[]]

Created state.vim

if g:dpp#_cache_version !=# 1| throw "Cache version error" | endif
let [g:dpp#_plugins, g:dpp#ftplugin, g:dpp#_options, g:dpp#_check_files] = g:dpp#_cache
let g:dpp#_config_path = '/Users/kshu/.config/vim/dpp.ts'
let &runtimepath = '/Users/kshu/.cache/dpp/github.com/Shougo/dpp-ext-toml,/Users/kshu/.cache/dpp/github.com/Shougo/dpp-protocol-git,/Users/kshu/.cache/dpp/github.com/Shougo/dpp.vim,/Users/kshu/.vim,/Applications/MacVim.app/Contents/Resources/vim/vimfiles,/Users/kshu/.cache/dpp/Vim/.dpp,/Applications/MacVim.app/Contents/Resources/vim/runtime,/Applications/MacVim.app/Contents/Resources/vim/vimfiles/after,/Users/kshu/.vim/after,/Users/kshu/.cache/dpp/Vim/.dpp/after'

Command result of find .dpp/ in .cache/Vim

.dpp/
.dpp//ftdetect
.dpp//doc
.dpp//after
.dpp//after/ftplugin.vim

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

  1. rm -rf .cache/dpp
  2. vim
  3. :q
  4. vim
  5. :call dpp#async_ext_action('', '')

Screenshot (if possible)

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

:messages result

[dpp] denops.vim must be loaded before "dpp#async_ext_action()".

Shougo commented 7 months ago

Plugins are not installed. You must install plugins by dpp-ext-installer.

Shougo commented 7 months ago

const s:dpp_manual_repo_source_url = 'github.com/'

This is wrong. Because manual installed plugins must be under repos directory in the base directory.

kenji0923 commented 7 months ago

Thank you for pointing out my setting failure. I should have noticed the path in the cache.vim, determined by the default setting, is different from the path I installed denops. Added documentation may help a lot.