@@ -216,11 +216,17 @@ let s:filetype_defaults = {
216216 \ ' cvs' : 0 ,
217217 \ ' .' : 0 }
218218
219- function ! s: FileTypeDisabled (filetype ) abort
220- let short = empty (a: filetype ) ? ' .' : split (a: filetype , ' \.' , 1 )[0 ]
219+ function ! s: BufferDisabled () abort
220+ if exists (' b:copilot_disabled' )
221+ return b: copilot_disabled ? 3 : 0
222+ endif
223+ if exists (' b:copilot_enabled' )
224+ return b: copilot_enabled ? 4 : 0
225+ endif
226+ let short = empty (&l: filetype ) ? ' .' : split (&l: filetype , ' \.' , 1 )[0 ]
221227 let config = get (g: , ' copilot_filetypes' , {})
222- if has_key (config, a : filetype )
223- return empty (config[a : filetype ])
228+ if has_key (config, & l : filetype )
229+ return empty (config[& l : filetype ])
224230 elseif has_key (config, short)
225231 return empty (config[short])
226232 elseif has_key (config, ' *' )
@@ -233,8 +239,7 @@ endfunction
233239function ! copilot#Enabled () abort
234240 return ! get (g: , ' copilot_disabled' , 0 )
235241 \ && s: TermsAccepted (0 )
236- \ && ! get (b: , ' copilot_disabled' , 0 )
237- \ && empty (s: FileTypeDisabled (&filetype ))
242+ \ && empty (s: BufferDisabled ())
238243 \ && empty (copilot#agent#StartupError ())
239244endfunction
240245
@@ -565,18 +570,20 @@ function s:NetworkStatusMessage() abort
565570endfunction
566571
567572function ! s: EnabledStatusMessage () abort
568- let ft_disabled = s: FileTypeDisabled (& filetype )
573+ let buf_disabled = s: BufferDisabled ( )
569574 if ! s: has_ghost_text && bufwinid (' copilot://' ) == -1
570575 return " Neovim 0.6 prerelease required to support ghost text"
571576 elseif ! copilot#IsMapped ()
572577 return ' <Tab> map has been disabled or is claimed by another plugin'
573578 elseif get (g: , ' copilot_disabled' , 0 )
574579 return ' Disabled globally by :Copilot disable'
575- elseif get (b: , ' copilot_disabled' , 0 )
580+ elseif buf_disabled is # 4
581+ return ' Disabled for current buffer by b:copilot_enabled'
582+ elseif buf_disabled is # 3
576583 return ' Disabled for current buffer by b:copilot_disabled'
577- elseif ft_disabled is # 2
584+ elseif buf_disabled is # 2
578585 return ' Disabled for filetype=' . &filetype . ' by internal default'
579- elseif ft_disabled
586+ elseif buf_disabled
580587 return ' Disabled for filetype=' . &filetype . ' by g:copilot_filetypes'
581588 elseif ! copilot#Enabled ()
582589 return ' BUG: Something is wrong with enabling/disabling'
@@ -633,7 +640,7 @@ function! s:commands.setup(opts) abort
633640 let @* = data.user_code
634641 echo " First copy your one-time code: " . data.user_code
635642 if len (browser)
636- echo " Press ENTER to open github.com in your browser"
643+ echo " Press ENTER to open " . data.verification_uri . " in your browser"
637644 try
638645 if len (&mouse )
639646 let mouse = &mouse
@@ -651,8 +658,6 @@ function! s:commands.setup(opts) abort
651658 let exit_status = copilot#job#Stream (browser + [data.verification_uri], v: null , v: null )
652659 if exit_status
653660 echo " Failed to open browser. Visit " . data.verification_uri
654- else
655- redraw
656661 endif
657662 else
658663 echo " Could not find browser. Visit " . data.verification_uri
0 commit comments