There is a simple way, namely
\newcommand{\ket}[1]{\left \lvert#1 \right \rangle}
This code is completely equivalent to yours. On the other hand, you'll get the same warning if you have
\lvert x\rvert
in your document. Write the maintainers and ask them to add the commands.
In the meantime, you can create a chktexrc.local file that you can save somewhere containing
Silent
{
\rm \em \bf \it \sl \sf \sc \tt \selectfont
\rmfamily \sffamily \ttfamily \mdseries \bfseries
\slshape \scshape \relax
\vskip \pagebreak \nopagebreak
\textrm \textem \textbf \textit \textsl \textsf \textsc \texttt
\clearpage \ddots \dotfill \flushbottom \fussy \indent \linebreak
\onecolumn \pagebreak \pushtabs \poptabs \scriptsize \sloppy
\twocolumn \vdots
\today \kill \newline \thicklines \thinlines
\columnsep \space \item \tiny \footnotesize \small \normalsize
\normal \large \Large \LARGE \huge \Huge \printindex
\newpage \listoffigures \listoftables \tableofcontents
\maketitle \makeindex
\hline \hrule \vrule
\centering
\bigskip \medskip \smallskip
\noindent \expandafter
\noindent \expandafter
\makeatletter \makeatother
\columnseprule
\textwidth \textheight \hsize \vsize
\if \fi \else
\csname \endcsname
\z@ \p@ \@warning \typeout
\dots \ldots \input \endinput \nextline \leavevmode \cdots
\appendix \listfiles \and \quad
\hskip \vfill \vfil \hfill \hfil \topmargin \oddsidemargin
\frenchspacing \nonfrenchspacing
\begingroup \endgroup \par
\vrefwarning \upshape \headheight \headsep \hoffset \voffset
\cdot \qquad
\left \right
\qedhere
\xspace
\addlinespace \cr \fill \frontmatter
\toprule \midrule \bottomrule
\lvert \rvert
}[
Here you can put regular expressions to match Silent macros. It was
designed for the case where you have many custom macros sharing a
common prefix, but can of course be used for other things.
Support ConTeXt to at least some extent
\start.* \stop.*
]
and call chktexrc with
chktex -l path/to/chktexrc.local mydocument.tex
with the suitable replacement to path/to, of course.
Unfortunately there seems to be no way to add to the ignored keywords at runtime other than copying all of them and increment the list.
How did I find the original list? Find on your system the file chktexrc, open it and copy the relevant part.
Comment
It's a silly warning by chktex. It's silly because a space is the correct way to terminate a command. It should be the other way around: only some commands should not be terminated simply by a space, for instance \TeX or \LaTeX.
So there should be a NoSilent list, rather than a long list for which termination with a space is usually the best choice.
\lvert, thenamsmathhas surely been loaded. Why should one want to use\ensuremathfor that? – egreg Jul 03 '20 at 19:51chktex. Ignore it. – egreg Jul 03 '20 at 19:51#1is the one that could be a mistake (probably safe in math mode though). Are you sure chktex isn't complaining about that one? – Donald Arseneau Jul 03 '20 at 21:59