Re: [textadept] Adeptsense for other languages

From: Robert <ro....at.web.de>
Date: Fri, 18 Feb 2011 14:52:58 +0100

On Fri, Feb 18, 2011 at 1:30 AM, mitchell <c....at.caladbolg.net> wrote:
> Hi,
>
> On Thu, 17 Feb 2011, mitchell wrote:
>
>> 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.
>
> I committed code to hg that supports type inference through variable
> assignment (e.g. local b = buffer) because it is used a lot in dynamic
> languages and should be in the adeptsense core.
>
> mitchell
>

Nice, I have a working prototype for Python now. Looking forward to
the Ruby adeptsense!

Robert
Received on Fri 18 Feb 2011 - 08:52:58 EST

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