-ls not working
avegancafe opened this issue · 14 comments
So I'm having this issue where :Gist -ls isn't working at all (It just prints "Not Found"). I have 1 starred gist, so there's definitely at least one, but even so, it would be nice if it said like "No starred Gists" or something instead of "Not Found", since it also says that if the url is broken, which was confusing.
Do you have ~/.gist-vim that contains github token? (note: please don't paste it at here)
Yes, I have a key. I can also do many of the other things described in the gist-vim README.
Could you please try following? (please note that don't paste private contents)
apply patch following
diff --git a/autoload/gist.vim b/autoload/gist.vim
index 0cd0c97..032367c 100644
--- a/autoload/gist.vim
+++ b/autoload/gist.vim
@@ -190,6 +190,7 @@ function! s:GistList(gistls, page) abort
echohl ErrorMsg | echomsg 'Gists not found' | echohl None
return
endif
+ let g:debug = res
let content = webapi#json#decode(res.content)
if type(content) == 4 && has_key(content, 'message') && len(content.message)
bw!:Gist -ls
:echo g:debug
{'status': '404', 'header': ['Server: GitHub.com', 'Date: Fri, 10 Apr 2015 00:39:08
GMT', 'Content-Type: application/json; charset=utf-8', 'Content-Length: 87', 'Stat
us: 404 Not Found', 'X-RateLimit-Limit: 5000', 'X-RateLimit-Remaining: 4999', 'X-Ra
teLimit-Reset: 1428629948', 'X-OAuth-Scopes: gist', 'X-Accepted-OAuth-Scopes: repo'
, 'X-GitHub-Media-Type: github.v3', 'X-XSS-Protection: 1; mode=block', 'X-Frame-Opt
ions: deny', 'Content-Security-Policy: default-src ''none''', 'Access-Control-Allow
-Credentials: true', 'Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-Ra
teLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted
-OAuth-Scopes, X-Poll-Interval', 'Access-Control-Allow-Origin: *', 'X-GitHub-Reques
t-Id: 9B2977EE:1B15:364684:55271BAC', 'Strict-Transport-Security: max-age=31536000;
includeSubdomains; preload', 'X-Content-Type-Options: nosniff'], 'message': 'Not F
ound', 'content': '{
"message": "Not Found",
"documentation_url": "https://developer.github.com/v3"
}
'}
Looks like the url is invalid
What is gist_api_url?
:Gist -ls
:echo gist_api_url
should be printed as https://api.github.com/
That is indeed the url that is printed
Hmm, could you please remove ~/.gist-vim or rename it at once?
Yeah I tried doing that a couple times, didn't help
Did you input password for authentication?
Yup
Hi, I know that this is an old issue, but just in case: I fixed this by adding let g:gist_show_privates = 1 to my .vimrc.
I don't know if this is a bug or not. I noticed that the used URL ended up being https://api.github.com/users/starred/gists (which as far as I can tell is not valid) and then in this part of the code:
if a:gistls ==# '-all'
let url = g:gist_api_url.'gists/public'
elseif get(g:, 'gist_show_privates', 0) && a:gistls ==# 'starred'
let url = g:gist_api_url.'gists/starred'
elseif get(g:, 'gist_show_privates') && a:gistls ==# 'mine'
let url = g:gist_api_url.'gists'
else
let url = g:gist_api_url.'users/'.a:gistls.'/gists'
endif
it seems like the else branch ends up being used and so the resulting URL is the one I mentioned.
Hope this helps!
That fix worked for me @fvictorio ! I actually just checked out mine, and it looks like it's going to this:
https://api.github.com/users/kylelholzinger@gmail.com/gists
instead of this:
https://api.github.com/users/kyleholzinger/gists
Going to look into opening up a PR to fix this
update @fvictorio: I nailed down that on line 801 it sets gistls to g:github_user, which will default to the output of the command gith config --get github.user. In my case it was my email, but I changed it to my username and now it's working. Probably should be something in the readme? Not sure
Already noted in README.
$ git config --global github.user Username