9
9
let s: save_cpo = &cpo
10
10
set cpo &vim
11
11
12
+ if exists (' g:gist_disabled' ) && g: gist_disabled == 1
13
+ function gist#Gist (... )
14
+ endfunction
15
+ finish
16
+ endif
17
+
12
18
if ! exists (' g:github_user' ) && ! executable (' git' )
13
19
echohl ErrorMsg | echomsg " Gist: require 'git' command" | echohl None
14
20
finish
@@ -39,6 +45,20 @@ if !exists('g:gist_api_url')
39
45
if strlen (g: gist_api_url ) == 0
40
46
let g: gist_api_url = ' https://api.github.com/'
41
47
end
48
+ if exists (' g:github_api_url' ) && ! exists (' g:gist_shutup_issue154' )
49
+ if matchstr (g: gist_api_url , ' https\?://\zs[^/]\+\ze' ) != matchstr (g: github_api_url , ' https\?://\zs[^/]\+\ze' )
50
+ echohl WarningMsg
51
+ echo " --- Warning ---"
52
+ echo " It seems that you set different URIs for github_api_url/gist_api_url."
53
+ echo " If you want to remove this message: let g:gist_shutup_issue154 = 1"
54
+ echohl None
55
+ if confirm (" Continue?" , " &Yes\n &No" ) != 1
56
+ let g: gist_disabled = 1
57
+ finish
58
+ endif
59
+ redraw !
60
+ endif
61
+ endif
42
62
endif
43
63
44
64
if ! exists (' g:gist_update_on_write' )
@@ -115,7 +135,7 @@ endfunction
115
135
116
136
" Note: A colon in the file name has side effects on Windows due to NTFS Alternate Data Streams; avoid it.
117
137
let s: bufprefix = ' gist' . (has (' unix' ) ? ' :' : ' _' )
118
- function ! s: GistList (gistls, page)
138
+ function ! s: GistList (gistls, page) abort
119
139
if a: gistls == ' -all'
120
140
let url = g: gist_api_url .' gists/public'
121
141
elseif get (g: , ' gist_show_privates' , 0 ) && a: gistls == ' starred'
@@ -216,7 +236,7 @@ function! gist#list(user, ...)
216
236
return webapi#json#decode (res .content)
217
237
endfunction
218
238
219
- function ! s: GistGetFileName (gistid)
239
+ function ! s: GistGetFileName (gistid) abort
220
240
let auth = s: GistGetAuthHeader ()
221
241
if len (auth) == 0
222
242
return ' '
@@ -229,7 +249,7 @@ function! s:GistGetFileName(gistid)
229
249
return ' '
230
250
endfunction
231
251
232
- function ! s: GistDetectFiletype (gistid)
252
+ function ! s: GistDetectFiletype (gistid) abort
233
253
let auth = s: GistGetAuthHeader ()
234
254
if len (auth) == 0
235
255
return ' '
@@ -246,7 +266,7 @@ function! s:GistDetectFiletype(gistid)
246
266
silent ! exec " setlocal ft=" .tolower (type )
247
267
endfunction
248
268
249
- function ! s: GistWrite (fname)
269
+ function ! s: GistWrite (fname) abort
250
270
if substitute (a: fname , ' \\' , ' /' , ' g' ) == expand (" %:p:gs@\\ @/@" )
251
271
if g: gist_update_on_write != 2 || v: cmdbang
252
272
Gist - e
@@ -260,7 +280,7 @@ function! s:GistWrite(fname)
260
280
endif
261
281
endfunction
262
282
263
- function ! s: GistGet (gistid, clipboard )
283
+ function ! s: GistGet (gistid, clipboard ) abort
264
284
redraw | echon ' Getting gist... '
265
285
let res = webapi#http#get (g: gist_api_url .' gists/' .a: gistid , ' ' , { " Authorization" : s: GistGetAuthHeader () })
266
286
if res .status = ~ ' ^2'
@@ -351,7 +371,7 @@ function! s:GistGet(gistid, clipboard)
351
371
endif
352
372
endfunction
353
373
354
- function ! s: GistListAction (shift)
374
+ function ! s: GistListAction (shift) abort
355
375
let line = getline (' .' )
356
376
let mx = ' ^gist:\s*\zs\(\w\+\)\ze.*'
357
377
if line = ~# mx
@@ -369,7 +389,7 @@ function! s:GistListAction(shift)
369
389
endif
370
390
endfunction
371
391
372
- function ! s: GistUpdate (content, gistid, gistnm, desc)
392
+ function ! s: GistUpdate (content, gistid, gistnm, desc) abort
373
393
let gist = { " id" : a: gistid , " files" : {}, " description" : " " ," public" : function (' webapi#json#true' ) }
374
394
if exists (' b:gist' )
375
395
if has_key (b: gist , ' private' ) && b: gist .private | let gist[" public" ] = function (' webapi#json#false' ) | endif
@@ -421,7 +441,7 @@ function! s:GistUpdate(content, gistid, gistnm, desc)
421
441
return loc
422
442
endfunction
423
443
424
- function ! s: GistDelete (gistid)
444
+ function ! s: GistDelete (gistid) abort
425
445
let auth = s: GistGetAuthHeader ()
426
446
if len (auth) == 0
427
447
redraw
@@ -483,7 +503,7 @@ endfunction
483
503
"
484
504
" GistID: 123123
485
505
"
486
- function ! s: GistPost (content, private, desc, anonymous)
506
+ function ! s: GistPost (content, private, desc, anonymous) abort
487
507
let gist = { " files" : {}, " description" : " " ," public" : function (' webapi#json#true' ) }
488
508
if a: desc != ' ' | let gist[" description" ] = a: desc | endif
489
509
if a: private | let gist[" public" ] = function (' webapi#json#false' ) | endif
@@ -523,7 +543,7 @@ function! s:GistPost(content, private, desc, anonymous)
523
543
return loc
524
544
endfunction
525
545
526
- function ! s: GistPostBuffers (private, desc, anonymous)
546
+ function ! s: GistPostBuffers (private, desc, anonymous) abort
527
547
let bufnrs = range (1 , bufnr (" $" ))
528
548
let bn = bufnr (' %' )
529
549
let query = []
@@ -579,7 +599,7 @@ function! s:GistPostBuffers(private, desc, anonymous)
579
599
return loc
580
600
endfunction
581
601
582
- function ! gist#Gist (count , line1, line2, ... )
602
+ function ! gist#Gist (count , line1, line2, ... ) abort
583
603
redraw
584
604
if strlen (g: github_user ) == 0
585
605
echohl ErrorMsg | echomsg " You don't have github account. read ':help gist-vim-setup'." | echohl None
@@ -780,7 +800,7 @@ function! gist#Gist(count, line1, line2, ...)
780
800
return 1
781
801
endfunction
782
802
783
- function ! s: GistGetAuthHeader ()
803
+ function ! s: GistGetAuthHeader () abort
784
804
if get (g: , ' gist_use_password_in_gitconfig' , 0 ) != 0
785
805
let password = substitute (system (' git config --get github.password' ), " \n " , ' ' , ' ' )
786
806
if password = ~ ' ^!' | let password = system (password[1 :]) | endif
0 commit comments