astoff / digestif

A language server for TeX and friends
Other
264 stars 6 forks source link

No completion in \citet{} and \citep{} #46

Closed zhenhua-wang closed 2 years ago

zhenhua-wang commented 2 years ago

Citation completion works great in \cite{}, but it does not work in \citet{} and \citep{}.

I also tried generating tag file for natbib.sty and put it into the data folder. Unfortunately, completion still does not work.

astoff commented 2 years ago

You'd have to edit the output of digestif -g natbib.sty so it describes the purpose of those new citation commands. Unfortunately the tags file format is not completely documented, but the entries should look similar to the original \cite in latex.tags:

  cite = {
    action = "cite",
    arguments = {
      {delimiters = {"[", "]"}, meta = "subcite", optional = true},
      {list = true, meta = "keys"}
    },
    documentation = "info:latex2e#\\cite",
    summary = "Refer to a bibliography item."
  },

If you would like to contribute a natbib.sty.tags file to the project, I'd be happy to assist you further. Just send me your current version of the file (via a draft pull request, pasting it here, or whatever).

zhenhua-wang commented 2 years ago

Hi, thanks your fast response! I am not an expert in language server, but adding these entries does the work for me.

  citep = {
    action = "cite",
    arguments = {
      {list = true, meta = "keys"}
    },
    summary = "Textual citation."
  },
  citepalias = {},
  citestarts = {},
  citestyle = {arguments = {{meta = "#1"}}},
  citet = {
    action = "cite",
    arguments = {
      {list = true, meta = "keys"}
    },
    summary = "Parenthetical citation."
  },

Below are the tag file for natbib. I did not change any besides from the two entries mentioned above. I am happy to help, let me know what can I do for this. Thank you!

generated = true
dependencies = {"citeref.sty", "natbib.sty"}
documentation = {}
commands = {
  ["@bib@Xauthor"] = {arguments = {{meta = "#1"}}},
  ["@bib@Xjournal"] = {arguments = {{meta = "#1"}}},
  ["@bibfield"] = {arguments = {{meta = "#1"}, {meta = "#2"}}},
  ["@bibibid@"] = {arguments = {{meta = "#1"}}},
  ["@bibitemShut"] = {arguments = {}},
  ["@biblabel"] = {arguments = {{meta = "#1"}}},
  ["@extra@b@citeb"] = {},
  ["@extra@binfo"] = {arguments = {}},
  ["@firstofone"] = {arguments = {{meta = "#1"}}},
  ["@ifnum"] = {arguments = {{meta = "#1"}}},
  ["@ifx"] = {arguments = {{meta = "#1"}}},
  ["@ifxundefined"] = {arguments = {{meta = "#1"}}},
  ["@lbibitem"] = {
    arguments = {
      {literal = "["},
      {delimiters = {"", "]"}, meta = "#1"},
      {meta = "#2"}
    }
  },
  ["@mkboth"] = {arguments = {{meta = "#1"}, {meta = "#2"}}},
  ["@safe@activesfalse"] = {},
  ["@safe@activestrue"] = {},
  BibitemOpen = {arguments = {}},
  BibitemShut = {arguments = {{meta = "#1"}}},
  Citealp = {},
  Citealt = {},
  Citeauthor = {},
  Citep = {},
  Citet = {},
  ["HAR@checkdef"] = {arguments = {}},
  MakeUppercase = {},
  ["NAT@@citetp"] = {arguments = {{literal = "["}, {delimiters = {"", "]"}, meta = "#1"}}},
  ["NAT@@close"] = {},
  ["NAT@@open"] = {},
  ["NAT@@setcites"] = {arguments = {}},
  ["NAT@UP"] = {arguments = {{meta = "#1"}}},
  ["NAT@Up"] = {arguments = {{meta = "#1"}}},
  ["NAT@alias"] = {},
  ["NAT@anchor"] = {arguments = {{meta = "#1"}, {meta = "#2"}}},
  ["NAT@apalk"] = {
    arguments = {
      {delimiters = {"", ", "}, meta = "#1"},
      {delimiters = {"", ", "}, meta = "#2"},
      {delimiters = {"", "\\@nil"}, meta = "#3"},
      {meta = "#4"}
    }
  },
  ["NAT@aysep"] = {},
  ["NAT@bare"] = {
    arguments = {
      {delimiters = {"", "("}, meta = "#1"},
      {delimiters = {"", ")"}, meta = "#2"},
      {delimiters = {"", "(@)"}, meta = "#3"},
      {delimiters = {"", "\\@nil"}, meta = "#4"},
      {meta = "#5"}
    }
  },
  ["NAT@bibitem@cont"] = {arguments = {}},
  ["NAT@bibitem@init"] = {arguments = {}},
  ["NAT@biblabel"] = {arguments = {{meta = "#1"}}},
  ["NAT@biblabelnum"] = {arguments = {{meta = "#1"}}},
  ["NAT@bibsetnum"] = {arguments = {{meta = "#1"}}},
  ["NAT@bibsetup"] = {arguments = {{meta = "#1"}}},
  ["NAT@celt"] = {arguments = {{meta = "#1"}}},
  ["NAT@cite"] = {arguments = {{meta = "#1"}, {meta = "#2"}, {meta = "#3"}}},
  ["NAT@cite@list@append"] = {arguments = {{meta = "#1"}}},
  ["NAT@citea@mbox"] = {arguments = {}},
  ["NAT@citemultiple"] = {},
  ["NAT@citenum"] = {arguments = {{meta = "#1"}, {meta = "#2"}, {meta = "#3"}}},
  ["NAT@cites"] = {},
  ["NAT@citesuper"] = {arguments = {{meta = "#1"}, {meta = "#2"}, {meta = "#3"}}},
  ["NAT@citetp"] = {},
  ["NAT@citeundefined"] = {},
  ["NAT@citex"] = {
    arguments = {
      {literal = "["},
      {delimiters = {"", "]["}, meta = "#1"},
      {delimiters = {"", "]"}, meta = "#2"},
      {meta = "#3"}
    }
  },
  ["NAT@citexnum"] = {
    arguments = {
      {literal = "["},
      {delimiters = {"", "]["}, meta = "#1"},
      {delimiters = {"", "]"}, meta = "#2"},
      {meta = "#3"}
    }
  },
  ["NAT@close"] = {},
  ["NAT@cmprs"] = {arguments = {}},
  ["NAT@cmt"] = {},
  ["NAT@def@citea"] = {arguments = {}},
  ["NAT@def@citea@box"] = {arguments = {}},
  ["NAT@def@citea@close"] = {arguments = {}},
  ["NAT@def@citea@space"] = {arguments = {}},
  ["NAT@deftemp"] = {arguments = {{meta = "#1"}}},
  ["NAT@exp"] = {arguments = {{delimiters = {"", "\\@nil"}, meta = "#1"}}},
  ["NAT@find@eq"] = {
    arguments = {
      {delimiters = {"", "="}, meta = "#1"},
      {delimiters = {"", "\\@nil"}, meta = "#2"}
    }
  },
  ["NAT@force@numbers"] = {},
  ["NAT@hyper@"] = {arguments = {{meta = "#1"}}},
  ["NAT@hyper@citea"] = {arguments = {{meta = "#1"}}},
  ["NAT@hyper@citea@space"] = {arguments = {{meta = "#1"}}},
  ["NAT@idxtxt"] = {},
  ["NAT@ifcat@num"] = {arguments = {{meta = "#1"}}},
  ["NAT@ifcmd"] = {},
  ["NAT@ifxcmd"] = {},
  ["NAT@index"] = {},
  ["NAT@index@alt"] = {},
  ["NAT@last@yr@mbox"] = {arguments = {}},
  ["NAT@make@cite@list"] = {arguments = {}},
  ["NAT@nextc"] = {
    arguments = {
      {delimiters = {"", ","}, meta = "#1"},
      {delimiters = {"", "@@"}, meta = "#2"}
    }
  },
  ["NAT@nmfmt"] = {arguments = {{meta = "#1"}}},
  ["NAT@noname"] = {arguments = {}},
  ["NAT@num@celt"] = {arguments = {{meta = "#1"}, {meta = "#2"}}},
  ["NAT@open"] = {},
  ["NAT@parse"] = {arguments = {{meta = "#1"}}},
  ["NAT@parse@date"] = {
    arguments = {
      {meta = "#1"},
      {meta = "#2"},
      {meta = "#3"},
      {meta = "#4"},
      {meta = "#5"},
      {delimiters = {"", "@@"}, meta = "#6"}
    }
  },
  ["NAT@rem@eq"] = {arguments = {{delimiters = {"", "="}, meta = "#1"}}},
  ["NAT@reset@citea"] = {arguments = {}},
  ["NAT@reset@parser"] = {arguments = {}},
  ["NAT@restc"] = {arguments = {{delimiters = {"", ","}, meta = "#1"}, {meta = "#2"}}},
  ["NAT@sectionbib"] = {arguments = {}},
  ["NAT@sep"] = {},
  ["NAT@separator"] = {arguments = {}},
  ["NAT@set@cites"] = {},
  ["NAT@sort"] = {arguments = {}},
  ["NAT@sort@cites"] = {arguments = {{meta = "#1"}}},
  ["NAT@sort@cites@"] = {arguments = {{meta = "#1"}}},
  ["NAT@spacechar"] = {arguments = {}},
  ["NAT@split"] = {
    arguments = {
      {meta = "#1"},
      {meta = "#2"},
      {meta = "#3"},
      {meta = "#4"},
      {delimiters = {"", "@@"}, meta = "#5"}
    }
  },
  ["NAT@star@cite"] = {arguments = {}},
  ["NAT@star@cite@noextension"] = {arguments = {{delimiters = {"", "\\@@"}, meta = "#1"}}},
  ["NAT@star@cite@nostar"] = {arguments = {}},
  ["NAT@star@cite@post"] = {
    arguments = {
      {literal = "["},
      {delimiters = {"", "]"}, meta = "#1"},
      {delimiters = {"", "\\@@"}, meta = "#2"}
    }
  },
  ["NAT@star@cite@pre"] = {arguments = {{literal = "["}, {delimiters = {"", "]"}, meta = "#1"}}},
  ["NAT@star@cite@star"] = {arguments = {{literal = "*"}}},
  ["NAT@test"] = {arguments = {{meta = "#1"}}},
  ["NAT@testdef"] = {arguments = {{meta = "#1"}, {meta = "#2"}}},
  ["NAT@wrout"] = {
    arguments = {
      {meta = "#1"},
      {meta = "#2"},
      {meta = "#3"},
      {meta = "#4"},
      {meta = "#5"}
    }
  },
  ["NAT@xcom"] = {arguments = {{delimiters = {"", ",@@"}, meta = "#1"}}},
  ["NAT@yrsep"] = {},
  appdef = {arguments = {{meta = "#1"}, {meta = "#2"}}},
  astroncite = {
    arguments = {
      {meta = "#1"},
      {delimiters = {"", "(@)(@)\\@nil"}, meta = "#2"},
      {meta = "#3"}
    }
  },
  betweenauthors = {},
  bibAnnote = {arguments = {{meta = "#1"}, {meta = "#2"}, {meta = "#3"}}},
  bibAnnoteFile = {arguments = {{meta = "#1"}, {meta = "#2"}}},
  bibcite = {arguments = {{meta = "#1"}, {meta = "#2"}}},
  bibcleanup = {arguments = {}},
  bibfield = {arguments = {}},
  bibinfo = {arguments = {{meta = "#1"}}},
  bibitem = {},
  ["bibitem@fin"] = {arguments = {}},
  bibitemContinue = {arguments = {}},
  bibitemNoStop = {arguments = {}},
  bibitemStop = {arguments = {}},
  bibname = {},
  bibpunct = {
    arguments = {
      {
        delimiters = {"[", "]"},
        details = "Default: “,”.",
        meta = "#1",
        optional = true
      },
      {meta = "#2"},
      {meta = "#3"},
      {meta = "#4"},
      {meta = "#5"},
      {meta = "#6"},
      {meta = "#7"}
    }
  },
  bibsection = {},
  bibstyle = {arguments = {{meta = "#1"}}},
  ["bibstyle@aa"] = {},
  ["bibstyle@agsm"] = {},
  ["bibstyle@agu"] = {},
  ["bibstyle@anngeo"] = {},
  ["bibstyle@chicago"] = {},
  ["bibstyle@copernicus"] = {},
  ["bibstyle@cospar"] = {},
  ["bibstyle@dcu"] = {},
  ["bibstyle@esa"] = {},
  ["bibstyle@kluwer"] = {},
  ["bibstyle@named"] = {},
  ["bibstyle@nature"] = {},
  ["bibstyle@nlinproc"] = {},
  ["bibstyle@pass"] = {},
  ["bibstyle@plain"] = {},
  ["bibstyle@plainnat"] = {},
  cite = {},
  citealp = {},
  citealt = {},
  citeauthor = {},
  citeauthoryear = {
    arguments = {
      {meta = "#1"},
      {meta = "#2"},
      {delimiters = {"", "(@)(@)\\@nil"}, meta = "#3"},
      {meta = "#4"}
    }
  },
  citeends = {},
  citefullauthor = {},
  citeindextype = {},
  citename = {
    arguments = {
      {meta = "#1"},
      {delimiters = {"", "(@)(@)\\@nil"}, meta = "#2"},
      {meta = "#3"}
    }
  },
  citenum = {},
  citep = {
    action = "cite",
    arguments = {
      {list = true, meta = "keys"}
    },
    summary = "Textual citation."
  },
  citepalias = {},
  citestarts = {},
  citestyle = {arguments = {{meta = "#1"}}},
  citet = {
    action = "cite",
    arguments = {
      {list = true, meta = "keys"}
    },
    summary = "Parenthetical citation ."
  },
  citetalias = {},
  citetext = {arguments = {{meta = "#1"}}},
  citeyear = {},
  citeyearpar = {},
  ["def@NAT@cite@lists"] = {
    arguments = {
      {delimiters = {"", ","}, meta = "#1"},
      {delimiters = {"", "\\@@"}, meta = "#2"}
    }
  },
  ["def@NAT@last@yr"] = {arguments = {{meta = "#1"}}},
  defcitealias = {arguments = {{meta = "#1"}, {meta = "#2"}}},
  harvardand = {},
  harvarditem = {
    arguments = {
      {
        delimiters = {"[", "]"},
        details = "Default: “”.",
        meta = "#1",
        optional = true
      },
      {meta = "#2"},
      {meta = "#3"},
      {meta = "#4"}
    }
  },
  harvardleft = {},
  harvardright = {},
  harvardurl = {arguments = {{meta = "#1"}}},
  harvardyearleft = {},
  harvardyearright = {},
  ["hyper@natanchorend"] = {},
  ["hyper@natanchorstart"] = {arguments = {{meta = "#1"}}},
  ["hyper@natlinkbreak"] = {arguments = {{meta = "#1"}, {meta = "#2"}}},
  ["hyper@natlinkend"] = {},
  ["hyper@natlinkstart"] = {arguments = {{meta = "#1"}}},
  makeindex = {},
  nocite = {arguments = {{meta = "#1"}}},
  refname = {},
  ["reset@font"] = {},
  setcitestyle = {arguments = {{meta = "#1"}}},
  shortcites = {arguments = {{meta = "#1"}}},
  string = {},
  textsuperscript = {arguments = {{meta = "#1"}}}
}
environments = {thebibliography = {arguments = {{meta = "#1"}}}}
astoff commented 2 years ago

To include the tags file for natbib, someone would have to clean up the above generated file quite extensively: delete the private commands with @, complete the information for all commands as you did for citet and citep, add some summary string, etc.

Admittedly, this is quite a bit of work. I'll close this ticket since your problem seems to be fixed now. However, if you feel like continuing working on this and open a pull request, it would be very welcome.