diff options
| author | zeertzjq <zeertzjq@outlook.com> | 2025-03-11 06:13:31 +0800 |
|---|---|---|
| committer | zeertzjq <zeertzjq@outlook.com> | 2025-03-11 06:24:57 +0800 |
| commit | 638b3c0717219ce152cbd255cbc878aa1b34ab95 (patch) | |
| tree | 242432e2e753a4018339b481c0fc020208bb7324 /test | |
| parent | f2c0755828d529af101b5d0e4a1fd204fd0a7039 (diff) | |
| download | rneovim-638b3c0717219ce152cbd255cbc878aa1b34ab95.tar.gz rneovim-638b3c0717219ce152cbd255cbc878aa1b34ab95.tar.bz2 rneovim-638b3c0717219ce152cbd255cbc878aa1b34ab95.zip | |
vim-patch:9.1.1186: filetype: help files in git repos are not detected
Problem: filetype: help files in git repos are not detected
Solution: detect */doc/*.txt files as help if they end with a help
modeline, even if 'modeline' is off
Here's how I checked that this would still detect vim's own help files
correctly:
$ find . -type f -path '*/doc/*.txt' \
> -exec awk '{ } ENDFILE { print FILENAME ":" $0; }' '{}' + |
> grep -v 'vim:.*\<\(ft\|filetype\)=help\>'
./src/libvterm/doc/seqs.txt: 23 DECSM 42 = DECNRCM, national/multinational character
closes: vim/vim#16817
https://github.com/vim/vim/commit/16d6fff98ed3a9dfd34a41696b005b0c4c7800f8
Split the pattern into a Lua pattern for the first part and a Vim regex
pattern for the second part, so that if the first part doesn't match
there is no need to use the Vim regex.
Co-authored-by: David Mandelberg <david@mandelberg.org>
Diffstat (limited to 'test')
| -rw-r--r-- | test/old/testdir/test_filetype.vim | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/test/old/testdir/test_filetype.vim b/test/old/testdir/test_filetype.vim index 296062f92c..0355956447 100644 --- a/test/old/testdir/test_filetype.vim +++ b/test/old/testdir/test_filetype.vim @@ -916,8 +916,6 @@ func s:GetFilenameChecks() abort \ '.zcompdump', '.zlogin', '.zlogout', '.zshenv', '.zshrc', '.zsh_history', \ '.zcompdump-file', '.zlog', '.zlog-file', '.zsh', '.zsh-file', \ 'any/etc/zprofile', 'zlog', 'zlog-file', 'zsh', 'zsh-file'], - \ - \ 'help': [$VIMRUNTIME .. '/doc/help.txt'], \ } endfunc @@ -1620,6 +1618,23 @@ func Test_haredoc_file() filetype off endfunc +func Test_help_file() + filetype on + call assert_true(mkdir('doc', 'pR')) + + call writefile(['some text', 'vim:ft=help:'], 'doc/help.txt', 'D') + split doc/help.txt + call assert_equal('help', &filetype) + bwipe! + + call writefile(['some text'], 'doc/nothelp.txt', 'D') + split doc/nothelp.txt + call assert_notequal('help', &filetype) + bwipe! + + filetype off +endfunc + func Test_hook_file() filetype on |