On 2010-07-03, X Heruacles wrote: > On Thu, Jul 1, 2010 at 4:42 AM, Gary Johnson <garyj...@spocom.com> wrote: > > On 2010-06-30, X Heruacles wrote: > > > On Wed, Jun 30, 2010 at 3:42 PM, Gary Johnson <garyj...@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.
[...] > So I think that's the problem: you need to have . in your > 'iskeyword' option for Lua files. > Sorry for the late reply Gary and thank you very much that it works!!! > But there are others that can't work, so I want to know why this helps. I > tried > to read some help file about iskeyword and isfname, but it hardly did help. So > I ask you do me a favor to describe the keyword and how it works?(maybe this > won't waste too much of your time) > Thank you again:) I'll try. Bear in mind that I don't know anything about Lua. Ctags knows Lua syntax, so it recognizes "TaskHandler.prizeTask" as a single entity for which it should create a tag. It creates a tag for "TaskHandler.prizeTask" and writes it to the tags file. When you type ^], Vim looks at the character under the cursor and the characters next to it and tries to identify a sequence of characters including the one under the cursor that form a keyword, by Vim's definition of a keyword. Vim then tries to find that keyword in its list of tags. Vim's definition of a keyword is a sequence of characters from the set in the 'iskeyword' option. Vim uses this definition for a lot of its commands, not just those related to tags. For example, it uses that definition to recognize words when executing w to move to the next word or diw to delete the word the cursor is on. Consequently, Vim's default definition of 'iskeyword' is set to correspond to a word as commonly used in text or a keyword as used in most programming languages: a sequence of characters from the set of alphanumeric characters and underscore. When you move Vim's cursor to the start of the Lua identifier TaskHandler.prizeTask and type ^], Vim will try to find the keyword under the cursor, which by its normal definition is "TaskHandler". "TaskHandler" is not a tag, though, so the command fails. Similarly, Vim recognizes "prizeTask" as a keyword but it is not a tag, either. You can make this work by adding . to the set of characters that Vim recognizes as part of a keyword, that is, by adding . to 'iskeyword': :set iskeyword+=. Now Vim will recognize "TaskHandler.prizeTask" as a single keyword and will successfully find it in its list of tags. The problem with this solution is that Vim will now include . as part of a word any time it does something with a word. For example, if you moved the cursor to the word "tags" at the end of the preceding paragraph and typed '*', Vim would search for the next occurrence of "tags.", including the period, not just "tags". I hope that was clear and not too much. Regards, 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