lambdalisue / vim-gista

An alternative gist.vim, vim plugin which manipulate gists in Vim.
http://www.vim.org/scripts/script.php?script_id=4976
MIT License
156 stars 5 forks source link

Do ':OpenBrowser' after ':Gista post' #67

Closed tyru closed 8 years ago

tyru commented 8 years ago

The following setting allows :Gista post to execute :call openbrowser#open('https://gist.github.com/' . gist.id) after post. (Currently disabled by default. Or should enable by default if open-browser is installed?)

let g:gista#command#post#open_browser = 1

If you prefer, I will update help also :)

lambdalisue commented 8 years ago

I'm sorry but I don't want to put any code for other plugin to make things clear (that's why I made vim-gista-unite or vim-gista-ctrlp separately). If you need such action, I will prepare some hook function.

lambdalisue commented 8 years ago

相談なので日本語で。

前述したとおり外部プラグイン関連のコードを加えるのには抵抗があるので hook or User autocmd がいいと思っているのですが、どちらが良いと思いますか?

hook の場合は gist というインスタンスを受け取る関数を定義してもらう形になると思います。例

function s:hook(gist) abort
    let url = a:gist.html_url
    " do something
endfunction
let g:gista#command#post#hook = function('s:hook')

User autocmd の場合は gita#command#browse#call で現在のバッファの URL が取れるのでそれを使っていただくか gita#command#browse#open とかでブラウザ開いていただく形になります。例

function! s:autocmd() abort
   let url = gista#command#browse#call()
   " do something
endfunction

Vim 的には autocmd かなーという気もしているのですが

tyru commented 8 years ago

あー実装が楽な方でいいですよ(おそらくUser autocmdのが楽?)。 というか設定側もUser autocmdのが楽だと思うので、やっぱUser autocmdでw

lambdalisue commented 8 years ago

GistaPost is available on https://github.com/lambdalisue/vim-gista/pull/68

Example:

function! s:on_GistaPost() abort
  let gistid = g:gista#avars.gistid
  execute printf('Gista browse --gistid=%s', gistid)
endfunction
augroup my_vim_gista_autocmd
  autocmd! *
  autocmd User GistaPost call s:on_GistaPost()
augroup END
tyru commented 8 years ago

Thanks!

tyru commented 8 years ago

Confirmed :metal:

tyru commented 8 years ago

Confirmed :metal:

Oh... I don't know the details of this sign... But I learned today that this sign has a offensive meaning... https://ja.wikipedia.org/wiki/%E3%82%B3%E3%83%AB%E3%83%8A

This is why non-verbal language shouldn't be used without knowing the meaning enough ;)