There isn't really a 'correct' answer, as you have to define this yourself. LyX uses the refstyle
packages for such formatted references, and this does not, as far as I can tell, have definitions for program listings.
So what you would do is I think to add such a definition to your preamble, in Document --> Settings --> LaTeX preamble. A simple example is
\newref{lst}{
name = listing~,
names = listing~,
Name = Listing~,
Names = Listings~,
rngtxt = {~to~},
lsttxt = { and }}
With this definition you should use lst:
as a the prefix in the labels. If you want some other prefix, change the lst
in \newref{lst}
to the prefix of your choice.
Note however, that as long as you don't use ERTs, I think you just need \newref{lst}{name = listing~}
, as LyX simply doesn't have support for the other reference formats, unless I'm mistaken.
A final note: generally there is no correct way of writing labels for chapters, sections etc. either. The use of chap
, sec
, eq
and so on is just a convention, it not something you need to do. Unless you use the refstyle
package. This does actually need to have the right string as prefixes to figure out what type of object is referred to. The cleveref
package is cleverer in this sense, as it figures stuff out on its own.