Re: question about lua source navigation
Thanks Gary, this really helps me a lot :) On Sat, Jul 3, 2010 at 1:23 AM, Gary Johnson garyj...@spocom.com wrote: 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
Re: question about lua source navigation
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:) 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. 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_AUTHORDarren Hiebert / dhieb...@users.sourceforge.net/ !_TAG_PROGRAM_NAME Exuberant Ctags // !_TAG_PROGRAM_URL http://ctags.sourceforge.net/official site/ !_TAG_PROGRAM_VERSION 5.7 // Task:succeedsubdir/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 -- 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
question about lua source navigation
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?) -- 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
Re: question about lua source navigation
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. 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 -- 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 -- 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
Re: question about lua source navigation
The error code is E426. After I set iskeyword, the command set iskeyword? echos iskeyword=@,48-57,_,128-167,224-235,: but it still didn't solve the problem. Thanks anyway. 2010/6/30 Dominique Pellé dominique.pe...@gmail.com 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?) What error number do you get? Does adding colon character to 'iskeyword' helps?:set iskeyword+=: -- Dominique -- 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 -- 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