Skip to content

Commit

Permalink
依存をほぼバージョン未指定jsrに置き換えた
Browse files Browse the repository at this point in the history
  • Loading branch information
kuuote committed Feb 10, 2025
1 parent 24e41f5 commit d3c7ec4
Show file tree
Hide file tree
Showing 54 changed files with 197 additions and 240 deletions.
79 changes: 45 additions & 34 deletions conf/dpp.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
import { ensure, is } from "jsr:@core/unknownutil";
import { Denops } from "jsr:@denops/std";
import {
ensure,
is,
} from "/data/vim/repos/github.com/lambdalisue/deno-unknownutil/mod.ts";
Ext as LazyExt,
LazyMakeStateResult,
Params as LazyParams,
} from "jsr:@shougo/dpp-ext-lazy";
import { Ext as TomlExt, Params as TomlParams } from "jsr:@shougo/dpp-ext-toml";
import {
BaseConfig,
ConfigArguments,
ConfigReturn,
} from "/data/vim/repos/github.com/Shougo/dpp.vim/denops/dpp/base/config.ts";
import { Denops } from "/data/vim/repos/github.com/Shougo/dpp.vim/denops/dpp/deps.ts";
import {
ContextBuilder,
Dpp,
Plugin,
} from "/data/vim/repos/github.com/Shougo/dpp.vim/denops/dpp/types.ts";
} from "jsr:@shougo/dpp-vim/config";
import { Protocol } from "jsr:@shougo/dpp-vim/protocol";
import { ExtOptions, Plugin } from "jsr:@shougo/dpp-vim/types";

type Toml = {
plugins: Plugin[];
};

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

const isStringArray = is.ArrayOf(is.String);

