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

Crude syntax-based prettification of CtrlPTag #441

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Cimbali
Copy link

@Cimbali Cimbali commented May 31, 2018

Here's one attempt at making the CtrlPTag ouput palatable/readable. It's using simple syntax matching. See what it does in images:

Comparing current vs pretty CtrlPTag


Probably something much more powerful could be done with a proper formatting function. Just split on tab characters, then you can unobfuscate the kind of tag, properly shorten paths, reorder the code as last element of the line, etc.
See also http://ctags.sourceforge.net/FORMAT

There is one syntax group (CtrlPTagDir) that is not really used right now but could be used to show only the basename of files.

@Cimbali
Copy link
Author

Cimbali commented Jun 5, 2018

Alright so I did some more work to improve this, parsing the tags to fix some problems and improve appearance. The downside is some processing time in the #init() function. If you want to have a look, here it is:

  • without reordering: Gets the path to the source file which is relative to the tags file, and changes it to a path that is absolute, relative to home, or relative to cwd. This looks better & improves matching the selected tag in the taglist() output (about .5s for 10k C++ tags across 2 files)
  • with reordering: This has all of the above but improves the overall output by ordering the fields in a meaningful order: start with the tag kind (1 char) then the actual tag, then meta data (which class etc.), then only file and line or code (about .9s for 10k C++ tags across 2 files)

I tried parsing the line (tag<tab>file<tab>command(;"(<tab>field)+)?, tag and file may not contain tabs) with:

  • matchstr(),
  • 2x stridx(..., "\t") + match(..., ';"\t'),
  • split(..., "\t") + finding the fields with index(map(..., "v:val[-2:] == ';\"'"), 1),
  • split(... "\t") + finding the fields with a loop.
    This is the current code and works the fastest afaict.

CtrlPTagDir is not really used right now but could be concealed to show
only the basename of files.
See also http://ctags.sourceforge.net/FORMAT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant