# Using unicode “combining right arrow above” to generate vector command in Plain LuaTeX

As Marcel Krüger has shown in his answer

Using unicode "combining right arrow above" to generate vector command

it is possible to use the “combining right arrow above” as the \vec command. This improves the readability in the source extremly. I have some documents with so much vectors.

I copied the answer and tried it. No problem. But I would like to use this solution in Plain LuaTeX, but there the letters do not get accented at all allthough I have not modified the code. What is wrong here?

MWE:

% Plain LuaTeX

\font\fourteenmath="latinmodern-math.otf:mode=base;script=math" at 14.4 pt
\textfont1=\fourteenmath

\Umathcodex="7"1x
\Umathcodey="7"1y
\protected\def\vec{\Umathaccent fixed"0"1"20D7 }

$$\vec xy$$% Works.

\mathcode"20D7="8000
\def\aftervec{\directlua{
local nest = tex.nest[tex.nest.ptr]
local last = nest.tail
if not last or not last.id == 18 then
error'I can only put accents on simple noads.'
end
if last.sub or last.sup then
error'If you want accents on a superscript or subscript, please use braces.'
end
local acc = node.new(21, 1)
acc.nucleus = last.nucleus
last.nucleus = nil
acc.accent = node.new(23)
acc.accent.fam, acc.accent.char = 0, 0x20D7
nest.tail = acc
node.flush_node(last)
}}
\letcharcode"20D7=\aftervec

$$x⃗y$$ % x does not get accented.

\bye