Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VimtexEventCompileRunning event for continuous compilation #2290

Closed
Neelfrost opened this issue Dec 30, 2021 · 4 comments
Closed

VimtexEventCompileRunning event for continuous compilation #2290

Neelfrost opened this issue Dec 30, 2021 · 4 comments

Comments

@Neelfrost
Copy link

Neelfrost commented Dec 30, 2021

Is your feature request related to a problem? Please describe it.
I would like to display the compile status on my statusline. Currently, vimtex provides 3 events that trigger when:

  1. Compile is first started,
  2. Compile is successful,
  3. Compile has failed.

The above works great for single-shot compilation, but not when using continuous compilation, since compile runs every time the document is saved.

Describe the solution you'd like
I would like another event that is triggered when a cycle of continuous compilation runs.
image

@lervag
Copy link
Owner

lervag commented Dec 31, 2021

This already exists, but I forgot to document it. You want the VimtexEventCompiling event. I've updated the docs now.

@lervag lervag closed this as completed Dec 31, 2021
lervag added a commit that referenced this issue Dec 31, 2021
@lervag
Copy link
Owner

lervag commented Dec 31, 2021

Note, if you want this for a statusline feature, then you don't need to rely on the events. I use a custom statusline, but I believe my code should be not so hard to read, see here:

https://github.com/lervag/dotnvim/blob/c07302353b0544c4c6923b06ef0281ebb5077c18/autoload/personal/statusline.vim#L148-L157

  let l:status = getbufvar(a:bufnr, 'vimtex').compiler.status + 1

  let [l:symbol, l:color] = get([
        \ ['[⏻] ', ''],
        \ ['[⏻] ', ''],
        \ ['[⟳] ', ''],
        \ ['[✔︎] ', 'SLInfo'],
        \ ['[✖] ', 'SLAlert']
        \], l:status)

The idea here is that the statusline can check the b:vimtex.compiler.status attribute, which is the current compiler status. The status values are the same as those documented at :help vimtex#compiler#callback, although the values -1 and 0 may appear. -1 indicates that the compiler was never started, and value 0 means it is not running.

@Neelfrost
Copy link
Author

This is even better! Thank you! :)

@lervag
Copy link
Owner

lervag commented Dec 31, 2021

No problem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants