commit cc6ee59f5ac36d5b0598c8db837a9c50a3fad615
parent 2f24ae8de471570e3188c91128229b6e98e1710f
Author: zeertzjq <zeertzjq@outlook.com>
Date: Tue, 13 May 2025 10:07:51 +0800
Merge pull request #33994 from brianhuster/vim-3704b5b
vim-patch:37045b5,9.1.1384 && fix(tutor): `l:lang` is undefined
Diffstat:
5 files changed, 61 insertions(+), 25 deletions(-)
diff --git a/runtime/autoload/tutor.vim b/runtime/autoload/tutor.vim
@@ -120,6 +120,8 @@ endfunction
" Tutor Cmd: {{{1
function! s:Locale()
+ " Make sure l:lang exists before returning.
+ let l:lang = 'en_US'
if exists('v:lang') && v:lang =~ '\a\a'
let l:lang = v:lang
elseif $LC_ALL =~ '\a\a'
@@ -132,8 +134,6 @@ function! s:Locale()
endif
elseif $LANG =~ '\a\a'
let l:lang = $LANG
- else
- let l:lang = 'en_US'
endif
return split(l:lang, '_')
endfunction
@@ -220,6 +220,7 @@ function! tutor#TutorCmd(tutor_name)
call tutor#SetupVim()
exe "edit ".l:to_open
+ call tutor#EnableInteractive(v:true)
call tutor#ApplyTransform()
endfunction
@@ -229,6 +230,27 @@ function! tutor#TutorCmdComplete(lead,line,pos)
return join(l:names, "\n")
endfunction
+" Enables/disables interactive mode.
+function! tutor#EnableInteractive(enable)
+ let enable = a:enable
+ if enable
+ setlocal buftype=nofile
+ setlocal concealcursor+=inv
+ setlocal conceallevel=2
+ call tutor#ApplyMarks()
+ augroup tutor_interactive
+ autocmd! TextChanged,TextChangedI <buffer> call tutor#ApplyMarksOnChanged()
+ augroup END
+ else
+ setlocal buftype<
+ setlocal concealcursor<
+ setlocal conceallevel<
+ if exists('#tutor_interactive')
+ autocmd! tutor_interactive * <buffer>
+ endif
+ endif
+endfunction
+
function! tutor#ApplyTransform()
if has('win32')
sil! %s/{unix:(\(.\{-}\)),win:(\(.\{-}\))}/\2/g
diff --git a/runtime/ftplugin/tutor.vim b/runtime/ftplugin/tutor.vim
@@ -1,19 +1,18 @@
-" vim: fdm=marker
+" Tutor filetype plugin
+" Language: Tutor (the new tutor plugin)
+" Maintainer: This runtime file is looking for a new maintainer.
+" Last Change: 2025 May 10
+" Contributors: Phạm Bình An <phambinhanctb2004@gmail.com>
+" Original Author: Felipe Morales <hel.sheep@gmail.com>
+" Last Change:
+" 2025 May 10 set b:undo_ftplugin
+" 2025 May 12 update b:undo_ftplugin
" Base: {{{1
call tutor#SetupVim()
" Buffer Settings: {{{1
setlocal noreadonly
-if !exists('g:tutor_debug') || g:tutor_debug == 0
- setlocal buftype=nofile
- setlocal concealcursor+=inv
- setlocal conceallevel=2
-else
- setlocal buftype=
- setlocal concealcursor&
- setlocal conceallevel=0
-endif
setlocal noundofile
setlocal keywordprg=:help
@@ -39,7 +38,7 @@ call tutor#SetNormalMappings()
sign define tutorok text=✓ texthl=tutorOK
sign define tutorbad text=✗ texthl=tutorX
-if !exists('g:tutor_debug') || g:tutor_debug == 0
- call tutor#ApplyMarks()
- autocmd! TextChanged,TextChangedI <buffer> call tutor#ApplyMarksOnChanged()
-endif
+let b:undo_ftplugin = "setl foldmethod< foldexpr< foldlevel< undofile< keywordprg< iskeyword< |"
+ \ . "call tutor#EnableInteractive(v:false) |"
+
+" vim: fdm=marker
diff --git a/runtime/plugin/tutor.vim b/runtime/plugin/tutor.vim
@@ -1,3 +1,9 @@
+" Tutor: New Style Tutor Plugin :h vim-tutor-mode
+" Maintainer: This runtime file is looking for a new maintainer.
+" Contributors: Phạm Bình An <phambinhanctb2004@gmail.com>
+" Original Author: Felipe Morales <hel.sheep@gmail.com>
+" Date: 2025 May 12
+
if exists('g:loaded_tutor_mode_plugin') || &compatible
finish
endif
diff --git a/runtime/tutor/tutor.tutor b/runtime/tutor/tutor.tutor
@@ -17,15 +17,8 @@ Table of contents:
## SETTING UP *setting-up*
-First, you'll need to enable "debug" mode
-~~~ cmd
- :let g:tutor_debug = 1
-~~~
-This will allow saving changes to the tutor files and will disable conceals, so
-you can more easily check your changes.
-
-After this, create a new .tutor file (we will be practicing on this very file, so you
-don't need to do this now):
+Create a new .tutor file (we will be practicing on this very file, so you don't
+need to do this now):
~~~ cmd
:e new-tutorial.tutor
~~~
diff --git a/test/old/testdir/test_plugin_tutor.vim b/test/old/testdir/test_plugin_tutor.vim
@@ -0,0 +1,16 @@
+" Test for the new-tutor plugin
+
+func SetUp()
+ set nocompatible
+ runtime plugin/tutor.vim
+endfunc
+
+func Test_auto_enable_interactive()
+ Tutor
+ call assert_equal('nofile', &buftype)
+ call assert_match('tutor#EnableInteractive', b:undo_ftplugin)
+
+ edit Xtutor/Xtest.tutor
+ call assert_true(empty(&buftype))
+ call assert_match('tutor#EnableInteractive', b:undo_ftplugin)
+endfunc