vim-erlang / vim-erlang-tags

Generate Vim tags for Erlang files
https://vim-erlang.github.io
Other
61 stars 23 forks source link

Nitrogen Project #42

Closed mkohlhaas closed 3 years ago

mkohlhaas commented 3 years ago

For a Nitrogen project I can not find every record definition. E.g. C-] ing to #button, #grid_8 and #container_12 do not work. Actually, #grid_8 will point to #grid. The other two just fail.

Using :tf #anyrecord does not work either: E488: trailing characters: #container_12. But there are not trailing characters.

Some simple records work, like #p, #h1 work absolutely fine.

hcs42 commented 3 years ago

Have you executed the vim_erlang_tags.erl command in a way that it could find the file that contains the record definition?

If I clone the https://github.com/nitrogen/nitrogen repository, it does not contain a definition for the #button macro. The #button macro is only used in nitrogen/rel/overlay/common/site/src/index.erl, but it is actually defined in the nitrogen_core repository (see the -include_lib in the beginning of index.erl).

If I also clone https://github.com/nitrogen/nitrogen_core, run vim_erlang_tags.erl on it and specify the tag file in my vimrc, then tagjumps works for me as expected. Both C-] and :tj #button. But note that the command is :tj (short for "tagjump"), not :tf! The tf command doesn't expect any parameters, so it will always give E488 if you try to specify one.

mkohlhaas commented 3 years ago

Hi Csaba,

thanks for your support!

No idea why I used :tf instead of :tj. My bad. :tjump works absolutely fine!

Though the records with underscores in it cannot be <C-]>inged. Do you want to investigate it? So far I can live with :tjump just fine, I think.

In case you want to have a closer look into it I setup a Nitrogen project on https://github.com/mkohlhaas/nindex.git

You can see the tags file in there too. It looks fine. #container_12, #grid_8, etc are in there.

If you open file site/src/index.erl you can try to <C-]> to the different record types. Everything after the underscore will be ignored. So #container_12 cannot be found. In case of #grid_8 it jumps to #grid.

hcs42 commented 3 years ago

Thanks for the example, it makes the investigation easier. The tag file indeed looks good.

The problem might be your iskeyword setting.

I downloaded https://github.com/mkohlhaas/nindex.git and hit <C-]> on #container_12. I got E426: tag not found: #container_12, which is good since the project does not contain lib/nitrogen_core/include/wf.hrl.

When <C-]> reads the tag under the cursor, it uses the iskeyword (isk) setting to decide which characters can be part of a tag. My guess is that _ is not listed in your iskeyword setting. (The mechanism is actually bit more complicated, but that is not relevant for the _ character. See VimErlangTagsSelect for the exact implementation).

Could you check what is the value of the iskeyword setting? Open an Erlang file and type :set iskeyword?. The following is an example result:

iskeyword=@,48-57,_,192-255,$,@-@ 

If the _ character is missing from your output, then you must have some other plugin or customization that modifies the value of this setting.

mkohlhaas commented 3 years ago

Great advice!

  1. Starting Vim without any configuration: vim -u NONE -N site/src/index.erl and it works perfectly fine and the keyword setting is: iskeyword=@,48-57,_,192-255
  2. Starting Vim with my custom config: keyword setting: iskeyword=@,48-57,_,192-255,$,@-@.

Keyword settings seems to be ok. But it obviously has to do with my config file. I think we can close this ticket. Will try to find out what plug-in or setting this causes. I hope it's not the vim-erlang-tags plug-in ;-) In case I find out I will post it here.

Thanks for your help, Csaba!

hcs42 commented 3 years ago

You are welcome. My only other guess at this point is that just like vim-erlang-tags defines a custom mapping for <c-]>, another plugin might also do that. One more thing you could try is to put an echomsg &isk line into the VimErlangTagsSelect function I linked above, and check it with :messages afterwards. This would show whether this function is called at all – and if yes, then what is the value of iskeyword when it is actually used.

If you find out what caused the problem, please consider posting it into this ticket. I'm curious :) Also, other people might run into a similar issue.