Struggling with ctags


#1

Hi

I am trying to use Atom and ctags to navigate a very large C project. I am running on Windows.

The project is hosted in svn so I have simply opened the root folder of the project in Atom.

I read the advice for using ctags in the Getting Started section of the documentation:

To jump to a symbol such as a method definition, press cmd-r . This opens a list of all symbols in the current file, which you can fuzzy filter similarly to cmd-t .

To search for symbols across your project, use cmd-shift-r . First you’ll need to make sure you have tags (or TAGS ) file generated for your project. This can be done by installing ctags and running a command such as ctags -R src/ from the command line in your project’s root directory. Using Homebrew? Just run brew install ctags .

I also generated a tags file in the root of the project as follows:

“\Program Files (x86)\ctags58\ctags” -R

This created a tags file of around 58MB.

Now in Atom, if I open a C file, put the cursor on a locally defined symbol and press CTRL-r I see:

No symbols found

Any idea why that is not working please?

I assume that that local search would not use ctags.

Now, considering ctags, I assume that to jump to a declaration in another file I use CTRL-SHIFT-r. But, for my understanding, will Atom automatically look for a tags file in the project root or must I tell it to do so?

(I have installed atom-ctags but I’m not sure exactly what that does).


Atom Ctags 2.1.0 released
#2

I haven’t used atom-ctags, so I’m not sure how that works or if there are any differences. If you properly generated a tags file, it should be in the root of the repository and named tags. Have you opened the tags file to see if there are any symbols for the C file you’re looking at? Is there a spinner indicating that Atom is still crunching through the tags file? (58MB is pretty big for a tags file and would take some noticeable amount of time …)


#3

There is no spinner. There is nothing to indicate that Atom has found the tags file. Would Atom just reject the file as it is so large?

Also, I don’t understand why the local searches aren’t working.


#4

I moved a post to a new topic: Email notifications


#5

No.

Please define exactly what you mean by “local searches”. Preferably in “Steps to Reproduce” format:


Atom-Ctags (autocomplete+ with ctags)
#6

Hi, I’ve created a simple test case as requested.

I am running Atom 0.135 on Windows 8.1. I have installed atom-ctags 2.2.0 and autocomplete-plus 0.21.0 and they are both enabled.

I have a very simple project of two C files:

main.c:

extern void myFunc(int& x);

int main()
{
    int x;

    myFunc(x);
}

myFunc.c:

void myFunc(int& x)
{
    x=x*2;
}

I created a tags file using:

"\Program Files (x86)\ctags58\ctags" -R

Here’s the tags file:

!_TAG_FILE_FORMAT	2	/extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED	1	/0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR	Darren Hiebert	/dhiebert@users.sourceforge.net/
!_TAG_PROGRAM_NAME	Exuberant Ctags	//
!_TAG_PROGRAM_URL	http://ctags.sourceforge.net	/official site/
!_TAG_PROGRAM_VERSION	5.8	//
main	.\main.c	/^int main()$/;"	f
myFunc	.\myFunc.c	/^void myFunc(int& x)$/;"	f

Then re-open the folder in Atom.

Now, the problems are:

1) Can’t jump to local symbol

In main.c, place cursor before ‘x’ in ‘myFunc(x);’ and press Ctrl-r, Atom displays ‘No symbols found’

2) Can’t jump to external symbol

In main.c, place cursor in ‘myFunc’ then right click and select ‘Go to Declaration’, Atom displays ‘No symbols found’.

Lastly, there is no indication (eg a spinner) that Atom read the tags file.

I hope that this test case helps to reproduce my problem.

Best regards

David


#7

You should click 'Rebuild ctags' next to 'Go to Declaration' first when open atom.


#8

I did that. The modification date of the tags file does not change (so I guess it was not rebuilt). ‘Go to Declaration’ still shows ‘No symbols found’.


#9

Do you have a Git repository initialized? Or are these just two files in a folder?


#10

Just two files in a folder. (I don’t use Git).


#11

atom-ctags did not support local symbol same as ctags.

I guess you place cursor at end of symbol as myFunc|, if so, you should place cursor at start or middle of symbol as |myFunc and my|Func


Atom Ctags 2.1.0 released
#12
  1. Local symbols

atom-ctags did not support local symbol same as ctags.

Agreed, but I thought that Atom’s own fuzzy search should support this. Any idea why not?

  1. Can’t jump to external symbol

I guess you place cursor at end of symbol as myFunc|, if so, you should place cursor at start or middle of symbol as |myFunc and my|Func

It doesn’t work in any of those 3 positions.


#13

It’s very strange, I test it at atom-ctags 2.2.0 and atom 0.130 and atom 0.136 on win7 x64, works normal.


#14

I cannot reproduce this issue on Atom v0.137.0-d351251 and OS X v10.9.5 just using the built-in symbols-view package. I do not have atom-ctags installed. In both cases, Atom acts as expected:

  1. Atom displays the list of symbols
  2. Atom goes to the myFunc declaration in myFunc.c

I also created the directory and files exactly as you specified with no Git repository. What I’d like you to try next is to:

  1. Go to your Atom session
  2. Open the Developer Tools: View > Developer > Toggle Developer Tools
  3. Switch to the Console tab
  4. Type the following and press ENTER: atom.project.getRootDirectory()
  5. Expand the first drop-down, if necessary
  6. Copy and paste the result in your next post

#15

Hi
I’m at home now and only have access to a Win 7 pc. I have installed Atom 0.136 but no extra packages. With the same file set I still can’t jump to the symbols. Ctrl-r only displays main. I did what you asked for and here is the output (for the Win 7 pc):

atom.project.getRootDirectory()
Directory {symlink: false, didRemoveSubscription: function, willAddSubscription: function, emitter: Emitter, subscriptionCounts: Object…}didRemoveSubscription: function (){ return fn.apply(me, arguments); }emitter: EmittereventHandlersByEventName: ObjectlowerCasePath: "c:\users\david\work\atom_test"path: "c:\Users\David\Work\Atom_test"subscriptionCounts: Objectsymlink: falsewillAddSubscription: function (){ return fn.apply(me, arguments); }__proto__: Directory

#16

Here’s a screenshot:


#17

And C:\Users\David\Work\Atom_test is where the tags file (and the others) resides?


#18

And C:\Users\David\Work\Atom_test is where the tags file (and the others) resides?

Yes.


#19

Wait, Ctrl+R should only display main if you are in the file main.c since that is the only symbol that ctags recognized. So, this is working as intended. If you want to see all the symbols for the entire project, you have to do the search in project version which I believe is Ctrl+Shift+R.


#20

Ok, thanks. That means it’s working ok on my Win 7 PC. Next I could install atom-ctags and see if that breaks it or we could wait until Monday and I’ll try again on my Win 8 PC at work. What do you think?