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

Add preview window support #21

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

Conversation

ches
Copy link

@ches ches commented Feb 3, 2015

This covers CTRL-W_} and CTRL-W_g}, which I believe takes care of all standard tag window mappings now (minus some details like handling counts the way some originals do).

Generalizes the approach so that the wrapper function doesn't need logic to handle split, preview, etc. Also no longer results in the cursor being moved to beginning of the function call (or record/macro after #15) in the original buffer.

I'm not certain that the change to adding # and ? to iskeyword doesn't have any repercussions that I haven't foreseen, but I've tested the mappings with records and macros and everything looks solid to me.

@ches
Copy link
Author

ches commented Feb 4, 2015

Just realized the problem fixed in the second commit here. I can squash that following review.

@hcs42
Copy link
Member

hcs42 commented Feb 7, 2015

This covers CTRL-W_} and CTRL-W_g}, which I believe takes care of all standard tag window mappings now (minus some details like handling counts the way some originals do).

Generalizes the approach so that the wrapper function doesn't need logic to handle split, preview, etc. Also no longer results in the cursor being moved to beginning of the function call (or record/macro after #15) in the original buffer.

Thanks!

I'm not certain that the change to adding # and ? to iskeyword doesn't have any repercussions that I haven't foreseen, but I've tested the mappings with records and macros and everything looks solid to me.

I can think of only one example: when hitting Ctrl-] on ??MY_MAC, the current code tries to jump to the ?MY_MAC (which is present in the tags file), while the new code tries to jump to ??MY_MAC (which is not present). See http://erlang.org/doc/reference_manual/macros.html → "Stringifying Macro Arguments".

Otherwise the commits look good, so I have started to use the head of #22 in my daily work – we will see if any other edge case comes up.

@ches
Copy link
Author

ches commented Feb 7, 2015

Awesome, thanks for the feedback! Sounds perfectly reasonable to me to give it a trial run for awhile and see if any gotchas surface, and from there determine if working around them isn't a nasty kludge. Good point on the macro argument edge case.

Let me know here how it goes and I can try to address issues. Thanks for giving it a try 😄

@hcs42
Copy link
Member

hcs42 commented Feb 16, 2015

I have been using the head of #22, it have been working well, except for the issue that I mentioned:

I can think of only one example: when hitting Ctrl-] on ??MY_MAC, the current code tries to jump to the ?MY_MAC (which is present in the tags file), while the new code tries to jump to ??MY_MAC (which is not present). See http://erlang.org/doc/reference_manual/macros.html → "Stringifying Macro Arguments".

Also, the outstanding part of issue #19 (see this comment) is very much related to this problem. The solution I described there have been made obsolete by this PR modifying the code to use expand("<cword>") instead of normal mode movements to select the tag.

My proposal to solve both problems is to write our own function instead of expand("<cword>"), which will find the tag under the cursor in the following way:

  • It checks if the cursor is inside a quoted atom using synIDattr(synID(line('.'), col('.'), 1), 'name') ==# 'erlangQuotedAtom'.
  • If it is inside a quoted atom, it expands to the text between the last ' before the cursor and the next ' after the cursor.
  • If it is not inside a quoted atom, it will expand from the cursor to both directions while it finds [a-zA-Z0-9:@_].
  • It both cases, it checks if the expanded text is preceded by ? or #, that is added to the expanded text.

This solution would have the following benefits:

  • We can drop hacking iskeyword.
  • It would work for ??MACROS_LIKE_THIS.
  • It would work for #'Records-like-this'.

Note: We would still need to modify vim-erlang-tags.erl to generate #'Bla-bla' instead of #Bla-bla.

@ches @civing Thoughts?

@ches If you agree with this, do you feel like implementing it, or shall I?

Generalizes the approach so that the function doesn't need logic to
handle split, preview, etc. Also no longer results in the cursor being
moved to beginning of the function call (or record/macro after vim-erlang#15) in
the original buffer.
@ches
Copy link
Author

ches commented Feb 16, 2015

This sounds reasonable to me, I'll try giving it a shot when I have a few spare minutes.

@civing
Copy link

civing commented Feb 18, 2015

Really good solution.

@civing
Copy link

civing commented Feb 18, 2015

This might even work in quoted atoms with spaces inside them. CTAGS seems to use a TAB as a seperator.
tag_name< TAB >file_name< TAB >ex_cmd;"< TAB >extension_fields

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.

3 participants