Shougo / dpp.vim

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

No `vim` directory is created in `s:dpp_base` #10

Closed uhooi closed 9 months ago

uhooi commented 9 months ago

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

Problems summary

No vim directory is created in s:dpp_base .

Expected

A vim directory is created in s:dpp_base .

Environment Information

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

plugins.vim https://github.com/uhooi/dotfiles/blob/fbb2061193530e418a1041e6810f0b10ad7946fb/.vim/config/plugins.vim

" Set dpp base path (required)
const s:dpp_base = expand('~/.cache/dpp/')
if !isdirectory(s:dpp_base)
  call mkdir(s:dpp_base, 'p')
endif

" Copy my dpp config files
const s:dpp_config_file = s:dpp_base .. 'dpp.ts'
if !filereadable(s:dpp_config_file)
  execute '!cp -f ./dpp/* ' .. s:dpp_base
endif

" Set dpp source path (required)
const s:dpp_src = 'github.com/Shougo/dpp.vim'
if !isdirectory(s:dpp_base .. 'repos/github.com/Shougo')
  call mkdir(s:dpp_base .. 'repos/github.com/Shougo', 'p')
endif

" Set denops source path
const s:denops_src = 'github.com/vim-denops/denops.vim'
if !isdirectory(s:dpp_base .. 'repos/github.com/vim-denops/')
  call mkdir(s:dpp_base .. 'repos/github.com/vim-denops/', 'p')
endif

" Set dpp extensions and protocols path
const s:dpp_plugins = [
\  'github.com/Shougo/dpp-ext-installer',
\  'github.com/Shougo/dpp-ext-lazy',
\  'github.com/Shougo/dpp-ext-toml',
\  'github.com/Shougo/dpp-protocol-git',
\]

" Clone repository and set dpp runtime path (required)
const s:dpp_dir = s:dpp_base .. 'repos/' .. s:dpp_src
if !isdirectory(s:dpp_dir)
  execute '!git clone https://' .. s:dpp_src s:dpp_dir
endif
execute 'set runtimepath^=' .. s:dpp_dir

" Clone repository and set plugin runtime path
for plugin in s:dpp_plugins
  let dir = s:dpp_base .. 'repos/' .. plugin
  if !isdirectory(dir)
    execute '!git clone https://' .. plugin dir
  endif
  execute 'set runtimepath^=' .. dir
endfor

if dpp#min#load_state(s:dpp_base)
  " Clone repository and set denops runtime path
  const s:denops_dir = s:dpp_base .. 'repos/' .. s:denops_src
  if !isdirectory(s:denops_dir)
    execute '!git clone https://' .. s:denops_src s:denops_dir
  endif
  execute 'set runtimepath^=' .. s:denops_dir

  autocmd User DenopsReady
  \  call dpp#make_state(s:dpp_base, s:dpp_config_file)
endif

dpp/dpp.ts https://github.com/uhooi/dotfiles/blob/fbb2061193530e418a1041e6810f0b10ad7946fb/.vim/config/dpp/dpp.ts

import {
  BaseConfig,
  ConfigReturn,
  ContextBuilder,
  Dpp,
  Plugin,
} from "https://deno.land/x/dpp_vim@v0.0.7/types.ts";
import { Denops, fn } from "https://deno.land/x/dpp_vim@v0.0.7/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<ConfigReturn> {
    args.contextBuilder.setGlobal({
      protocols: ["git"],
    });

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

    // Load toml plugins
    const tomls: Toml[] = [];
    for (
      const tomlFile of [
        "~/.cache/dpp/dpp.toml",
      ]
    ) {
      tomls.push(
        await args.dpp.extAction(
          args.denops,
          context,
          options,
          "toml",
          "load",
          {
            path: tomlFile,
            options: {
              lazy: false,
            },
          },
        ) as Toml,
      );
    }

    // 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);
      }
    }

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

    return {
      ftplugins,
      hooksFiles,
      plugins: lazyResult.plugins,
      stateLines: lazyResult.stateLines,
    };
  }
}

dpp/dpp.toml https://github.com/uhooi/dotfiles/blob/fbb2061193530e418a1041e6810f0b10ad7946fb/.vim/config/dpp/dpp.toml

