dpp.vim

repository·main·Indexed 41 days ago

https://github.com/shougo/dpp.vim

A high-performance, modular plugin manager for Vim and Neovim that relies on Deno and denops.vim. It utilizes a system of extensions (such as dpp-ext-installer and dpp-ext-lazy) and protocols (such as dpp-protocol-git) to provide flexible plugin management. Requires Vim 9.1.0448+ or Neovim 0.10.0+, Deno 2.3.0+, and denops.vim v8.0+.

Tokens
2.2K
Snippets
4
Records
6
Agent score
1%

What's inside dpp.vim

  1. Understand dpp.vim Extensions and Protocols

    main

    dpp.vim uses a modular architecture based on Extensions and Protocols to provide advanced functionality.

    Extensions

    Extensions implement high-level features, such as plugin management capabilities. Examples include:

    • dpp-ext-installer: For installing plugins from remote sources.
    • dpp-ext-local: For managing local plugins.
    • dpp-ext-lazy: For lazy-loading plugins.
    • dpp-ext-toml: For configuration using TOML.

    Protocols

    Protocols implement Version Control System (VCS) related features, allowing dpp.vim to interact with different repository types. An example is:

    • dpp-protocol-git: For handling Git repositories.
  2. Install dpp.vim

    main

    To use dpp.vim, you must meet specific version requirements and install several dependencies. Note that dpp.vim does not work with zero configuration; you must provide a configuration.

    Requirements

    • Vim: 9.1.0448+ or Neovim: 0.10.0+
    • Deno: 2.3.0+
    • denops.vim: v8.0+

    Additional Dependencies

    Depending on your needs, you may need to install these separately:

    • To install plugins from remote sources: dpp-ext-installer
    • To install plugins from git: dpp-protocol-git
  3. Use dpp as a source in ddu.vim

    main

    The @ddu-sources/dpp source allows you to list and manage dpp.vim plugins directly within ddu.vim. It retrieves the current state of plugins from the global variable g:dpp.state.plugins and presents them as items in a ddu buffer.

    Configuration

    When configuring the source in ddu.vim, you can use the names parameter to filter the list to specific plugins.

    Params:

    • names: An array of strings (string[]) representing the names of the plugins you want to include in the list. If empty, all plugins are shown.

    Available Actions

    When items are selected in the ddu buffer, the following actions are available:

    • browse: Opens the plugin's URL using ddu#kind#file#open.
    • update: Triggers a plugin update by calling the dpp#async_ext_action with the installer extension and the update action for the selected plugin names.
    " Example ddu configuration (conceptual)
    " Note: Actual ddu configuration syntax depends on your ddu setup
    " but the source parameters would look like this:
    " ddu#source('dpp', {'params': {'names': ['plugin-a', 'plugin-b']}})
  4. Configure dpp.vim using Vim script

    main

    This example demonstrates a Vim script configuration using ~/.cache/dpp as the base path.

    Key steps in the configuration:

    1. Set s:dpp_base (required).
    2. Set s:dpp_src (the path to the dpp.vim repository, which must be cloned beforehand).
    3. Add s:dpp_src to the runtimepath.
    4. Call dpp#min#load_state() to check for an existing state.
    5. If state loading fails, use dpp#make_state(base_path, config_path) inside a DenopsReady autocmd to generate a new state. Note that dpp#make_state() requires denops.vim to be in the runtimepath.
    " Ward off unexpected things that your distro might have made, as
    " well as sanely reset options when re-sourcing .vimrc
    set nocompatible
    
    " Set dpp base path (required)
    const s:dpp_base = '~/.cache/dpp/'
    
    " Set dpp source path (required)
    " NOTE: The plugins must be cloned before.
    const s:dpp_src = '~/.cache/dpp/repos/github.com/Shougo/dpp.vim'
    const s:denops_src = '~/.cache/dpp/repos/github.com/denops/denops.vim'
    "const s:denops_installer =
    "">'~/.cache/dpp/repos/github.com/Shougo/dpp-ext-installer'
    
    " Set dpp runtime path (required)
    execute 'set runtimepath^=' .. s:dpp_src
    
    if s:dpp_base->dpp#min#load_state()
      " NOTE: dpp#make_state() requires denops.vim
      " NOTE: denops.vim and dpp plugins are must be added
      execute 'set runtimepath^=' .. s:denops_src
      "execute 'set runtimepath^=' .. s:denops_installer
    
      autocmd User DenopsReady
      \ : echohl WarningMsg
      \ | echomsg 'dpp load_state() is failed'
      \ | echohl NONE
      \ | call dpp#make_state(s:dpp_base, '{TypeScript config file path}')
    endif
    
    autocmd User Dpp:makeStatePost
          \ : echohl WarningMsg
          \ | echomsg 'dpp make_state() is done'
          \ | echohl NONE
    
    " Attempt to determine the type of a file based on its name and
    " possibly its " contents. Use this to allow intelligent
    " auto-indenting " for each filetype, and for plugins that are
    " filetype specific.
    filetype indent plugin on
    
    " Enable syntax highlighting
    if has('syntax')
      syntax on
    endif
  5. Configure dpp.vim using Lua

    main

    This example demonstrates a Lua configuration for Neovim using ~/.cache/dpp as the base path.

    Key steps in the configuration:

    1. Define dppSrc and denopsSrc paths.
    2. Prepend dppSrc to vim.opt.runtimepath.
    3. Use dpp.load_state(dppBase) to check for existing state.
    4. If state loading fails, use dpp.make_state(dppBase, config_path) inside a DenopsReady autocmd. This requires denopsSrc to be in the runtimepath.
    local dppSrc = "~/.cache/dpp/repos/github.com/Shougo/dpp.vim"
    local denopsSrc = "~/.cache/dpp/repos/github.com/denops/denops.vim"
    --local denopsInstaller =
    --  "~/.cache/dpp/repos/github.com/Shougo/dpp-ext-installer"
    
    vim.opt.runtimepath:prepend(dppSrc)
    
    local dpp = require("dpp")
    
    local dppBase = "~/.cache/dpp"
    if dpp.load_state(dppBase) then
      vim.opt.runtimepath:prepend(denopsSrc)
      --vim.opt.runtimepath:prepend(denopsInstaller)
    
      vim.api.nvim_create_autocmd("User", {
        pattern = "DenopsReady",
        callback = function()
          vim.notify("dpp load_state() is failed")
          dpp.make_state(dppBase, {TypeScript config file path})
        end,
      })
    end
    
    vim.api.nvim_create_autocmd("User", {
      pattern = "Dpp:makeStatePost",
      callback = function()
        vim.notify("dpp make_state() is done")
      end,
    })
    
    vim.cmd("filetype indent plugin on")
    vim.cmd("syntax on")
  6. DduItem action structure for dpp source

    main

    When using the dpp source in ddu.vim, each item returned contains an action object of type Action. This object is used to identify the plugin and its associated metadata for actions like browsing or updating.

    Action Object Schema:

    • path: The file path of the plugin.
    • url: The URL of the plugin (if available).
    • __name: The name of the plugin (used for identifying the plugin during updates).
    type Action = {
      path: string;
      url: string;
      __name: string;
    };