diff --git a/dot_config/nvim/dein/plugin.toml b/dot_config/nvim/dein/plugin.toml index 2ac8058..5a56596 100644 --- a/dot_config/nvim/dein/plugin.toml +++ b/dot_config/nvim/dein/plugin.toml @@ -13,37 +13,23 @@ repo = "lambdalisue/kensaku.vim" [[plugins]] repo = "gw31415/mstdn.vim" -lua_add = ''' -vim.api.nvim_create_autocmd("BufReadCmd", { - pattern = "mstdn://*", - callback = function() - vim.cmd "setl nonu so=0" - vim.keymap.set('n', "G", function() - if vim.fn.getcurpos()[2] == vim.fn.line('$') then - -- 最下部で `G` するとさらに取得 - vim.fn["mstdn#timeline#load_more"]() - end - vim.cmd "norm! G" - end, { buffer = true }) - vim.keymap.set('n', "", function() - -- アイテム選択だが、今のところload_moreくらいしかない - vim.fn["mstdn#timeline#load_more"]() - end, { buffer = true }) - vim.keymap.set('n', ">>", function() vim.fn["mstdn#timeline#favourite"]() end, { buffer = true }) - vim.keymap.set('n', "<<", function() vim.fn["mstdn#timeline#unfavourite"]() end, { buffer = true }) - vim.keymap.set('n', "i", "(mstdn-open-editor)", { buffer = true }) - end -}) +hook_add = ''' +autocmd BufReadCmd mstdn://* call s:mstdn_config() +function s:mstdn_config() abort + " Some preferences + setl nonu so=0 scl=yes -vim.api.nvim_create_autocmd("BufReadCmd", { - pattern = "mstdn://*", - once = true, - callback = function() - vim.fn.timer_start("1500", function() - vim.fn["mstdn#timeline#reconnect_all"]() - end, { ["repeat"] = -1 }) - end -}) + " Key mappings + nn call mstdn#timeline#load_more() + nn G getcurpos()[1] == line('$') ? "\call mstdn#timeline#load_more()\" : "\norm! G\" + nn > call mstdn#timeline#favourite() + nn < call mstdn#timeline#unfavourite() + + " Configuration for mstdn-editor.vim + nn i (mstdn-editor-open) +endfunction +" auto reconnect +autocmd BufReadCmd mstdn://* call timer_start(1500, {-> mstdn#timeline#reconnect_all()}, #{repeat: -1}) ''' [[plugins]]