[[plugins]]
repo = 'mattn/vim-nekokak'

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

  1. Run vim -u NONE -N in terminal.
  2. Run :source ./plugins.vim in Vim.
  3. No vim directory is created in s:dpp_base .
    $ cd ~/.cache/dpp
    $ tree -L 4
    .
    ├── dpp.toml
    ├── dpp.ts
    └── repos
        └── github.com
            ├── Shougo
            │   ├── dpp-ext-installer
            │   ├── dpp-ext-lazy
            │   ├── dpp-ext-toml
            │   ├── dpp-protocol-git
            │   └── dpp.vim
            └── vim-denops
                └── denops.vim
  4. Run :set rtp .
      runtimepath=~/.cache/dpp/repos/github.com/vim-denops/denops.vim,~/.cache/dpp/repos/github.com/Shougo/dpp-protocol-git,~/.cache/dpp/repos/github.com/Shougo/dpp-ext-toml,~/.cache/dpp/repos/github.com/Shougo/dpp-ext-lazy,~/.cache/dpp/repos/github.com/Shougo/dpp-ext-installer,~/.cache/dpp/repos/github.com/Shougo/dpp.vim,~/.vim,~/.local/vim/share/vim/vimfiles,~/.local/vim/share/vim/vim90,~/.local/vim/share/vim/vimfiles/after,~/.vim/after
  5. Run :call dpp#async_ext_action('installer', 'install') .
    [dpp] You need to make state file by "dpp#make_state()".

Screenshot (if possible)

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

:redir > messages.txt
:messages
:redir END

messages.txt


Messages maintainer: The Vim Project
Shougo commented 9 months ago

It works for me.

I have tested below vimrc.

" Set dpp base path (required)
const s:dpp_base = expand('~/.cache/uhooi/')
if !isdirectory(s:dpp_base)
  call mkdir(s:dpp_base, 'p')
endif

" Copy my dpp config files
const s:dpp_config_file = '~/work/test/dpp_uhooi.ts'

" Set dpp source path (required)
const s:dpp_src = 'github.com/Shougo/dpp.vim'
if !isdirectory(s:dpp_base .. 'repos/github.com/Shougo')
  call mkdir(s:dpp_base .. 'repos/github.com/Shougo', 'p')
endif

" Set denops source path
const s:denops_src = 'github.com/vim-denops/denops.vim'
if !isdirectory(s:dpp_base .. 'repos/github.com/vim-denops/')
  call mkdir(s:dpp_base .. 'repos/github.com/vim-denops/', 'p')
endif

" Set dpp extensions and protocols path
const s:dpp_plugins = [
\  'github.com/Shougo/dpp-ext-installer',
\  'github.com/Shougo/dpp-ext-lazy',
\  'github.com/Shougo/dpp-ext-toml',
\  'github.com/Shougo/dpp-protocol-git',
\]

" Clone repository and set dpp runtime path (required)
set runtimepath^=~/work/dpp.vim

" Clone repository and set plugin runtime path
for plugin in s:dpp_plugins
  let dir = s:dpp_base .. 'repos/' .. plugin
  if !isdirectory(dir)
    execute '!git clone https://' .. plugin dir
  endif
  execute 'set runtimepath^=' .. dir
endfor

if dpp#min#load_state(s:dpp_base)
  " Clone repository and set denops runtime path
  const s:denops_dir = s:dpp_base .. 'repos/' .. s:denops_src
  if !isdirectory(s:denops_dir)
    execute '!git clone https://' .. s:denops_src s:denops_dir
  endif
  execute 'set runtimepath^=' .. s:denops_dir

  autocmd User DenopsReady
        \ : echohl WarningMsg
        \ | echomsg 'dpp load_state() is failed'
        \ | echohl NONE
        \ | call dpp#make_state(s:dpp_base, s:dpp_config_file)
endif

autocmd User Dpp:makeStatePost
      \ : echohl WarningMsg
      \ | echomsg 'dpp make_state() is done'
      \ | echohl NONE
Shougo commented 9 months ago

I have tested both Vim and neovim.

% ls -la ~/.cache/uhooi/
total 20
drwxr-xr-x  5 shougo shougo 4096 11月 18 21:38 ./
drwxr-xr-x 48 shougo shougo 4096 11月 18 21:29 ../
drwxr-xr-x  3 shougo shougo 4096 11月 18 21:36 nvim/
drwxr-xr-x  3 shougo shougo 4096 11月 18 21:29 repos/
drwxr-xr-x  3 shougo shougo 4096 11月 18 21:38 vim/
Shougo commented 9 months ago

Run :call dpp#async_ext_action('installer', 'install')

You must load denops.vim before the function call.

Shougo commented 9 months ago
Run vim -u NONE -N in terminal.
Run :source ./plugins.vim in Vim.

It is wrong. The denops.vim loading is when VimEnter. dpp.vim must be load when vimrc loading.

So it must be:

vim -Nu ./plugins.vim
uhooi commented 9 months ago

Oh.. thx!! Fix plugins.vim and run vim -Nu ./plugins.vim , vim directory is generated.

But the following error occurs.


Messages maintainer: The Vim Project
dpp load_state() is failed
dpp make_state() is done

Why...?

Shougo commented 9 months ago

It is not the error.

load_state() is failed in the first. Because make_state() is not executed yet.

Shougo commented 9 months ago

dpp make_state() is done

And make_state() is called.