async function glob(denops: Denops, path: string): Promise<string[]> {
Expand All @@ -32,12 +28,7 @@ async function glob(denops: Denops, path: string): Promise<string[]> {
}

export class Config extends BaseConfig {
override async config(args: {
contextBuilder: ContextBuilder;
denops: Denops;
basePath: string;
dpp: Dpp;
}): Promise<ConfigReturn> {
override async config(args: ConfigArguments): Promise<ConfigReturn> {
const vim = args.denops.meta.host === "vim";
const nvim = args.denops.meta.host === "nvim";
// X<dpp-inline_vimrcs>
Expand All @@ -55,6 +46,10 @@ export class Config extends BaseConfig {
});

const [context, options] = await args.contextBuilder.get(args.denops);
const protocols = await args.denops.dispatcher.getProtocols() as Record<
string,
Protocol
>;
const plugins: Plugin[] = [];

const profiles = new Set<string>();
Expand All @@ -76,19 +71,26 @@ export class Config extends BaseConfig {
profiles.add("nvim_lsp");
// profiles.add("vim_lsp");

const [tomlExt, tomlOptions, tomlParams]: [
TomlExt | undefined,
ExtOptions,
TomlParams,
] = await args.denops.dispatcher.getExt(
"toml",
) as [TomlExt | undefined, ExtOptions, TomlParams];
const tomls = await glob(args.denops, "$MYVIMDIR/conf/plug/**/*.toml");
for (const tomlPath of tomls) {
console.log("load toml: " + tomlPath);
const toml = await args.dpp.extAction(
args.denops,
const toml = await tomlExt!.actions.load.callback({
denops: args.denops,
context,
options,
"toml",
"load",
{
protocols,
extOptions: tomlOptions,
extParams: tomlParams,
actionParams: {
path: tomlPath,
},
) as Toml;
}) as Toml;

const profileVim = tomlPath.match(/\/vim\//) != null;
const profileNvim = tomlPath.match(/\/nvim\//) != null;
Expand Down Expand Up @@ -127,16 +129,25 @@ export class Config extends BaseConfig {
p.path = p.repo;
}
}
const lazyResult = await args.dpp.extAction(
args.denops,

const [lazyExt, lazyOptions, lazyParams]: [
LazyExt | undefined,
ExtOptions,
LazyParams,
] = await args.denops.dispatcher.getExt(
"lazy",
) as [LazyExt | undefined, ExtOptions, LazyParams];
const lazyResult = await lazyExt!.actions.makeState.callback({
denops: args.denops,
context,
options,
"lazy",
"makeState",
{
protocols,
extOptions: lazyOptions,
extParams: lazyParams,
actionParams: {
plugins,
},
) as LazyMakeStateResult;
}) as LazyMakeStateResult;

// プラギン置き場として/data/vimを使う
const repos = args.basePath + "/repos";
Expand Down
7 changes: 2 additions & 5 deletions conf/plug/ddc/main.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {
BaseConfig,
type ConfigArguments,
type SourceOptions,
} from "../../../denops/@deps/ddc.ts";
import { BaseConfig, ConfigArguments } from "jsr:@shougo/ddc-vim/config";
import { SourceOptions } from "jsr:@shougo/ddc-vim/types";

type Filters = Record<string, {
matchers: SourceOptions["matchers"];
Expand Down
11 changes: 5 additions & 6 deletions conf/plug/ddc/manual.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// import { Params as BufParams } from "../../../denops/@ddc-sources/buf.ts";
import { Params as ListParams } from "../../../denops/@ddc-sources/list.ts";
import { Denops, mapping, option } from "../../../denops/@deps/denops_std.ts";
import { map } from "../../../denops/@vimrc/lib/lambda/map.ts";
import {
BaseConfig,
ConfigArguments,
DdcOptions,
} from "../../../denops/@deps/ddc.ts";
import { Denops } from "jsr:@denops/std";
import * as mapping from "jsr:@denops/std/mapping";
import * as option from "jsr:@denops/std/option";
import { BaseConfig, ConfigArguments } from "jsr:@shougo/ddc-vim/config";
import { DdcOptions } from "jsr:@shougo/ddc-vim/types";

/*
X<ddc-config-manual_complete>
Expand Down
4 changes: 2 additions & 2 deletions conf/plug/ddu.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ repo = 'https://github.com/Shougo/ddu-ui-filer'
repo = 'https://github.com/Shougo/ddu.vim'
# L<ddu-global>
hook_add = '''
autocmd vimrc User DenopsReady source $MYVIMDIR/conf/plug/ddu.vim
" DenopsReadyのタイミングが変わってて呼び出されなくなったので無理やり呼び出しておく
autocmd vimrc User DenopsReady call ddu#custom#load_config(expand('$MYVIMDIR/conf/plug/ddu/main.ts'))
" ddu.vim自体のロードがDenopsReadyで行われるため再呼び出ししておく
autocmd vimrc User DenopsReady ++once call timer_start(0, {->execute('doautocmd <nomodeline> User DenopsReady', '')})
'''

Expand Down
2 changes: 0 additions & 2 deletions conf/plug/ddu.vim

This file was deleted.

39 changes: 19 additions & 20 deletions conf/plug/ddu/ff.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
import { group, register } from "../../../denops/@vimrc/lib/lambda/autocmd.ts";
import {
ActionFlags,
BaseConfig,
BaseUiParams,
type ConfigArguments,
type SourceOptions,
type UiActionArguments,
} from "/data/vim/deps/ddu.ts";
Denops,
} from "jsr:@denops/std";
import * as autocmd from "jsr:@denops/std/autocmd"
import * as lambda from "jsr:@denops/std/lambda"
import * as mapping from "jsr:@denops/std/mapping"
import * as option from "jsr:@denops/std/option"
import { assert, is } from "jsr:@core/unknownutil";
import { Params as DduUiFFParams } from "jsr:@shougo/ddu-ui-ff";
import { BaseConfig, ConfigArguments } from "jsr:@shougo/ddu-vim/config";
import {
autocmd,
type Denops,
lambda,
mapping,
option,
} from "/data/vim/deps/denops_std.ts";
import { is, u } from "/data/vim/deps/unknownutil.ts";
import { Params as DduUiFFParams } from "/data/vim/repos/github.com/Shougo/ddu-ui-ff/denops/@ddu-uis/ff.ts";
ActionFlags,
SourceOptions,
UiActionArguments,
} from "jsr:@shougo/ddu-vim/types";
import { BaseParams } from "jsr:@shougo/ddu-vim/types";

type Filter = {
matchers: SourceOptions["matchers"];
sorters: SourceOptions["sorters"];
converters: SourceOptions["converters"];
};

function updateFilter(args: UiActionArguments<BaseUiParams>, filter: Filter) {
function updateFilter(args: UiActionArguments<BaseParams>, filter: Filter) {
const sources = args.options.sources.map((s) => {
if (is.String(s)) {
s = { name: s };
Expand All @@ -36,9 +35,9 @@ function updateFilter(args: UiActionArguments<BaseUiParams>, filter: Filter) {
},
};
});
args.ddu.updateOptions({
sources,
});
// args.ddu.updateOptions({
// sources,
// });
}

const augroup = "vimrc#ddu-ui-ff";
Expand Down Expand Up @@ -204,7 +203,7 @@ async function setupFileTypeAutocmd(args: ConfigArguments) {
};
const ddu_ff = register(denops, async (name: unknown) => {
await setupTable["_"]?.();
u.assert(name, is.String);
assert(name, is.String);
const names = (aliases[name] ?? name).split(/:/g);
for (const name of names) {
await setupTable[name]?.();
Expand Down
12 changes: 7 additions & 5 deletions conf/plug/ddu/filer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { register } from "../../../denops/@vimrc/lib/lambda/autocmd.ts";
import { BaseConfig, ConfigArguments, DduItem } from "/data/vim/deps/ddu.ts";
import { autocmd, lambda, mapping } from "/data/vim/deps/denops_std.ts";
import { is, u } from "/data/vim/deps/unknownutil.ts";
import * as autocmd from "jsr:@denops/std/autocmd"
import * as lambda from "jsr:@denops/std/lambda"
import * as mapping from "jsr:@denops/std/mapping"
import { assert, is } from "jsr:@core/unknownutil";
import { BaseConfig, ConfigArguments } from "jsr:@shougo/ddu-vim/config";

const augroup = "vimrc#ddu-ui-filer";

Expand Down Expand Up @@ -46,7 +48,7 @@ async function setupFileTypeAutocmd(args: ConfigArguments) {
};
const ddu_filer = register(denops, async (name: unknown) => {
await setupTable["_"]?.();
u.assert(name, is.String);
assert(name, is.String);
// const names = (aliases[name] ?? name).split(/:/g);
// for (const name of names) {
// await setupTable[name]?.();
Expand All @@ -61,7 +63,7 @@ async function setupFileTypeAutocmd(args: ConfigArguments) {
});
}
export class Config extends BaseConfig {
async config(args: ConfigArguments) {
override async config(args: ConfigArguments) {
const nvim = args.denops.meta.host === "nvim";
args.contextBuilder.patchGlobal({
uiParams: {
Expand Down
7 changes: 2 additions & 5 deletions conf/plug/ddu/lib/helper.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {
DduItem,
DduOptions,
} from "../../../../denops/@deps/ddu.ts";
import { Denops } from "../../../../denops/@deps/denops_std.ts";
import { Denops } from "jsr:@denops/std";
import { DduItem, DduOptions } from "jsr:@shougo/ddu-vim/types";

// 型wrapper
// いるものしか定義してないので適宜増やすこと
Expand Down
24 changes: 12 additions & 12 deletions conf/plug/ddu/main.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import * as sourceList from "../../../denops/@ddu-sources/list.ts";
import { type KindGitStatusActionData } from "../../../denops/@deps/ddu-kinds.ts";
import { is, u } from "../../../denops/@deps/unknownutil.ts";
import { group, register } from "../../../denops/@vimrc/lib/lambda/autocmd.ts";
// import { KindGitStatusActionData } from "../../../denops/@deps/ddu-kinds.ts";
import { cmd, map } from "../../../denops/@vimrc/lib/lambda/map.ts";
import { dduHelper } from "./lib/helper.ts";
import { is } from "jsr:@core/unknownutil";
import { Denops } from "jsr:@denops/std";
import * as autocmd from "jsr:@denops/std/autocmd";
import { BaseConfig, ConfigArguments } from "jsr:@shougo/ddu-vim/config";
import {
ActionFlags,
BaseConfig,
type ConfigArguments,
type DduOptions,
type SourceOptions,
} from "/data/vim/deps/ddu.ts";
import * as stdpath from "/data/vim/deps/deno_std/path/mod.ts";
import { autocmd, type Denops } from "/data/vim/deps/denops_std.ts";
DduOptions,
SourceOptions,
} from "jsr:@shougo/ddu-vim/types";
import * as stdpath from "jsr:@std/path";

const augroup = "vimrc#ddu";

Expand Down Expand Up @@ -465,7 +464,7 @@ async function selectorConfig(args: ConfigArguments) {
}

export class Config extends BaseConfig {
async config(args: ConfigArguments) {
override async config(args: ConfigArguments) {
await autocmd.group(args.denops, augroup, (helper) => {
helper.remove("*");
helper.define(
Expand All @@ -477,6 +476,7 @@ export class Config extends BaseConfig {
});
mainConfig(args);
await selectorConfig(args);
autocmd.emit(args.denops, "User", "vimrc#ddu#ready");
await new (await import("./ff.ts")).Config().config(args);
await autocmd.emit(args.denops, "User", "vimrc#ddu#ready");
}
}
4 changes: 2 additions & 2 deletions conf/plug/ddu/template.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
BaseConfig,
ConfigArguments,
} from "/data/vim/repos/github.com/Shougo/ddu.vim/denops/ddu/base/config.ts";
} from "jsr:@shougo/ddu-vim/config";

export class Config extends BaseConfig {
async config(args: ConfigArguments) {
override async config(args: ConfigArguments) {
}
}
3 changes: 2 additions & 1 deletion denops/@ddc-filters/sorter_file.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BaseFilter, Item } from "../@deps/ddc.ts";
import { BaseFilter } from "jsr:@shougo/ddc-vim/filter";
import { Item } from "jsr:@shougo/ddc-vim/types";

const rank: Record<string, number> = {
dir: 1,
Expand Down
3 changes: 2 additions & 1 deletion denops/@ddc-filters/sorter_fzf.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BaseFilter, FilterArguments, Item } from "../@deps/ddc.ts";
import { BaseFilter, FilterArguments } from "jsr:@shougo/ddc-vim/filter";
import { Item } from "jsr:@shougo/ddc-vim/types";
// @deno-types=./sorter_fzf/fzf_type.ts
import { Fzf } from "npm:[email protected]";

Expand Down
7 changes: 2 additions & 5 deletions denops/@ddc-filters/sorter_ngram.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import {
BaseFilter,
FilterArguments,
} from "https://deno.land/x/[email protected]/base/filter.ts";
import { Item } from "https://deno.land/x/[email protected]/types.ts";
import { makeTrie, match } from "./ngram/ngram.ts";
import { BaseFilter, FilterArguments } from "jsr:@shougo/ddc-vim/filter";
import { Item } from "jsr:@shougo/ddc-vim/types";

function byteLength(input: string): number {
return new TextEncoder().encode(input).length;
Expand Down
3 changes: 2 additions & 1 deletion denops/@ddc-filters/template.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BaseFilter, FilterArguments, Item } from "../@deps/ddc.ts";
import { BaseFilter, FilterArguments } from "jsr:@shougo/ddc-vim/filter";
import { Item } from "jsr:@shougo/ddc-vim/types";

type Never = Record<PropertyKey, never>;

Expand Down
8 changes: 4 additions & 4 deletions denops/@ddc-sources/list.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { is, maybe } from "jsr:@core/unknownutil";
import {
BaseSource,
GatherArguments,
Item,
OnCompleteDoneArguments,
} from "../@deps/ddc.ts";
import { is, u } from "../@deps/unknownutil.ts";
} from "jsr:@shougo/ddc-vim/source";
import { Item } from "jsr:@shougo/ddc-vim/types";

export type Params = {
candidates: Array<string | Item>;
Expand All @@ -25,7 +25,7 @@ export class Source extends BaseSource<Params> {
} else {
return {
...candidate,
user_data: u.maybe(candidate.user_data, is.Record) ?? {},
user_data: maybe(candidate.user_data, is.Record) ?? {},
};
}
}),
Expand Down
Loading

0 comments on commit d3c7ec4

Please sign in to comment.