aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2019-11-08 23:50:57 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2019-11-08 23:50:57 -0500
commitee9e8700ae84aa246ec01422aef83b673b5b1cf7 (patch)
treec808da714d412d4c6d5972932e9ce384ff3dff55 /modules/textadept
parente7d1e26a6db30304f61a59702cbca2f92d673af0 (diff)
downloadtextadept-ee9e8700ae84aa246ec01422aef83b673b5b1cf7.tar.gz
textadept-ee9e8700ae84aa246ec01422aef83b673b5b1cf7.zip
API file lists and Lua tags lists can contain functions that return file paths.
This gives more control over when to include certain autocompletion and documentation files like Textadept's API.
Diffstat (limited to 'modules/textadept')
-rw-r--r--modules/textadept/command_entry.lua9
-rw-r--r--modules/textadept/editing.lua7
2 files changed, 5 insertions, 11 deletions
diff --git a/modules/textadept/command_entry.lua b/modules/textadept/command_entry.lua
index b506757a..d858f071 100644
--- a/modules/textadept/command_entry.lua
+++ b/modules/textadept/command_entry.lua
@@ -203,21 +203,12 @@ events.connect(events.INITIALIZED, function()
for key, f in pairs(keys) do
if f == textadept.editing.show_documentation then
lua_mode_keys[key] = function()
- -- Enable Textadept API documentation unless the Lua module already
- -- enabled it.
- local api_files = textadept.editing.api_files
- if not api_files.lua[_HOME] then
- api_files.lua[#api_files.lua + 1] = _HOME..'/modules/lua/ta_api'
- end
-- Temporarily change _G.buffer since ui.command_entry is the "active"
-- buffer.
local orig_buffer = _G.buffer
_G.buffer = ui.command_entry
textadept.editing.show_documentation()
_G.buffer = orig_buffer
- -- Disable Textadept API documentation unless the Lua module previously
- -- enabled it.
- if not api_files.lua[_HOME] then api_files.lua[#api_files.lua] = nil end
end
break
end
diff --git a/modules/textadept/editing.lua b/modules/textadept/editing.lua
index 35016c71..fe54e1ed 100644
--- a/modules/textadept/editing.lua
+++ b/modules/textadept/editing.lua
@@ -113,6 +113,7 @@ M.autocompleters = {}
---
-- Map of lexer names to API documentation file tables.
+-- File tables contain API file paths or functions that return such paths.
-- Each line in an API file consists of a symbol name (not a fully qualified
-- symbol name), a space character, and that symbol's documentation. "\n"
-- represents a newline character.
@@ -697,8 +698,10 @@ function M.show_documentation(pos, case_insensitive)
end)
end
for i = 1, #M.api_files[lang] do
- if lfs.attributes(M.api_files[lang][i]) then
- for line in io.lines(M.api_files[lang][i]) do
+ local file = M.api_files[lang][i]
+ if type(file) == 'function' then file = file() end
+ if file and lfs.attributes(file) then
+ for line in io.lines(file) do
if line:find(symbol_patt) then
api_docs[#api_docs + 1] = line:match(symbol_patt..'%s+(.+)$')
end