Skip to content

Commit

Permalink
chore: use denops v7
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoh86 committed Jul 30, 2024
1 parent 6e1eed1 commit ce13e21
Show file tree
Hide file tree
Showing 35 changed files with 92 additions and 172 deletions.
2 changes: 2 additions & 0 deletions deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"name": "denops-ollama.vim",
"version": "0.0.0",
"exports": {},
"description": "A set of denops utils just for me",
"tasks": {
"test": "deno test --allow-env=DENOPS_TEST_CONNECT_TIMEOUT,DENOPS_TEST_DENOPS_PATH,DENOPS_TEST_VERBOSE,DENOPS_TEST_VIM_EXECUTABLE,DENOPS_TEST_NVIM_EXECUTABLE --allow-run=vim,nvim --allow-net=127.0.0.1:0 --allow-read",
Expand Down
7 changes: 2 additions & 5 deletions denops/ollama/api/base.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import {
ensure,
Predicate,
} from "https://deno.land/x/[email protected]/mod.ts";
import { ensure, type Predicate } from "jsr:@core/[email protected]";
import {
JSONLinesParseStream,
type JSONValue,
} from "https://deno.land/x/[email protected]/mod.ts";
import { ReqInit } from "./types.ts";
import type { ReqInit } from "./types.ts";

const defaultBaseUrl = "http://localhost:11434";

Expand Down
5 changes: 1 addition & 4 deletions denops/ollama/api/copy_model.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import type { ReqInit, Result } from "./types.ts";
import { doPost } from "./base.ts";
import {
is,
PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import { is, type PredicateType } from "jsr:@core/[email protected]";

// Definitions for the endpoint to "Copy a model"
// Method: POST
Expand Down
4 changes: 2 additions & 2 deletions denops/ollama/api/copy_model_test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { assertEquals } from "https://deno.land/std@0.224.0/assert/mod.ts";
import { assertEquals } from "jsr:@std/[email protected]";
import {
assertSpyCallArgs,
assertSpyCalls,
stub,
} from "https://deno.land/std@0.224.0/testing/mock.ts";
} from "jsr:@std/testing@0.225.3/mock";
import { copyModel } from "./copy_model.ts";

Deno.test("copyModel", async (t) => {
Expand Down
5 changes: 1 addition & 4 deletions denops/ollama/api/create_model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
is,
type PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import { is, type PredicateType } from "jsr:@core/[email protected]";
import { isErrorResponse, type ReqInit } from "./types.ts";
import { parseJSONStream } from "./base.ts";
import { doPost } from "./base.ts";
Expand Down
5 changes: 1 addition & 4 deletions denops/ollama/api/delete_model.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import type { ReqInit, Result } from "./types.ts";
import { doDelete } from "./base.ts";
import {
is,
PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import { is, type PredicateType } from "jsr:@core/[email protected]";

// Definitions for the endpoint to "Delete a model"
// Method: DELETE
Expand Down
5 changes: 1 addition & 4 deletions denops/ollama/api/generate_chat_completion.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
is,
type PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import { is, type PredicateType } from "jsr:@core/[email protected]";
import { isErrorResponse, isFormat, type ReqInit } from "./types.ts";
import { parseJSONStream } from "./base.ts";
import { doPost } from "./base.ts";
Expand Down
6 changes: 1 addition & 5 deletions denops/ollama/api/generate_completion.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
ensure,
is,
type PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import { ensure, is, type PredicateType } from "jsr:@core/[email protected]";
import { isErrorResponse, isFormat, type ReqInit } from "./types.ts";
import { parseJSONStream } from "./base.ts";
import { doPost } from "./base.ts";
Expand Down
6 changes: 3 additions & 3 deletions denops/ollama/api/generate_completion_test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { assertEquals } from "https://deno.land/std@0.224.0/assert/mod.ts";
import { assertEquals } from "jsr:@std/[email protected]";
import {
assertSpyCallArgs,
assertSpyCalls,
stub,
} from "https://deno.land/std@0.224.0/testing/mock.ts";
} from "jsr:@std/testing@0.225.3/mock";
import {
generateCompletion,
GenerateCompletionResponse,
type GenerateCompletionResponse,
} from "./generate_completion.ts";

Deno.test("generateCompletion", async (t) => {
Expand Down
6 changes: 1 addition & 5 deletions denops/ollama/api/generate_embeddings.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
ensure,
is,
type PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import { ensure, is, type PredicateType } from "jsr:@core/[email protected]";
import { isErrorResponse, type ReqInit, type Result } from "./types.ts";
import { doPost } from "./base.ts";

Expand Down
6 changes: 1 addition & 5 deletions denops/ollama/api/list_local_models.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
ensure,
is,
type PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import { ensure, is, type PredicateType } from "jsr:@core/[email protected]";
import { isErrorResponse, type ReqInit, type Result } from "./types.ts";
import { doGet } from "./base.ts";

Expand Down
5 changes: 1 addition & 4 deletions denops/ollama/api/pull_model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
is,
type PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import { is, type PredicateType } from "jsr:@core/[email protected]";
import { isErrorResponse, type ReqInit } from "./types.ts";
import { doPost } from "./base.ts";
import { parseJSONStream } from "./base.ts";
Expand Down
5 changes: 1 addition & 4 deletions denops/ollama/api/push_model.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
is,
type PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import { is, type PredicateType } from "jsr:@core/[email protected]";
import { isErrorResponse, type ReqInit } from "./types.ts";
import { parseJSONStream } from "./base.ts";
import { doPost } from "./base.ts";
Expand Down
6 changes: 1 addition & 5 deletions denops/ollama/api/show_model_information.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
ensure,
is,
type PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import { ensure, is, type PredicateType } from "jsr:@core/[email protected]";
import { doPost } from "./base.ts";
import { isErrorResponse, type ReqInit, type Result } from "./types.ts";

Expand Down
5 changes: 1 addition & 4 deletions denops/ollama/api/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
is,
type PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import { is, type PredicateType } from "jsr:@core/[email protected]";

// The format to return a response in. Currently the only accepted value is json
export const isFormat = is.OptionalOf(is.LiteralOf("json"));
Expand Down
7 changes: 2 additions & 5 deletions denops/ollama/dispatch/complete.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import {
is,
PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import type { Denops } from "jsr:@denops/[email protected]";
import { is, type PredicateType } from "jsr:@core/[email protected]";
import { generateCompletion } from "../api.ts";
import { isReqArgs } from "./types.ts";
import { getPrefix, getSuffix } from "../util/context.ts";
Expand Down
4 changes: 2 additions & 2 deletions denops/ollama/dispatch/complete_test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from "https://deno.land/std@0.224.0/assert/mod.ts";
import { assert } from "jsr:@std/[email protected]";
import { complete } from "./complete.ts";

import { test } from "https://deno.land/x/[email protected]/mod.ts";
import { test } from "jsr:@denops/[email protected]";
export type Extends<E, A> = A extends E ? true : false;
export type NotExtends<E, A> = A extends E ? false : true;
export type Exact<A, B> = Extends<A, B> extends true
Expand Down
11 changes: 4 additions & 7 deletions denops/ollama/dispatch/delete_model.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { type Denops } from "https://deno.land/x/[email protected]/mod.ts";
import { getLogger } from "https://deno.land/[email protected]/log/mod.ts";
import * as helper from "https://deno.land/x/[email protected]/helper/mod.ts";
import {
is,
PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import type { Denops } from "jsr:@denops/[email protected]";
import { getLogger } from "jsr:@std/[email protected]";
import * as helper from "jsr:@denops/[email protected]/helper";
import { is, type PredicateType } from "jsr:@core/[email protected]";

import { deleteModel as deleteModelAPI } from "../api.ts";
import { canceller } from "../util/cancellable.ts";
Expand Down
11 changes: 4 additions & 7 deletions denops/ollama/dispatch/init.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import {
ConsoleHandler,
setup as setupLog,
} from "https://deno.land/[email protected]/log/mod.ts";
import type { Denops } from "jsr:@denops/[email protected]";
import { ConsoleHandler, setup as setupLog } from "jsr:@std/[email protected]";
import xdg from "https://deno.land/x/[email protected]/src/mod.deno.ts";
import { ensureFile } from "https://deno.land/std@0.224.0/fs/ensure_file.ts";
import { join } from "https://deno.land/std@0.224.0/path/join.ts";
import { ensureFile } from "jsr:@std/[email protected]";
import { join } from "jsr:@std/[email protected]/join";

import { setup as setupHighlight } from "../ui/highlight_prefix.ts";
import { mapCancel } from "../util/cancellable.ts";
Expand Down
10 changes: 5 additions & 5 deletions denops/ollama/dispatch/list_models.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as datetime from "https://deno.land/[email protected].0/datetime/mod.ts";
import * as bytes from "https://deno.land/std@0.224.0/fmt/bytes.ts";
import { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import * as helper from "https://deno.land/x/[email protected]/helper/mod.ts";
import * as datetime from "jsr:@std/datetime@0.224.3";
import * as bytes from "jsr:@std/fmt@0.225.6/bytes";
import type { Denops } from "jsr:@denops/[email protected]";
import * as helper from "jsr:@denops/[email protected]/helper";
import { Table } from "https://deno.land/x/[email protected]/table/mod.ts";

import { listLocalModels } from "../api.ts";
import { isReqArgs, ReqArgs } from "./types.ts";
import { isReqArgs, type ReqArgs } from "./types.ts";
import { canceller } from "../util/cancellable.ts";

export const isListModelsArgs = isReqArgs;
Expand Down
7 changes: 2 additions & 5 deletions denops/ollama/dispatch/open_log.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import type { Denops } from "jsr:@denops/[email protected]";

import {
is,
PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import { is, type PredicateType } from "jsr:@core/[email protected]";
import { isOpener } from "../ui/open.ts";

export const isOpenLogArgs = is.ObjectOf({
Expand Down
15 changes: 6 additions & 9 deletions denops/ollama/dispatch/pull_model.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import * as bytes from "https://deno.land/std@0.224.0/fmt/bytes.ts";
import type { Denops } from "jsr:@denops/[email protected]";
import * as bytes from "jsr:@std/fmt@0.225.6/bytes";
import { pullModel as pullModelAPI } from "../api.ts";
import { getLogger } from "https://deno.land/[email protected].0/log/mod.ts";
import * as helper from "https://deno.land/x/[email protected]/helper/mod.ts";
import { getLogger } from "jsr:@std/log@0.224.5";
import * as helper from "jsr:@denops/[email protected]/helper";
import { canceller } from "../util/cancellable.ts";
import { abortableAsyncIterable } from "https://deno.land/[email protected].0/async/mod.ts";
import { abortableAsyncIterable } from "jsr:@std/async@0.224.2";
import { isReqArgs } from "./types.ts";
import {
is,
PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import { is, type PredicateType } from "jsr:@core/[email protected]";

export const isPullModelArgs = is.AllOf([
is.ObjectOf({
Expand Down
10 changes: 3 additions & 7 deletions denops/ollama/dispatch/start_chat.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { abortableAsyncIterable } from "https://deno.land/[email protected]/async/mod.ts";
import { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import {
is,
maybe,
PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import { abortableAsyncIterable } from "jsr:@std/[email protected]";
import type { Denops } from "jsr:@denops/[email protected]";
import { is, maybe, type PredicateType } from "jsr:@core/[email protected]";

import { isOpener } from "../ui/open.ts";
import { ChatBase } from "../ui/chat.ts";
Expand Down
10 changes: 3 additions & 7 deletions denops/ollama/dispatch/start_chat_in_ctx.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { abortableAsyncIterable } from "https://deno.land/[email protected]/async/mod.ts";
import { type Denops } from "https://deno.land/x/[email protected]/mod.ts";
import {
is,
maybe,
type PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import { abortableAsyncIterable } from "jsr:@std/[email protected]";
import type { Denops } from "jsr:@denops/[email protected]";
import { is, maybe, type PredicateType } from "jsr:@core/[email protected]";

import {
generateChatCompletion,
Expand Down
5 changes: 1 addition & 4 deletions denops/ollama/dispatch/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
is,
PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import { is, type PredicateType } from "jsr:@core/[email protected]";

export const isReqArgs = is.ObjectOf({
timeout: is.OptionalOf(is.Number),
Expand Down
9 changes: 2 additions & 7 deletions denops/ollama/main.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import {
ensure,
is,
maybe,
Predicate,
} from "https://deno.land/x/[email protected]/mod.ts";
import type { Denops } from "jsr:@denops/[email protected]";
import { ensure, is, maybe, type Predicate } from "jsr:@core/[email protected]";

import { init } from "./dispatch/init.ts";
import { isStartChatArgs, startChat } from "./dispatch/start_chat.ts";
Expand Down
26 changes: 13 additions & 13 deletions denops/ollama/ui/chat.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { getLogger } from "https://deno.land/[email protected].0/log/mod.ts";
import * as datetime from "https://deno.land/[email protected].0/datetime/mod.ts";
import { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import { ulid } from "https://deno.land/std@0.224.0/ulid/mod.ts";
import * as autocmd from "https://deno.land/x/[email protected]/autocmd/mod.ts";
import * as fn from "https://deno.land/x/[email protected]/function/mod.ts";
import * as batch from "https://deno.land/x/[email protected]/batch/mod.ts";
import * as option from "https://deno.land/x/[email protected]/option/mod.ts";
import * as helper from "https://deno.land/x/[email protected]/helper/mod.ts";
import * as lambda from "https://deno.land/x/[email protected]/lambda/mod.ts";
import { ensure, is } from "https://deno.land/x/unknownutil@v3.18.1/mod.ts";
import { Notify, Queue } from "https://deno.land/x/async@v2.1.0/mod.ts";
import { getLogger } from "jsr:@std/log@0.224.5";
import * as datetime from "jsr:@std/datetime@0.224.3";
import type { Denops } from "jsr:@denops/[email protected]";
import { ulid } from "jsr:@std/[email protected]";
import * as autocmd from "jsr:@denops/[email protected]/autocmd";
import * as fn from "jsr:@denops/[email protected]/function";
import * as batch from "jsr:@denops/[email protected]/batch";
import * as option from "jsr:@denops/[email protected]/option";
import * as helper from "jsr:@denops/[email protected]/helper";
import * as lambda from "jsr:@denops/[email protected]/lambda";
import { ensure, is } from "jsr:@core/unknownutil@3.18.1";
import { Notify, Queue } from "jsr:@lambdalisue/async@2.1.1";

import {
type HighlightPrefix,
prepareHighlightPrefix,
} from "./highlight_prefix.ts";
import { canceller } from "../util/cancellable.ts";
import * as spinner from "./spinner.ts";
import { Opener } from "./open.ts";
import type { Opener } from "./open.ts";

export abstract class ChatBase<TContext> {
abstract parseContext(context: unknown): TContext | undefined;
Expand Down
2 changes: 1 addition & 1 deletion denops/ollama/ui/highlight_prefix.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Denops } from "https://deno.land/x/[email protected]/mod.ts";
import type { Denops } from "jsr:@denops/[email protected]";

export async function setup(denops: Denops) {
await denops.cmd("highlight default link OllamaPrompt Question");
Expand Down
5 changes: 1 addition & 4 deletions denops/ollama/ui/open.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
is,
PredicateType,
} from "https://deno.land/x/[email protected]/mod.ts";
import { is, type PredicateType } from "jsr:@core/[email protected]";

export const isOpener = is.OneOf([
is.LiteralOf("split"),
Expand Down
10 changes: 5 additions & 5 deletions denops/ollama/ui/spinner.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import spinners from "npm:[email protected]";
import { type SpinnerName as Kind } from "npm:[email protected]";
import { type Denops } from "https://deno.land/x/[email protected]/mod.ts";
import * as batch from "https://deno.land/x/[email protected]/batch/mod.ts";
import * as fn from "https://deno.land/x/[email protected]/function/mod.ts";
import { ensure, is } from "https://deno.land/x/unknownutil@v3.18.1/mod.ts";
import type { SpinnerName as Kind } from "npm:[email protected]";
import type { Denops } from "jsr:@denops/[email protected]";
import * as batch from "jsr:@denops/[email protected]/batch";
import * as fn from "jsr:@denops/[email protected]/function";
import { ensure, is } from "jsr:@core/unknownutil@3.18.1";

const varPrefix = "ollama_ui_spinner";
const signGroup = "ollama_ui_spinner_group";
Expand Down
4 changes: 2 additions & 2 deletions denops/ollama/ui/spinner_test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from "https://deno.land/x/[email protected]/mod.ts";
import { bufnr } from "https://deno.land/x/[email protected]/function/mod.ts";
import { test } from "jsr:@denops/[email protected]";
import { bufnr } from "jsr:@denops/[email protected]/function";
import * as target from "./spinner.ts";
import { default as sp, type SpinnerName } from "npm:[email protected]";

Expand Down
10 changes: 5 additions & 5 deletions denops/ollama/util/cancellable.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { map } from "https://deno.land/x/[email protected]/mapping/mod.ts";
import * as lambda from "https://deno.land/x/[email protected]/lambda/mod.ts";
import { ulid } from "https://deno.land/std@0.224.0/ulid/mod.ts";
import * as autocmd from "https://deno.land/x/[email protected]/autocmd/mod.ts";
import { Denops } from "https://deno.land/x/[email protected]/mod.ts";
import { map } from "jsr:@denops/[email protected]/mapping";
import * as lambda from "jsr:@denops/[email protected]/lambda";
import { ulid } from "jsr:@std/[email protected]";
import * as autocmd from "jsr:@denops/[email protected]/autocmd";
import type { Denops } from "jsr:@denops/[email protected]";

export async function mapCancel(denops: Denops) {
// See ../../../autoload/ollama/internal.vim
Expand Down
Loading

0 comments on commit ce13e21

Please sign in to comment.