Skip to content

Commit f5c3746

Browse files
committed
merge: add macrocode as special case
refer: #3243
2 parents c6e2162 + 2cf1d17 commit f5c3746

File tree

3 files changed

+94
-1
lines changed

3 files changed

+94
-1
lines changed

autoload/vimtex/syntax/core.vim

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,15 @@ function! vimtex#syntax#core#init_rules() abort " {{{1
740740
endif
741741
endif
742742

743+
" }}}2
744+
" {{{2 Commands: \begin{macrocode}
745+
746+
" * In documented TeX Format, the 'macrocode' environment separates
747+
" documentation from actual code, hence should get special highlighting.
748+
if expand('%:e') ==# 'dtx'
749+
syntax match texDtxMacrocode "\%#=2^% \{4}\\\(begin\|end\){macrocode}"
750+
endif
751+
743752
" }}}2
744753

745754
let b:current_syntax = 'tex'
@@ -770,7 +779,6 @@ function! vimtex#syntax#core#init_rules() abort " {{{1
770779
\texMathDelimMod,
771780
\texMathDelim,
772781
\@NoSpell
773-
774782
endfunction
775783

776784
" }}}1
@@ -830,6 +838,7 @@ function! vimtex#syntax#core#init_highlights() abort " {{{1
830838
" See :help group-name for list of conventional group names
831839

832840
" Primitive TeX highlighting groups
841+
highlight def link texDtxMacrocode Special
833842
highlight def link texArg Include
834843
highlight def link texCmd Statement
835844
highlight def link texCmdSpaceCodeChar Special
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
% \iffalse meta-comment
2+
%
3+
% Copyright (C) 1993-2025
4+
%
5+
% The LaTeX Project and any individual authors listed elsewhere
6+
% in this file.
7+
%
8+
% This file is part of the Standard LaTeX `Tools Bundle'.
9+
% -------------------------------------------------------
10+
%
11+
% It may be distributed and/or modified under the
12+
% conditions of the LaTeX Project Public License, either version 1.3c
13+
% of this license or (at your option) any later version.
14+
% The latest version of this license is in
15+
% https://www.latex-project.org/lppl.txt
16+
% and version 1.3c or later is part of all distributions of LaTeX
17+
% version 2005/12/01 or later.
18+
%
19+
% The list of all files belonging to the LaTeX `Tools Bundle' is
20+
% given in the file `manifest.txt'.
21+
%
22+
% \fi
23+
% \iffalse
24+
%% File: indent.dtx Copyright (C) 1991-1994 David Carlisle
25+
%
26+
%<package>\NeedsTeXFormat{LaTeX2e}
27+
%<package>\ProvidesPackage{indentfirst}
28+
%<package> [2023/07/02 v1.03 Indent first paragraph (DPC)]
29+
%
30+
%<*driver>
31+
\documentclass{ltxdoc}
32+
\usepackage{indentfirst}
33+
\GetFileInfo{indentfirst.sty}
34+
\begin{document}
35+
\title{The \textsf{indentfirst} package\thanks{This file
36+
has version number \fileversion, last
37+
revised \filedate.}}
38+
\author{David Carlisle}
39+
\date{\filedate}
40+
\MaintainedByLaTeXTeam{tools}
41+
\maketitle
42+
\DocInput{indentfirst.dtx}
43+
\end{document}
44+
%</driver>
45+
% \fi
46+
%
47+
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
48+
%
49+
% \changes{v1.00}{1991/01/02}{Initial version}
50+
% \changes{v1.01}{1992/06/26}{Re-issue for the new doc and docstrip}
51+
% \changes{v1.02}{1994/01/31}{Re-issue for LaTeX2e}
52+
% \changes{v1.03}{1995/11/23}{Typo fixes in documentation}
53+
%
54+
% \begin{abstract}
55+
% Make the first line of all sections etc. be indented by the usual
56+
% paragraph indentation. This should work with all the standard document
57+
% classes.
58+
% \end{abstract}
59+
%
60+
% \CheckSum{4}^^A Still I think a record:-)
61+
%
62+
% \MaybeStop{}
63+
%
64+
% \begin{macro}{\if@afterindent}
65+
% \LaTeX\ uses the switch |\if@afterindent| to decide whether to indent
66+
% after a section heading. We just need to make sure that this is always
67+
% true.
68+
% \begin{macrocode}
69+
%<*package>
70+
\let\@afterindentfalse\@afterindenttrue
71+
\@afterindenttrue
72+
%</package>
73+
% \end{macrocode}
74+
% \end{macro}
75+
%
76+
% \Finale
77+
%
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source common.vim
2+
3+
Edit test-macrocode.dtx
4+
5+
if empty($INMAKE) | finish | endif
6+
7+
call vimtex#test#finished()

0 commit comments

Comments
 (0)