-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
92 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
" fake textobj-entire | ||
onoremap ae <Cmd>normal! gg0vG$<CR> | ||
xnoremap ae gg0oG$ | ||
" yank operation | ||
"" L<denops-vimrc-yank> | ||
xnoremap <CR> <Cmd>call vimrc#denops#request('yank', 'yank', [getregion(getpos('v'), getpos('.'), #{type: mode()})])<CR>:<C-u><Esc> | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * as TOML from "/data/vim/repos/github.com/denoland/deno_std/toml/mod.ts"; | ||
export * as stdpath from "/data/vim/repos/github.com/denoland/deno_std/path/mod.ts"; | ||
export * from "/data/vim/repos/github.com/denoland/deno_std/encoding/base64.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { encodeBase64 } from "../@deps/deno_std.ts"; | ||
import { Denops } from "../@deps/denops_std.ts"; | ||
|
||
async function yankDetachWayland(text: string) { | ||
const wlCopy = new Deno.Command("wl-copy", { | ||
stdin: "piped", | ||
stdout: "null", | ||
stderr: "null", | ||
}).spawn(); | ||
const w = wlCopy.stdin.getWriter(); | ||
w.write(new TextEncoder().encode(text)) | ||
.finally(() => w.close()); | ||
await wlCopy.status; | ||
// detach tmux for VIME use | ||
await new Deno.Command("tmux", { | ||
args: ["detach-client"], | ||
}).output(); | ||
} | ||
|
||
async function oscyank(denops: Denops, text: string) { | ||
const content = `\x1b]52;c;${encodeBase64(text)}\x1b\\`; | ||
if (denops.meta.host == "vim") { | ||
await denops.call("echoraw", content); | ||
} else { | ||
await denops.call("luaeval", "vim.api.nvim_chan_send(2, _A)", content); | ||
} | ||
} | ||
|
||
function union(text: unknown) { | ||
if (Array.isArray(text)) { | ||
return text.join("\n"); | ||
} | ||
return String(text); | ||
} | ||
|
||
// X<denops-vimrc-yank> | ||
export async function main(denops: Denops) { | ||
const isWayland = Deno.env.get("WAYLAND_DISPLAY") != "" && | ||
Boolean(await denops.call("executable", "wl-copy")); | ||
denops.dispatcher = { | ||
async yank(text: unknown) { | ||
const trimText = union(text).trimEnd(); | ||
if (isWayland) { | ||
await yankDetachWayland(trimText); | ||
} else { | ||
await oscyank(denops, trimText); | ||
} | ||
}, | ||
}; | ||
// await denops.cmd( | ||
// `nnoremap <CR> <Cmd>call denops#request('${denops.name}', 'yank', [getline(1, '$')->join("\\n")])<CR>`, | ||
// ); | ||
// await denops.cmd( | ||
// `xnoremap <CR> y<Cmd>call denops#request('${denops.name}', 'yank', [getreg(v:register)])<CR>`, | ||
// ); | ||
} |