Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: async support #202

Open
chemzqm opened this issue Feb 21, 2016 · 3 comments
Open

Feature request: async support #202

chemzqm opened this issue Feb 21, 2016 · 3 comments

Comments

@chemzqm
Copy link

chemzqm commented Feb 21, 2016

I have a slow network with github.com in China, it would be great if this plugin support async feature if possible.

Both vim and neovim could support async process now.

@jalcine
Copy link

jalcine commented Mar 10, 2016

@chemzqm commented on Feb 21, 2016, 5:34 AM PST:

I have a slow network with github.com in China, it would be great if this plugin support async feature if possible.

Both vim and neovim could support async process now.

This would require support in webapi-vim for asynchronous networking (for it to be fully transparent). @mattn, does that make sense?

@mattn
Copy link
Owner

mattn commented Mar 10, 2016

@jalcine right. but the async with only vim script is harder to implement. it's easy to use external command like below.

let job = job_start(["gist", "/tmp/gistXXXXX"], {"callback": "GistDone"})

But job-control feature is still experimental. And remote_expr() works only on Windows or X11 environment.

@wsdjeg
Copy link

wsdjeg commented Jun 29, 2016

@chemzqm
I am working on an lib Github-api.vim, I just impl the api of gist, but there are some issues.
here is my two func for create gist.

""
" @public
" Create a gist
"
" POST : /gists
" Input: >
"    {
"      "description": "the description for this gist",
"      "public": true,
"      "files": {
"        "file1.txt": {
"          "content": "String file contents"
"        }
"      }
"    }
" <
function! githubapi#gist#Create(desc,filename,content,public,user,password) abort
    let data = {}
    let data.description = a:desc
    let data.public = a:public
    call extend(data, {'files': {a:filename : {'content' :a:content}}})
    return githubapi#util#Get('gists', " -d '" . json_encode(data) . "' -X POST -u " . a:user . ':' .a:password)
endfunction
function! githubapi#util#Get(url,args) abort
    let cmd = 'curl -s "' .g:githubapi_root_url . a:url . '"'
    if !empty(a:args)
        let cmd = cmd . a:args
    endif
    call githubapi#util#log('util#Get cmd : ' . cmd)
    let result = join(systemlist(cmd),"\n")
    return empty(result) ? result : json_decode(result)
endfunction

if I run

echo githubapi#gist#Create('test create','test.text','hello word','true','wsdjeg','mypassword').html_url 

then I can see the url of the created gist.
but if I run

echo githubapi#gist#Create('test create','test.text',join(getline(1,'$'), "\n"),'true','wsdjeg','mypassword').html_url

I get a lot of error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants