Skip to content

Commit

Permalink
update mstdn.vim config
Browse files Browse the repository at this point in the history
  • Loading branch information
gw31415 committed Dec 14, 2023
1 parent 6f3a475 commit e0c86d0
Showing 1 changed file with 16 additions and 30 deletions.
46 changes: 16 additions & 30 deletions dot_config/nvim/dein/plugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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', "<Enter>", 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", "<Plug>(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 <buffer> <enter> <cmd>call mstdn#timeline#load_more()<cr>
nn <buffer> <expr> G getcurpos()[1] == line('$') ? "\<cmd>call mstdn#timeline#load_more()\<cr>" : "\<cmd>norm! G\<cr>"
nn <buffer><nowait> > <cmd>call mstdn#timeline#favourite()<cr>
nn <buffer><nowait> < <cmd>call mstdn#timeline#unfavourite()<cr>
" Configuration for mstdn-editor.vim
nn <buffer> i <Plug>(mstdn-editor-open)
endfunction
" auto reconnect
autocmd BufReadCmd mstdn://* call timer_start(1500, {-> mstdn#timeline#reconnect_all()}, #{repeat: -1})
'''

[[plugins]]
Expand Down

0 comments on commit e0c86d0

Please sign in to comment.