astoff / digestif

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

Complete command with brackets #26

Closed flimofly closed 2 years ago

flimofly commented 4 years ago

Am I correct that with environments the cursor is placed inside the brackets after completion (then triggering a new completion popup where one can select the right environment), but that something similar does not happen with e.g. the \cite command, where it would put the cursor inside the {} and trigger completion based on the .bib file?

VS Code offers several versions of the \cite command in the popup, from \cite{} to \cites()()[][]{}{}. One can then tab between the different brackets.

astoff commented 4 years ago

Ok, let's discuss just the \cite command, which has the signature \cite[subcite]{keys}. Currently the snippet for this is cite${1:[${2:subcite}]}{${3:keys}}$0, which means:

  1. The first selected region is [subcite]. From here, you can 1a. Delete this optional argument and jump to 2, or 1b. Press tab again to select the inside of the brackets, i.e. subcite, and type the desired optional argument
  2. The next selected region is keys (only the inside, since it's mandatory and it doesn't make sense to delete the delimiters)
  3. Finally, the cursor jumps to after the closing brace

Now, I must say I'm not an inveterate user of snippets, but this is the best approach I could imagine. In Emacs, after the snippet is inserted, I can either type C-d somepaper TAB to get \cite{somepaper}, or TAB p. 20 TAB somepaper TAB to get \cite[p. 20]{somepaper}. My feeling is that multiplying each possible completion by the number of optional arguments is going to be less efficient/more confusing; what was your expectation?

(Note: \cites is a command from biblatex, which digestif doesn't support yet. But as soon as there is a tags file for it, the same mechanism would be used.)

astoff commented 2 years ago

Since there were no further comments, I'll close this.