denops.vim icon indicating copy to clipboard operation
denops.vim copied to clipboard

Expose types for plugin's main function

Open Milly opened this issue 1 year ago • 3 comments

Exposes the type PluginMain for the plugin's main function. Update the way to define the main function of the plugin as follows:

// New approach
export const main: PluginMain = (denops) => {
  // ...
};

There is a discussion in #332 about extending the definition of the plugin's main function.

Milly avatar May 01 '24 18:05 Milly

Actually, I usually prefer ordinal function style but the new approach has a big advantage so I'm positive to change the style.

What we need to updates are

  • [x] denops.vim - https://github.com/vim-denops/denops.vim/pull/347
  • [x] deno-denops-core - https://github.com/vim-denops/deno-denops-core/pull/7
  • [x] deno-denops-std - https://github.com/vim-denops/deno-denops-std/pull/245
  • [x] denops-helloworld.vim - https://github.com/vim-denops/denops-helloworld.vim/pull/16
  • [x] denops-maze.vim - https://github.com/vim-denops/denops-maze.vim/pull/1
  • [x] denops-documentation - https://github.com/vim-denops/denops-documentation/pull/13

lambdalisue avatar May 02 '24 20:05 lambdalisue

Moreover, I believe there are more suitable names than "PluginMain" for the following reasons:

  • Developers are already aware that it's a plugin, hence the "Plugin" prefix seems somewhat redundant.
  • Although the function is named "main," it merely serves as a placeholder and doesn't elucidate the functionality. Therefore, the type name should offer a more descriptive insight.

Considering the aforementioned points, I suggest "Entrypoint" as the type name. What are your thoughts?

lambdalisue avatar May 02 '24 20:05 lambdalisue

I suggest "Entrypoint" as the type name. What are your thoughts?

Very good. I agree.

Milly avatar May 03 '24 05:05 Milly

Now denops_std (v6.5.0) serve Entrypoint and we can define the main function like

import type { Entrypoint } from "https://deno.land/x/[email protected]/mod.ts";

export const main: Entrypoint = (denops) => {
  // ...
};

lambdalisue avatar May 14 '24 18:05 lambdalisue