Wednesday, June 30, 2010

Re: question about lua source navigation

On 2010-06-30, X Heruacles wrote:

> On Wed, Jun 30, 2010 at 3:42 PM, Gary Johnson <garyjohn@spocom.com> wrote:
>
> On 2010-06-30, X Heruacles wrote:
> > I'm just learning lua and I use vim to navigate some lua projects. I use
> ctags
> > to generate tags using a map:
> >
> > map <F12> <Esc>:!ctags -R .<CR>
> >
> > but it rarely helps. When I want to jump to some function definition, it
> always
> > errs. Then I checked the generated tag and it seems fine. So my question
> is
> > just is there a better way to navigate lua project?(esp. jumping to
> function
> > definition?)
>
> I don't know what else might be available for navigating Lua, but
> the ctags web page at SourceForge says that it understands Lua, and
> you write that the tags appear fine, so I would suggest that you
> find out why your Lua tags aren't working as you expect and fix that
> problem. If you post a short file containing Lua code and explain
> what you do and what happens when you try to jump to a tag in that
> code, we might be able to spot the problem and give you a solution.
>
> Regards,
> Gary

> thanks Gary. Then I show the code here:
> the generated tag has a line looks like this:
>
> TaskHandler.prizeTask .\init\taskHandler.lua /^function
> TaskHandler.prizeTask(plr, task)$/;" f
>
> and I have a function:
>
> function Task:succeed()
>
> debug_log("Task:succeed")
>
> self.isSucceed = true
>
> TaskHandler.prizeTask(self.owner, self)
>
> self:eventOnSuccess()
>
> if self.spanTimerId > 0 then self:clearSpanTimer() end
>
> self.owner:addFinishedTask(self)
>
> if self.entry.type == taskType.TASK_TYPE_MAIN then
>
> self.owner:setSaveRecord("MainTask", self:getId(), 0)
>
> else
>
> end
>
> if self.entry.nexttask ~= nil and self.entry.nexttask ~= 0 then
>
> debug_log("self.owner:addTask")
>
> self.owner:addTask(self.entry.nexttask)
>
> end
>
> end
>
>
>
> in the file task.lua in the subdirectory of where the tags file lies. While my
> cursor on "prizeTask", I press Ctrl-], only to find it shows me an error that
> can't find the tag: prizeTask. So it is.

Thanks for the code. I tried to replicate the problem but ctags is
not generating the same tags for me as it did for you.

I created a new directory for testing this and within that directory
created a subdirectory, subdir. I put your code into a file named
task.lua in subdir. In the top-level directory I executed

ctags -R .

Here is the resulting 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.7 //
Task:succeed subdir/task.lua /^ function Task:succeed()$/;" f

As you can see, it contains only one tag.

I opened a file in the top-level directory and added the line

Task:succeed

Typing ^] over "Task" resulted in

E426: tag not found: Task

and typing ^] over "succeed" resulted in

E426: tag not found: succeed

I then executed

:set iskeyword+=:

Typing ^] anywhere over "Task:succeed" then resulted in Vim jumping
to the top of that function.

[Time passes while I do other work and think some more.]

I just appended those lines from your tags file to mine and added
tabs between the fields. Typing ^] over "TaskHandler" or
"prizeTask" resulted in E426. Then I executed

:set iskeyword+=.

and tried again. This time I got this error:

E429: File ".\init\taskHandler.lua" does not exist

So I think that's the problem: you need to have . in your
'iskeyword' option for Lua files.

HTH,
Gary

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: