Skip to content

Commit

Permalink
該当メッセージに対応するチャンネルを開くようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
kamecha committed Jul 29, 2024
1 parent bfb5b7c commit 809492a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
8 changes: 8 additions & 0 deletions autoload/traqvim/message.vim
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ function traqvim#message#message_next() abort
call cursor([next.position["start"], 0])
endfunction

function traqvim#message#goto_message() abort
let message = traqvim#message#get_message()
if empty(message)
return
endif
call denops#request('traqvim', 'timelineMessage', [message])
endfunction

function traqvim#message#registerYankMessageLink() abort
let &opfunc = function('traqvim#message#yankMessageLink')
return 'g@'
Expand Down
2 changes: 2 additions & 0 deletions denops/traqvim/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { isMessage } from "./type_check.ts";
export const actionOpenChannel = async (
denops: Denops,
channelMessageOptions: channelMessageOptions,
message?: Message,
bufNum?: number,
): Promise<void> => {
helper.echo(denops, "actionOpenChannel");
Expand All @@ -27,6 +28,7 @@ export const actionOpenChannel = async (
const escapedChannelPath = bufname.format({
scheme: "VtraQ",
expr: "/Channel",
params: message ? { message: message.id } : undefined,
fragment: channelMessageOptions.channelPath.replace("#", ""),
});
const channelBufferVars: ChannelBuffer = {
Expand Down
16 changes: 15 additions & 1 deletion denops/traqvim/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,20 @@ export async function main(denops: Denops) {
await actionOpenChannel(denops, timelineOption);
return;
},
async timelineMessage(message: unknown): Promise<unknown> {
assert(message, isMessage);
const limit = await vars.globals.get(denops, "traqvim#fetch_limit");
assert(limit, is.Number);
const timelineOption: channelMessageOptions = {
id: message.channelId,
limit: limit,
until: message.createdAt,
inclusive: true,
order: "desc",
};
await actionOpenChannel(denops, timelineOption, message);
return;
},
async activity(): Promise<unknown> {
await actionOpenActivity(denops);
return;
Expand Down Expand Up @@ -152,7 +166,7 @@ export async function main(denops: Denops) {
inclusive: true,
order: "desc",
};
actionOpenChannel(denops, timelineOption, bufNum);
actionOpenChannel(denops, timelineOption, undefined, bufNum);
}
return;
},
Expand Down
2 changes: 2 additions & 0 deletions ftplugin/traqvim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ nnoremap <buffer><silent> <Plug>(traqvim-next)
\ <Cmd>call traqvim#message#message_next()<CR>
nnoremap <buffer><silent> <Plug>(traqvim-prev)
\ <Cmd>call traqvim#message#message_prev()<CR>
nnoremap <buffer><silent> <Plug>(traqvim-goto)
\ <Cmd>call traqvim#message#goto_message()<CR>
nnoremap <buffer><expr> <Plug>(traqvim-operator-message-yank-link)
\ traqvim#message#registerYankMessageLink()
Expand Down

0 comments on commit 809492a

Please sign in to comment.