Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

31 Commits

Repository files navigation

:Vfix

:Vfix in action preview

A crude and simple script for Vim to resolve some of the error :messages yielded when vim-scrips fail.

Can be a help to find where errors originate etc.

  • For Vim >= 8.1.0362
  • For Nvim >= 0.4.0 (#a2e48b556b7537acd26353b6cc201410be7cf3dc)

Latest


ℹ️ About

Parses :messages and resolves numeric and other references to errors before adding them to QuickFix list.

💲 Example

As in gif above.

Error detected while processing function 346[5]..345[31]..340:
line 3:
E492: Not and editor command: ^I^I^Iautocmdx

Pushed by Vfix to QuickFix as:

1 .vim/some/dir/script.vim|460 error 492| fun! s:MyScript.set_au(): Not an editor command: autocmdx
2 .vim/some/dir/script.vim|564 info| Called by: fun! s:MyScript.go_active(a, b)
3 .vim/some/dir/script.vim|594 info| Called by: fun! s:MyScript.interpret_cmd(...)

Here we have on line 1. in QuickFix the offending line 460 by function 340 resolved to s:MyScript.set_au().

Line 2. and 3. are the trace from 345 to 346. The entries in the QuickFix list are direct links to the scripts and their error lines - as long as they can be found.

💾 Install

Put script in a autoload folder or source it manually.

📟: Commands

Adds one command: :Vfix

📚 Usage

The script comes with a few options. When Vfix has been sourced you can run:

:Vfix help

to get a list:

Options:
a : append - Append to QuickFix List. Default OFF:replace
r : reverse - Reverse messages. Default OFF:FIFO
o : copen - Open using copen. Default OFF:cw
s : silent - Do not open window. Default OFF
ig : nolost - Ignore lost functions. Default OFF
au : autorun - Vfix on sourcing a file. Default OFF
ac : clear - Alway clear ":messages". Default OFF
fm : use-mark - Only from last mark. Default ON
m : use-mark - Search mark.
am : auto-mark - Add marks in :messages. Default ON
M : mark-now - Add a mark in :messages.
lm : list-m - List marks
cc : clear - Clear messages once.
sf : Print Status for flags.
h : This help

Beware that cc and ac erase :messages. To view status of flags use :Vfix sf

:Vfix alone runs the script and open QuickFix if it managed to dechipher any errors - optionally with cc, a, s, o or r option(s).

🔍 Lost functions

Note that every time a script get sourced it get a new reference. If this is a numeric ref. it can not be resolved later and one will get N/A + a noop address in the errors list. Activate ig to silence these.

Update: With marks this is now better handled. Use marks and all old messages are ignored.

🌎 Global options

Override on options can be set in .vimrc (or elsewhere). All takes 1 for on and 0 for off.

" Option Defaultg:Vfix_append0" Append to QuickFix error list. Else replace.g:Vfix_copen0" Use copen. Else cwindow.g:Vfix_silent0" Never open window.g:Vfix_reverse0" Reverse messages / errors LIFO. Main reson for this is" when one have a lot of `:messages`. Would perhaps be" better to jump to end of error list.g:Vfix_ignore_lost0" Ignore errors where functions can not be resolved. See" note below.g:Vfix_clr_always0" Clear :messages each time Vfix is executedg:Vfix_auto_run0" Auto run on sourcing. Can be buggy.g:Vfix_filter_mark1" Only parse messages from last markg:Vfix_auto_mark1" Add mark in :messages each time a script is sourcedg:Vfix_hi_markComment" Highlighting group to use for marks in messagesg:Vfix_load_on_startup0" The boot() section of the code will be run first" time :Vfix is called. Set this to 1 to boot()" when vim source the script. Mainly for hacking.g:Vfix_re_source_globals0" Mainly for hacking ***this*** script." If set and true global options will be reset when" re-sourcing script.

📰 News

Marks in :messages and new default values.

Added support for marks in messages. It makes, I hope, for a cleaner experience.

By this the default reversing of messages is also turned off.

Works in short like this:

  1. Pre Sourcing: echo a persistent message (mark) to :messages
  2. On run: Search for last mark and ignore all messages before it

Note! Marks are not auto added if path is */autoload/*. Yes, this can be somewhat inconvenient - but as we hook to SourcePre we risk adding marks on places where we do not want them ... Could try to find a better solution for this.

  • Auto marking + filtering from last mark is on by default.
  • All marks has a prefix of ;; VfixM NN HH:MM:SS <file|text> where NN is an internal counter.
  • Add marks manually by :Vfix M <optional text>
  • Filter using earlier marks by :Vfix m NR..
  • Show all by uing :Vfix m 0 , or turn mark filtering off :Vfix fm=0
  • List marks by: :Vfix lm
  • Set marks highlighting by g:Vfix_hi_mark, default "Comment"

📣 Notes

  • Support for Neovim (and older versions then 8.2)
  • Add option to use shell command to read script files. Each time we read a file, even though it is with readfile(), the file is pushed to the hidden buflist. This can be a bit noisy. Files are added when updating Quickfix so this is not an option.
  • Consider jumping to end of error list instead of reversing.
  • Sorting is a mess when one have mixed messages: One can typically have an error reference in :messages followed by one or more error messages. This script is greedy when reading errors after an error with reported location - resulting in a skewed reporting when it comes to called by references. So - w ork on this.
  • Better autocommand handling.
  • More specific about that -^ point so it is actually possible to check off. :sweat_smile:
  • It is possible to cache references to all objects and functions each time a script is sourced by looping s:, g: etc. Could have it as an option, but likely best suited as an addon. Is a bit complex and usually not worth it.
  • Find a way to set a a mark in :messages if user reloads a script they are working on. Could likely use autocommand in combination with :silent echom This way one could ignore lost messages better.
  • As we read the files where errors originated and also get context - a few lines before / after - one could try to implement a way to show this. Popup? For example a popup while navigating QuickFix list. Could be useful for when one do not want to open the file - or the file is open in another vim session.
  • Look up error number in :help? Each :message is prepended with an error in the form of ENNN. Could add a link to this, - but have not found it useful.
  • Add a plain-text README?
  • This README started partially as a joke. Clean it up.

➰ History

Is a snip that has been in my .vim directory for years, adding a little now and then. Likely a lot of bugs, ironically enough. Did some cleanup on the code and have likely introduced a few more. But put it out there in case anyone find it helpful.

About

Vfix : Vim, Debugging, Vim-scripts

Topics

Resources

Stars

17 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages