From 3905922cafd3f48fb7675d16ae4533b553f0001c Mon Sep 17 00:00:00 2001 From: kamecha Date: Tue, 12 Dec 2023 20:10:11 +0900 Subject: [PATCH 01/10] =?UTF-8?q?set=20signcolumn=3Dyes=E3=81=AB=E3=81=97?= =?UTF-8?q?=E3=81=A6=E5=B9=85=E3=82=92=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autoload/traqvim.vim | 2 +- ftplugin/traqvim.vim | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/traqvim.vim b/autoload/traqvim.vim index 842ad4a..94527b6 100644 --- a/autoload/traqvim.vim +++ b/autoload/traqvim.vim @@ -158,7 +158,7 @@ function! traqvim#make_message_body(message, width) abort endfor endif endif - let footer = [ "", repeat("─", a:width) ] + let footer = [ "", repeat("─", a:width - 2) ] " 2はsigncolumnの分 let messageBody = header + rows + quote + footer return messageBody endfunction diff --git a/ftplugin/traqvim.vim b/ftplugin/traqvim.vim index edc6d65..514d3ca 100644 --- a/ftplugin/traqvim.vim +++ b/ftplugin/traqvim.vim @@ -1,6 +1,6 @@ setlocal noswapfile -setlocal signcolumn=no +setlocal signcolumn=yes setlocal nolist nnoremap (traqvim-next) \ call traqvim#message_next() From 6dde7a732136ddbead2ec9ca795d5fa6d096e5e2 Mon Sep 17 00:00:00 2001 From: kamecha Date: Tue, 12 Dec 2023 20:11:29 +0900 Subject: [PATCH 02/10] =?UTF-8?q?signcolumn=E3=81=ABpin=E3=82=92=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autoload/helper.vim | 1 + autoload/traqvim.vim | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/autoload/helper.vim b/autoload/helper.vim index a957e9c..706aa4a 100644 --- a/autoload/helper.vim +++ b/autoload/helper.vim @@ -4,4 +4,5 @@ function! helper#define_highlight() abort highlight! VtraQScreenName ctermfg=lightmagenta guifg=lightmagenta cterm=bold highlight! link VtraQQuote Comment highlight! link VtraQMessage Keyword + highlight! link VtraQPin Keyword endfunction diff --git a/autoload/traqvim.vim b/autoload/traqvim.vim index 94527b6..e6d3b77 100644 --- a/autoload/traqvim.vim +++ b/autoload/traqvim.vim @@ -21,12 +21,22 @@ function! traqvim#draw_timeline(bufNum) abort let start = 1 let winnr = bufwinid(a:bufNum) let width = winwidth(winnr) + " TODO: nerd font導入してるかの確認とかしたいな + " call sign_define("pin", #{ text: "📌"}) + call sign_define("pin", #{ text: "󰐃", texthl: "VtraQPin"}) "f0403 ← nerd font導入後、これに対応してるらしい + call sign_define("pin_long", #{ text: "│" , texthl: "VtraQPin"}) for message in getbufvar(a:bufNum, "channelTimeline") let body = traqvim#make_message_body(message, width) let end = start + len(body) - 1 " 一度に全部描画するから、positionをここで設定する let message.position = #{ index: index, start: start, end: end } call setbufline(a:bufNum, start, body) + if message->get('pinned') + call sign_place(index, "VtraQ", "pin", a:bufNum, #{ lnum: start, priority: 10 }) + for i in range(start + 1, end - 1) + call sign_place(index, "VtraQ", "pin_long", a:bufNum, #{ lnum: i, priority: 10 }) + endfor + endif let start = end + 1 let index = index + 1 endfor From f29c561ee1d5ef3af9e3de9b874fab51d3aca0a9 Mon Sep 17 00:00:00 2001 From: kamecha Date: Tue, 12 Dec 2023 20:44:45 +0900 Subject: [PATCH 03/10] =?UTF-8?q?sign=E5=AE=A3=E8=A8=80=E3=81=AE=E5=A0=B4?= =?UTF-8?q?=E6=89=80=E3=82=92ftplugin=E3=81=AB=E3=81=97=E3=81=A6=E3=82=B0?= =?UTF-8?q?=E3=83=AD=E3=83=BC=E3=83=90=E3=83=AB=E3=81=AB=E3=81=97=E3=81=9F?= =?UTF-8?q?(=E3=81=93=E3=82=8C=E3=81=A7=E8=89=AF=E3=81=8B=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E3=81=AE=E3=81=8B=E5=88=86=E3=81=8B=E3=82=89=E3=82=93?= =?UTF-8?q?:awoo:)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autoload/traqvim.vim | 4 ---- ftplugin/traqvim.vim | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/autoload/traqvim.vim b/autoload/traqvim.vim index e6d3b77..f3a12f2 100644 --- a/autoload/traqvim.vim +++ b/autoload/traqvim.vim @@ -21,10 +21,6 @@ function! traqvim#draw_timeline(bufNum) abort let start = 1 let winnr = bufwinid(a:bufNum) let width = winwidth(winnr) - " TODO: nerd font導入してるかの確認とかしたいな - " call sign_define("pin", #{ text: "📌"}) - call sign_define("pin", #{ text: "󰐃", texthl: "VtraQPin"}) "f0403 ← nerd font導入後、これに対応してるらしい - call sign_define("pin_long", #{ text: "│" , texthl: "VtraQPin"}) for message in getbufvar(a:bufNum, "channelTimeline") let body = traqvim#make_message_body(message, width) let end = start + len(body) - 1 diff --git a/ftplugin/traqvim.vim b/ftplugin/traqvim.vim index 514d3ca..65d4d70 100644 --- a/ftplugin/traqvim.vim +++ b/ftplugin/traqvim.vim @@ -2,6 +2,12 @@ setlocal noswapfile setlocal signcolumn=yes setlocal nolist + +" TODO: nerd font導入してるかの確認とかしたいな +" call sign_define("pin", #{ text: "📌"}) +call sign_define("pin", #{ text: "󰐃", texthl: "VtraQPin"}) "f0403 ← nerd font導入後、これに対応してるらしい +call sign_define("pin_long", #{ text: "│" , texthl: "VtraQPin"}) + nnoremap (traqvim-next) \ call traqvim#message_next() nnoremap (traqvim-prev) From a03cc531fa4c0510d7e33c2d4ec0421c2e4df347 Mon Sep 17 00:00:00 2001 From: kamecha Date: Tue, 12 Dec 2023 20:49:23 +0900 Subject: [PATCH 04/10] =?UTF-8?q?redraw=E3=81=A7pin=E3=81=8C=E6=AE=8B?= =?UTF-8?q?=E3=82=89=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=80=81=E4=BA=88?= =?UTF-8?q?=E3=82=81=E5=89=8A=E9=99=A4=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autoload/traqvim.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/autoload/traqvim.vim b/autoload/traqvim.vim index f3a12f2..6ea0537 100644 --- a/autoload/traqvim.vim +++ b/autoload/traqvim.vim @@ -17,6 +17,7 @@ endfunction function! traqvim#draw_timeline(bufNum) abort call setbufvar(a:bufNum, "&modifiable", 1) + call sign_unplace("VtraQ", #{ buffer: a:bufNum }) let index = 0 let start = 1 let winnr = bufwinid(a:bufNum) From 0539afc634344a22f22553adf1ccbbb28fec16c0 Mon Sep 17 00:00:00 2001 From: kamecha Date: Tue, 12 Dec 2023 20:50:09 +0900 Subject: [PATCH 05/10] =?UTF-8?q?forwad,back=E7=AD=89=E3=81=9D=E3=82=8C?= =?UTF-8?q?=E3=81=9E=E3=82=8C=E3=81=AEdraw=E3=81=AB=E5=AF=BE=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=82=82pin=E3=81=AE=E6=8F=8F=E7=94=BB=E3=82=92?= =?UTF-8?q?=E9=81=A9=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autoload/traqvim.vim | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/autoload/traqvim.vim b/autoload/traqvim.vim index 6ea0537..5b4b487 100644 --- a/autoload/traqvim.vim +++ b/autoload/traqvim.vim @@ -51,6 +51,12 @@ function! traqvim#draw_forward_messages(bufNum, messages) abort let body = traqvim#make_message_body(message, width) let end = start + len(body) - 1 call appendbufline(a:bufNum, start - 1, body) + if message->get('pinned') + call sign_place(0, "VtraQ", "pin", a:bufNum, #{ lnum: start, priority: 10 }) + for i in range(start + 1, end - 1) + call sign_place(0, "VtraQ", "pin_long", a:bufNum, #{ lnum: i, priority: 10 }) + endfor + endif let start = end + 1 endfor " この関数を呼ばれる前に追加分が既にバッファ変数に登録されてる @@ -69,6 +75,12 @@ function! traqvim#draw_back_messages(bufNum, messages) abort let body = traqvim#make_message_body(message, width) let end = start + len(body) - 1 call appendbufline(a:bufNum, start - 1, body) + if message->get('pinned') + call sign_place(0, "VtraQ", "pin", a:bufNum, #{ lnum: start, priority: 10 }) + for i in range(start + 1, end - 1) + call sign_place(0, "VtraQ", "pin_long", a:bufNum, #{ lnum: i, priority: 10 }) + endfor + endif let start = end + 1 endfor " 既存のメッセージのpositionを更新する @@ -81,6 +93,12 @@ function traqvim#draw_delete_message(bufNum, message) abort call setbufvar(a:bufNum, "&modifiable", 1) let start = a:message.position["start"] let end = a:message.position["end"] + if a:message->get('pinned') + call sign_unplace("VtraQ", #{ buffer: a:bufNum, lnum: start }) + for i in range(start + 1, end - 1) + call sign_unplace("VtraQ", #{ buffer: a:bufNum, lnum: i }) + endfor + endif call deletebufline(a:bufNum, start, end) " 既存のメッセージのpositionを更新する " この関数を呼ばれる前に削除分が既にバッファ変数から削除されてる @@ -109,6 +127,12 @@ function traqvim#draw_insert_message(bufNum, message) abort let body = traqvim#make_message_body(a:message, width) let end = start + len(body) - 1 call appendbufline(a:bufNum, start - 1, body) + if a:message->get('pinned') + call sign_place(0, "VtraQ", "pin", a:bufNum, #{ lnum: start, priority: 10 }) + for i in range(start + 1, end - 1) + call sign_place(0, "VtraQ", "pin_long", a:bufNum, #{ lnum: i, priority: 10 }) + endfor + endif " 既存のメッセージのpositionを更新する call map(timeline, function("traqvim#update_message_position", [timeline])) call setbufvar(a:bufNum, "&modifiable", 0) From 45feaa2f7161b9a4884b057396d39bf25a6fd18e Mon Sep 17 00:00:00 2001 From: kamecha Date: Tue, 12 Dec 2023 20:52:41 +0900 Subject: [PATCH 06/10] =?UTF-8?q?sign=E3=81=AEid=E3=82=92=E7=84=A1?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autoload/traqvim.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/traqvim.vim b/autoload/traqvim.vim index 5b4b487..ecc96ff 100644 --- a/autoload/traqvim.vim +++ b/autoload/traqvim.vim @@ -29,9 +29,9 @@ function! traqvim#draw_timeline(bufNum) abort let message.position = #{ index: index, start: start, end: end } call setbufline(a:bufNum, start, body) if message->get('pinned') - call sign_place(index, "VtraQ", "pin", a:bufNum, #{ lnum: start, priority: 10 }) + call sign_place(0, "VtraQ", "pin", a:bufNum, #{ lnum: start, priority: 10 }) for i in range(start + 1, end - 1) - call sign_place(index, "VtraQ", "pin_long", a:bufNum, #{ lnum: i, priority: 10 }) + call sign_place(0, "VtraQ", "pin_long", a:bufNum, #{ lnum: i, priority: 10 }) endfor endif let start = end + 1 From 4fbe860f38479596abda9c6878fe447fd5819ab8 Mon Sep 17 00:00:00 2001 From: kamecha Date: Wed, 13 Dec 2023 19:34:33 +0900 Subject: [PATCH 07/10] =?UTF-8?q?=E5=AF=BE=E5=BF=9C=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=81=AE=E3=83=94?= =?UTF-8?q?=E3=83=B3=E3=81=A0=E3=81=91=E3=81=AE=E6=8F=8F=E7=94=BB=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E9=96=A2=E6=95=B0=E3=81=AE=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autoload/traqvim.vim | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/autoload/traqvim.vim b/autoload/traqvim.vim index ecc96ff..8071716 100644 --- a/autoload/traqvim.vim +++ b/autoload/traqvim.vim @@ -41,6 +41,35 @@ function! traqvim#draw_timeline(bufNum) abort call setbufvar(a:bufNum, "&modifiable", 0) endfunction +function traqvim#draw_message_pin(bufNum, message) abort + call setbufvar(a:bufNum, "&modifiable", 1) + let start = a:message.position["start"] + let end = a:message.position["end"] + if a:message->get('pinned') + call sign_place(0, "VtraQ", "pin", a:bufNum, #{ lnum: start, priority: 10 }) + for i in range(start + 1, end - 1) + call sign_place(0, "VtraQ", "pin_long", a:bufNum, #{ lnum: i, priority: 10 }) + endfor + else + " unplaceはbufferとidしか指定できない + let pin_signs = sign_getplaced(a:bufNum, #{ group: "VtraQ", lnum: start }) + \ ->filter({ _, v -> v->get('bufnr') == a:bufNum }) + \ ->get(0) + call sign_unplace( + \"VtraQ", + \#{ buffer: a:bufNum, id: pin_signs->get('signs')->get(0)->get('id') }) + for i in range(start + 1, end - 1) + let pin_long_signs = sign_getplaced(a:bufNum, #{ group: "VtraQ", lnum: i }) + \ ->filter({ _, v -> v->get('bufnr') == a:bufNum }) + \ ->get(0) + call sign_unplace( + \"VtraQ", + \#{ buffer: a:bufNum, id: pin_long_signs->get('signs')->get(0)->get('id') }) + endfor + endif + call setbufvar(a:bufNum, "&modifiable", 0) +endfunction + function! traqvim#draw_forward_messages(bufNum, messages) abort call setbufvar(a:bufNum, "&modifiable", 1) " startをバッファの最下値にする From e5554c7646c5ce42d756015f12eb4bc251b5be59 Mon Sep 17 00:00:00 2001 From: kamecha Date: Wed, 13 Dec 2023 19:38:17 +0900 Subject: [PATCH 08/10] =?UTF-8?q?pin=E4=BD=9C=E6=88=90=E3=81=AE=E4=B8=80?= =?UTF-8?q?=E9=80=A3=E3=81=AE=E6=B5=81=E3=82=8C=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- denops/traqvim/action.ts | 32 ++++++++++++++++++++++++++++++++ denops/traqvim/main.ts | 9 +++++++++ denops/traqvim/model.ts | 11 +++++++++++ plugin/traqvim.vim | 2 ++ 4 files changed, 54 insertions(+) diff --git a/denops/traqvim/action.ts b/denops/traqvim/action.ts index a2c0c80..2382efd 100644 --- a/denops/traqvim/action.ts +++ b/denops/traqvim/action.ts @@ -4,6 +4,7 @@ import { activity, channelMessageOptions, channelTimeline, + createPin, deleteMessage, editMessage, } from "./model.ts"; @@ -184,3 +185,34 @@ export const actionYankMessageMarkdown = async ( await fn.setreg(denops, '"', message.content); await helper.echo(denops, "Yanked message markdown"); }; + +export const actionCreatePin = async ( + denops: Denops, + message: Message, + bufNum: number, +): Promise => { + try { + await createPin(message.id); + } catch (e) { + console.error(e); + return; + } + // 既存メッセージの取得 + const timeline = await vars.buffers.get(denops, "channelTimeline"); + ensureArray(timeline); + message.pinned = true; + // ピン留めしたものをセット + await vars.buffers.set( + denops, + "channelTimeline", + timeline.map((m) => { + if (m.id === message.id) { + return message; + } else { + return m; + } + }), + ); + await denops.call("traqvim#draw_message_pin", bufNum, message); +}; + diff --git a/denops/traqvim/main.ts b/denops/traqvim/main.ts index 5cc600d..4815c65 100644 --- a/denops/traqvim/main.ts +++ b/denops/traqvim/main.ts @@ -18,6 +18,7 @@ import { } from "./deps.ts"; import { actionBackChannelMessage, + actionCreatePin, actionDeleteMessage, actionEditMessage, actionForwardChannelMessage, @@ -337,5 +338,13 @@ export async function main(denops: Denops) { await denops.cmd(":bdelete"); return; }, + async createPin( + bufNum: unknown, + message: unknown, + ): Promise { + ensureNumber(bufNum); + await actionCreatePin(denops, message as Message, bufNum); + return; + }, }; } diff --git a/denops/traqvim/model.ts b/denops/traqvim/model.ts index 8a2c290..2e9e833 100644 --- a/denops/traqvim/model.ts +++ b/denops/traqvim/model.ts @@ -291,3 +291,14 @@ export const editMessage = async ( console.error(e); } }; + +export const createPin = async ( + messageId: string, +): Promise => { + try { + await api.api.createPin(messageId); + } catch (e) { + console.error(e); + } +}; + diff --git a/plugin/traqvim.vim b/plugin/traqvim.vim index 9585a73..8919d5e 100644 --- a/plugin/traqvim.vim +++ b/plugin/traqvim.vim @@ -29,6 +29,8 @@ command! TraqMessageDelete call denops#request('traqvim', 'messageDelete', [bufn command! TraqMessageEdit call denops#request('traqvim', 'messageEditOpen', [bufnr(), traqvim#get_message()]) " messageの編集を適用 command! TraqMessageEditApply call denops#request('traqvim', 'messageEdit', [getbufvar(bufname("%"), "editSourceBuffer"), getbufvar(bufname("%"), "message"), getline(1, '$')]) +" pinを作成 +command! TraqCreatePin call denops#request('traqvim', 'createPin', [bufnr(), traqvim#get_message()]) call helper#define_highlight() From 5e8e92298ea483b5a85645859d4d5bee8b9b27f8 Mon Sep 17 00:00:00 2001 From: kamecha Date: Wed, 13 Dec 2023 19:38:32 +0900 Subject: [PATCH 09/10] =?UTF-8?q?pin=E5=89=8A=E9=99=A4=E3=81=AE=E4=B8=80?= =?UTF-8?q?=E9=80=A3=E3=81=AE=E6=B5=81=E3=82=8C=E3=82=92=E5=AE=9F=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- denops/traqvim/action.ts | 30 ++++++++++++++++++++++++++++++ denops/traqvim/main.ts | 9 +++++++++ denops/traqvim/model.ts | 9 +++++++++ plugin/traqvim.vim | 2 ++ 4 files changed, 50 insertions(+) diff --git a/denops/traqvim/action.ts b/denops/traqvim/action.ts index 2382efd..f30f0ad 100644 --- a/denops/traqvim/action.ts +++ b/denops/traqvim/action.ts @@ -7,6 +7,7 @@ import { createPin, deleteMessage, editMessage, + removePin, } from "./model.ts"; export const actionOpenChannel = async ( @@ -216,3 +217,32 @@ export const actionCreatePin = async ( await denops.call("traqvim#draw_message_pin", bufNum, message); }; +export const actionRemovePin = async ( + denops: Denops, + message: Message, + bufNum: number, +): Promise => { + try { + await removePin(message.id); + } catch (e) { + console.error(e); + return; + } + // 既存メッセージの取得 + const timeline = await vars.buffers.get(denops, "channelTimeline"); + ensureArray(timeline); + message.pinned = false; + // ピン留め解除したものをセット + await vars.buffers.set( + denops, + "channelTimeline", + timeline.map((m) => { + if (m.id === message.id) { + return message; + } else { + return m; + } + }), + ); + await denops.call("traqvim#draw_message_pin", bufNum, message); +}; diff --git a/denops/traqvim/main.ts b/denops/traqvim/main.ts index 4815c65..a4f3086 100644 --- a/denops/traqvim/main.ts +++ b/denops/traqvim/main.ts @@ -24,6 +24,7 @@ import { actionForwardChannelMessage, actionOpenActivity, actionOpenChannel, + actionRemovePin, actionYankMessageLink, actionYankMessageMarkdown, } from "./action.ts"; @@ -346,5 +347,13 @@ export async function main(denops: Denops) { await actionCreatePin(denops, message as Message, bufNum); return; }, + async removePin( + bufNum: unknown, + message: unknown, + ): Promise { + ensureNumber(bufNum); + await actionRemovePin(denops, message as Message, bufNum); + return; + }, }; } diff --git a/denops/traqvim/model.ts b/denops/traqvim/model.ts index 2e9e833..de97a66 100644 --- a/denops/traqvim/model.ts +++ b/denops/traqvim/model.ts @@ -302,3 +302,12 @@ export const createPin = async ( } }; +export const removePin = async ( + messageId: string, +): Promise => { + try { + await api.api.removePin(messageId); + } catch (e) { + console.error(e); + } +}; diff --git a/plugin/traqvim.vim b/plugin/traqvim.vim index 8919d5e..169a161 100644 --- a/plugin/traqvim.vim +++ b/plugin/traqvim.vim @@ -31,6 +31,8 @@ command! TraqMessageEdit call denops#request('traqvim', 'messageEditOpen', [bufn command! TraqMessageEditApply call denops#request('traqvim', 'messageEdit', [getbufvar(bufname("%"), "editSourceBuffer"), getbufvar(bufname("%"), "message"), getline(1, '$')]) " pinを作成 command! TraqCreatePin call denops#request('traqvim', 'createPin', [bufnr(), traqvim#get_message()]) +" pinを削除 +command! TraqRemovePin call denops#request('traqvim', 'removePin', [bufnr(), traqvim#get_message()]) call helper#define_highlight() From 7c7095681c0400988311060fee07103af6489952 Mon Sep 17 00:00:00 2001 From: kamecha Date: Wed, 13 Dec 2023 19:53:12 +0900 Subject: [PATCH 10/10] =?UTF-8?q?pin=E3=81=AE=E3=83=88=E3=82=B0=E3=83=AB?= =?UTF-8?q?=E7=94=A8=E3=81=AE=E3=82=AA=E3=83=9A=E3=83=AC=E3=83=BC=E3=82=BF?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autoload/traqvim.vim | 21 +++++++++++++++++++++ ftplugin/traqvim.vim | 5 +++++ 2 files changed, 26 insertions(+) diff --git a/autoload/traqvim.vim b/autoload/traqvim.vim index 8071716..51cee8e 100644 --- a/autoload/traqvim.vim +++ b/autoload/traqvim.vim @@ -315,6 +315,27 @@ function traqvim#deleteMessage(t) abort call denops#request('traqvim', 'messageDelete', [bufnr(), messageStart]) endfunction +function traqvim#registerTogglePin() abort + let &opfunc = function('traqvim#togglePin') + return 'g@' +endfunction + +function traqvim#togglePin(t) abort + if a:t != 'line' + return + endif + let messageStart = traqvim#get_message_buf(line("'["), bufnr('%')) + let messageEnd = traqvim#get_message_buf(line("']"), bufnr('%')) + if messageStart->get('id') != messageEnd->get('id') + return + endif + if messageStart->get('pinned') + call denops#request('traqvim', 'removePin', [bufnr(), messageStart]) + else + call denops#request('traqvim', 'createPin', [bufnr(), messageStart]) + endif +endfunction + function traqvim#message_motion() abort let position = traqvim#get_message()->get('position') call cursor(position->get('start'), 1) diff --git a/ftplugin/traqvim.vim b/ftplugin/traqvim.vim index 65d4d70..66b6967 100644 --- a/ftplugin/traqvim.vim +++ b/ftplugin/traqvim.vim @@ -19,6 +19,8 @@ nnoremap (traqvim-yank-message-markdown-operator) \ traqvim#registerYankMessageMarkdown() nnoremap (traqvim-delete-message-operator) \ traqvim#registerDeleteMessage() +nnoremap (traqvim-toggle-pin-operator) + \ traqvim#registerTogglePin() onoremap (traqvim-message-motion) \ :call traqvim#message_motion() @@ -35,6 +37,9 @@ nmap Y nmap d \ (traqvim-delete-message-operator) +nmap p + \ (traqvim-toggle-pin-operator) + command! -buffer -nargs=0 TraqYankMessageLink \ call denops#request('traqvim', 'yankMessageLink', [traqvim#get_message()]) command! -buffer -nargs=0 TraqYankMessageMarkdown