Re: [textadept] Adeptsense for other languages

From: mitchell <c....at.caladbolg.net>
Date: Thu, 17 Feb 2011 16:05:58 -0500 (Eastern Standard Time)

Robert,

On Thu, 17 Feb 2011, Robert wrote:

> On Thu, Feb 17, 2011 at 3:53 PM, mitchell <c....at.caladbolg.net> wrote:
>> Robert,
>>
>>> why is the ctags format for the output of the Lua files emulated?
>>
>> Because ctags support for Lua is awful.
>>
>>> Can
>>> I try to write directly to the "sense" table if ctags support is
>>> difficult?
>>
>> Yes of course.
>>
>> sense.completions = {
>> �['class'] = { functions = {}, fields = {} },
>> �...
>> }
>>
>> is the general format. Let me know if you have any other questions. I hope
>> this helps.
>>
>> mitchell
>>
>> --
>
> Thanks,
> so I can do
> _m.lua.adeptsense.sense.completions['b'] =
> _m.lua.adeptsense.sense.completions['buffer']
> to get autocompletion after I did
> local b = buffer
>
> Should be possible to loop over variable declarations and require
> statements to get autocompletions for those cases as well, e.g.
> local m_snapopen = _m.textadept.snapopen
>
> What would be a good point to do this? After each save, on demand with
> a key command?

Instead of modifying sense.completions directly, you would want to
override the get_class() sense function and look for variable
assignments, e.g. (untested)

function sense:get_class(symbol)
   local buffer = buffer
   for i = buffer:line_from_position(buffer.current_pos), 0, -1 do
     local line = buffer:get_line(i)
     local class = line:match(symbol..'%s*=%s*([%w_%.]+)')
     if class then return class end
   end
   return self.super.get_class(self, symbol)
end

This obviously has advantage in that it can adapt to context. Something
like this is done for the Java adeptsense module I wrote that you can find
on the wiki (java module). I am also working on a Ruby adeptsense module
that does some pretty powerful stuff with a get_class() override. After
that I will work on some documentation since I'm still learning about
adeptsense's full potential.

mitchell
Received on Thu 17 Feb 2011 - 16:05:58 EST

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 12:00:00 EST