Re: [code] How to generate API files for Textadept's Lua auto-completer?

From: David Tamar <david-tamar.att.outlook.com>
Date: Sun, 27 Oct 2019 00:13:46 +0000

Hi Mitchell, it's going well so far and I'd like to suggest a small possible improvement for Textadept's auto-completion when developing for standalone Lua interpreters, and that is:

Textadept will suggest its own Lua API in auto-completion only if the current file (that is being edited) is located in Textadept's own directories, those are:

  1. Textadept's installation/source directory.
  2. Textadept's configuration directory at user's home.

In all other cases the only available Lua API for auto-completion should be that of the standard PUC Lua.
________________________________
From: Mitchell <m.att.foicica.com>
Sent: Friday, October 25, 2019 18:23
To: code.att.foicica.com <code.att.foicica.com>
Subject: Re: [code] How to generate API files for Textadept's Lua auto-completer?

Hi David,

On Fri, 25 Oct 2019, David Tamar wrote:

> Apparently, I managed to use Textadept a few months without any auto-completion or ctags to navigate the lexical scopes of my own Lua code. But recently I'm trying to understand how to generate API files so that TA's Lua completion could work with them on the fly.
>
> It's not clear to me how to divorce Textadept's Lua API from PUC-Rio's Lua API. Some of my projects are not related to TA, but they target stand-alone Lua interpreters of different versions (like LuaJIT 2.1, or Lua 5.1 for example). I'm also not sure how to auto-complete code from LuaRocks. In these cases TA should not autocomplete its own API since the code targets an external interpreter.

The instructions for generating your own autocompletion and documentation is here[1].

The Lua documentation used by Textadept is in *modules/lua/lua.luadoc*, so you can process that file manually or lump it in with your own code. Note that in order to have documentation show up nicely in Textadept (e.g. newlines are inserted correctly), you will have to patch your local copy of LuaDoc with *modules/lua/luadoc.patch*.

> There are some related issues with Lua's auto-completion in general that I wish to mention: It's currently not using fully-qualified names so it's confusing between same names coming from different tables.
> [snip]

Do you mean for documentation? For example, showing documentation for `print` in Textadept gives candidates for `_G.print()` and `ui.print()`. This is intentional, since you can alias modules to whatever name you want via `require()`. Textadept indicates there is more than one documentation match with the little arrows.

> There is also no static inferring for "require"-ed scopes, local scopes, and "assert"-ed inner structures of tables that were passed as parameters.

Would you please give an example? I'm not sure what you mean for each. Do note that Textadept does not do any sort of complex lexical analysis of code. It just does simple word lookups for the most part. See *modules/lua/init.lua*'s `textadept.editing.autocompleters.lua()`.

Cheers,
Mitchell

[1]: https://foicica.com/textadept/manual.html#Generating.Autocompletions.and.Documentation

--
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Sat 26 Oct 2019 - 20:13:46 EDT

This archive was generated by hypermail 2.2.0 : Sun 27 Oct 2019 - 06:34:42 EDT