aboutsummaryrefslogtreecommitdiff
path: root/modules/lua
diff options
context:
space:
mode:
Diffstat (limited to 'modules/lua')
-rw-r--r--modules/lua/init.lua35
-rw-r--r--modules/lua/ta_api5
-rw-r--r--modules/lua/ta_tags1
3 files changed, 20 insertions, 21 deletions
diff --git a/modules/lua/init.lua b/modules/lua/init.lua
index d3ef2419..abaa36aa 100644
--- a/modules/lua/init.lua
+++ b/modules/lua/init.lua
@@ -22,10 +22,8 @@ local function ta_api(filename)
local userhome = '^' .. _USERHOME:gsub('%p', '%%%0'):gsub('%%[/\\]', '[/\\]')
return function()
local buffer_filename = buffer.filename or ''
- if buffer_filename:find(home) or buffer_filename:find(userhome) or
- buffer == ui.command_entry or buffer._type then
- return filename
- end
+ return (buffer_filename:find(home) or buffer_filename:find(userhome) or
+ buffer == ui.command_entry or buffer._type) and filename
end
end
@@ -73,11 +71,11 @@ textadept.editing.autocompleters.lua = function()
local assignment = '%f[%w_]' .. symbol:gsub('(%p)', '%%%1') .. '%s*=%s*(.*)$'
for i = buffer:line_from_position(buffer.current_pos) - 1, 1, -1 do
local expr = buffer:get_line(i):match(assignment)
- if expr then
- for patt, type in pairs(M.expr_types) do
- if expr:find(patt) then symbol = type break end
- end
+ if not expr then goto continue end
+ for patt, type in pairs(M.expr_types) do
+ if expr:find(patt) then symbol = type break end
end
+ ::continue::
end
-- Search through ctags for completions for that symbol.
local name_patt = '^' .. part
@@ -87,14 +85,13 @@ textadept.editing.autocompleters.lua = function()
if not filename or not lfs.attributes(filename) then goto continue end
for tag_line in io.lines(filename) do
local name = tag_line:match('^%S+')
- if name:find(name_patt) and not list[name] then
- local fields = tag_line:match(';"\t(.*)$')
- local k, class = fields:sub(1, 1), fields:match('class:(%S+)') or ''
- if class == symbol and (op ~= ':' or k == 'f') then
- list[#list + 1] = name .. sep .. xpms[k]
- list[name] = true
- end
+ if not name:find(name_patt) or list[name] then goto continue end
+ local fields = tag_line:match(';"\t(.*)$')
+ local k, class = fields:sub(1, 1), fields:match('class:(%S+)') or ''
+ if class == symbol and (op ~= ':' or k == 'f') then
+ list[#list + 1], list[name] = name .. sep .. xpms[k], true
end
+ ::continue::
end
::continue::
end
@@ -102,10 +99,10 @@ textadept.editing.autocompleters.lua = function()
return #part, list
end
-local api_files = textadept.editing.api_files
-api_files.lua[#api_files.lua + 1] = _HOME .. '/modules/lua/api'
-api_files.lua[#api_files.lua + 1] = _USERHOME .. '/modules/lua/api'
-api_files.lua[#api_files.lua + 1] = ta_api(_HOME .. '/modules/lua/ta_api')
+local api_files = textadept.editing.api_files.lua
+table.insert(api_files, _HOME .. '/modules/lua/api')
+table.insert(api_files, _USERHOME .. '/modules/lua/api')
+table.insert(api_files, ta_api(_HOME .. '/modules/lua/ta_api'))
-- Commands.
diff --git a/modules/lua/ta_api b/modules/lua/ta_api
index c5e573e6..631fcb61 100644
--- a/modules/lua/ta_api
+++ b/modules/lua/ta_api
@@ -340,7 +340,7 @@ args _G.args (module)\nProcesses command line arguments for Textadept.
ascii lexer.ascii (pattern)\nA pattern that matches any ASCII character (codes 0 to 127).
assert _G.assert (module)\nExtends `_G` with formatted assertions and function argument type checks.
assert _G.assert(v, message, ...)\nAsserts that value *v* is not `false` or `nil` and returns *v*, or calls\n`error()` with *message* as the error message, defaulting to "assertion\nfailed!". If *message* is a format string, the remaining arguments are passed\nto `string.format()` and the resulting string becomes the error message.\n@param v Value to assert.\n@param message Optional error message to show on error. The default value is\n "assertion failed!".\n@param ... If *message* is a format string, these arguments are passed to\n `string.format()`.
-assert_type _G.assert_type(v, expected_type, narg)\nAsserts that value *v* has type string *expected_type* and returns *v*, or\ncalls `error()` with an error message that implicates function argument\nnumber *narg*.\nThis is intended to be used with API function arguments so users receive more\nhelpful error messages.\n@param v Value to assert the type of.\n@param expected_type String type to assert. It may be a punctuation-delimited\n list of type options.\n@param narg The positional argument number *v* is associated with. This is\n not required to be a number.\n@usage assert_type(filename, 'string/nil', 1)\n@usage assert_type(option.setting, 'number', 'setting') -- implicates key
+assert_type _G.assert_type(v, expected_type, narg)\nAsserts that value *v* has type string *expected_type* and returns *v*, or\ncalls `error()` with an error message that implicates function argument\nnumber *narg*.\nThis is intended to be used with API function arguments so users receive more\nhelpful error messages.\n@param v Value to assert the type of.\n@param expected_type String type to assert. It may be a non-letter-delimited\n list of type options.\n@param narg The positional argument number *v* is associated with. This is\n not required to be a number.\n@usage assert_type(filename, 'string/nil', 1)\n@usage assert_type(option.setting, 'number', 'setting') -- implicates key
auto_c_active buffer.auto_c_active(buffer)\nReturns whether or not an autocompletion or user list is visible.\n@param buffer A buffer.\n@return bool
auto_c_auto_hide buffer.auto_c_auto_hide (bool)\nAutomatically cancel an autocompletion or user list when no entries match\ntyped text.\nThe default value is `true`.
auto_c_cancel buffer.auto_c_cancel(buffer)\nCancels the displayed autocompletion or user list.\n@param buffer A buffer.
@@ -770,7 +770,7 @@ property_int lexer.property_int (table, Read-only)\nMap of key-value pairs with
property_int view.property_int (table, Read-only)\nMap of key-value pairs used by lexers with values interpreted as numbers,\nor `0` if not found.
punct lexer.punct (pattern)\nA pattern that matches any punctuation character ('!' to '/', ':' to '@',\n'[' to ''', '{' to '~').
punctuation_chars buffer.punctuation_chars (string)\nThe string set of characters recognized as punctuation characters.\nSet this only after setting `buffer.word_chars`.\nThe default value is a string that contains all non-word and non-whitespace\ncharacters.
-quick_open io.quick_open(paths, filter, opts)\nPrompts the user to select files to be opened from *paths*, a string\ndirectory path or list of directory paths, using a filtered list dialog.\nIf *paths* is `nil`, uses the current project's root directory, which is\nobtained from `io.get_project_root()`.\nString or list *filter* determines which files to show in the dialog, with\nthe default filter being `io.quick_open_filters[path]` (if it exists) or\n`lfs.default_filter`. A filter consists of Lua patterns that match file and\ndirectory paths to include or exclude. Patterns are inclusive by default.\nExclusive patterns begin with a '!'. If no inclusive patterns are given, any\npath is initially considered. As a convenience, file extensions can be\nspecified literally instead of as a Lua pattern (e.g. '.lua' vs. '%.lua$'),\nand '/' also matches the Windows directory separator ('[/\\]' is not needed).\nThe number of files in the list is capped at `quick_open_max`.\nIf *filter* is `nil` and *paths* is ultimately a string, the filter from the\n`io.quick_open_filters` table is used. If that filter does not exist,\n`lfs.default_filter` is used.\n*opts* is an optional table of additional options for\n`ui.dialogs.filteredlist()`.\n@param paths Optional string directory path or table of directory paths to\n search. The default value is the current project's root directory, if\n available.\n@param filter Optional filter for files and directories to include and/or\n exclude. The default value is `lfs.default_filter` unless *paths* is a\n string and a filter for it is defined in `io.quick_open_filters`.\n@param opts Optional table of additional options for\n `ui.dialogs.filteredlist()`.\n@usage io.quick_open(buffer.filename:match('^(.+)[/\\]')) -- list all files\n in the current file's directory, subject to the default filter\n@usage io.quick_open(io.get_current_project(), '.lua') -- list all Lua files\n in the current project\n@usage io.quick_open(io.get_current_project(), '!/build') -- list all files\n in the current project except those in the build directory\n@see io.quick_open_filters\n@see lfs.default_filter\n@see quick_open_max\n@see ui.dialogs.filteredlist
+quick_open io.quick_open(paths, filter, opts)\nPrompts the user to select files to be opened from *paths*, a string\ndirectory path or list of directory paths, using a filtered list dialog.\nIf *paths* is `nil`, uses the current project's root directory, which is\nobtained from `io.get_project_root()`.\nString or list *filter* determines which files to show in the dialog, with\nthe default filter being `io.quick_open_filters[path]` (if it exists) or\n`lfs.default_filter`. A filter consists of Lua patterns that match file and\ndirectory paths to include or exclude. Patterns are inclusive by default.\nExclusive patterns begin with a '!'. If no inclusive patterns are given, any\npath is initially considered. As a convenience, file extensions can be\nspecified literally instead of as a Lua pattern (e.g. '.lua' vs. '%.lua$'),\nand '/' also matches the Windows directory separator ('[/\\]' is not needed).\nThe number of files in the list is capped at `quick_open_max`.\nIf *filter* is `nil` and *paths* is ultimately a string, the filter from the\n`io.quick_open_filters` table is used. If that filter does not exist,\n`lfs.default_filter` is used.\n*opts* is an optional table of additional options for\n`ui.dialogs.filteredlist()`.\n@param paths Optional string directory path or table of directory paths to\n search. The default value is the current project's root directory, if\n available.\n@param filter Optional filter for files and directories to include and/or\n exclude. The default value is `lfs.default_filter` unless a filter for\n *paths* is defined in `io.quick_open_filters`.\n@param opts Optional table of additional options for\n `ui.dialogs.filteredlist()`.\n@usage io.quick_open(buffer.filename:match('^(.+)[/\\]')) -- list all files\n in the current file's directory, subject to the default filter\n@usage io.quick_open(io.get_current_project(), '.lua') -- list all Lua files\n in the current project\n@usage io.quick_open(io.get_current_project(), '!/build') -- list all files\n in the current project except those in the build directory\n@see io.quick_open_filters\n@see lfs.default_filter\n@see quick_open_max\n@see ui.dialogs.filteredlist
quick_open_filters io.quick_open_filters (table)\nMap of directory paths to filters used by `io.quick_open()`.\n@see quick_open
quick_open_max io.quick_open_max (number)\nThe maximum number of files listed in the quick open dialog.\nThe default value is `1000`.
quit _G.quit()\nEmits a `QUIT` event, and unless any handler returns `false`, quits\nTextadept.\n@see events.QUIT
@@ -857,6 +857,7 @@ selection_n_start_virtual_space buffer.selection_n_start_virtual_space (number,
selection_start buffer.selection_start (number)\nThe position of the beginning of the selected text.\nWhen set, becomes the anchor, but is not scrolled into view.
selections buffer.selections (number, Read-only)\nThe number of active selections. There is always at least one selection.
session textadept.session (module)\nSession support for Textadept.
+set_arguments textadept.run.set_arguments(filename, run, compile)\nAppends the command line argument strings *run* and *compile* to their\nrespective run and compile commands for file *filename* or the current file.\nIf either is `nil`, prompts the user for missing the arguments. Each filename\nhas its own set of compile and run arguments.\n@param filename Optional path to the file to set run/compile arguments for.\n@param run Optional string run arguments to set. If `nil`, the user is\n prompted for them. Pass the empty string for no run arguments.\n@param compile Optional string compile arguments to set. If `nil`, the user\n is prompted for them. Pass the empty string for no compile arguments.\n@see run_commands\n@see compile_commands
set_chars_default buffer.set_chars_default(buffer)\nResets `buffer.word_chars`, `buffer.whitespace_chars`, and\n`buffer.punctuation_chars` to their respective defaults.\n@param buffer A buffer.\n@see word_chars\n@see whitespace_chars\n@see punctuation_chars
set_default_fold_display_text view.set_default_fold_display_text(view, text)\nSets the default fold display text to string *text*.\n@param view A view.\n@param text The text to display by default next to folded lines.\n@see toggle_fold_show_text
set_empty_selection buffer.set_empty_selection(buffer, pos)\nMoves the caret to position *pos* without scrolling the view and removes any\nselections.\n@param buffer A buffer\n@param pos The position in *buffer* to move to.
diff --git a/modules/lua/ta_tags b/modules/lua/ta_tags
index a213f6ef..e186e8e3 100644
--- a/modules/lua/ta_tags
+++ b/modules/lua/ta_tags
@@ -859,6 +859,7 @@ selection_n_start_virtual_space _HOME/core/.buffer.luadoc /^module('buffer')$/;"
selection_start _HOME/core/.buffer.luadoc /^module('buffer')$/;" F class:buffer
selections _HOME/core/.buffer.luadoc /^module('buffer')$/;" F class:buffer
session _HOME/modules/textadept/session.lua /^module('textadept.session')]]$/;" m class:textadept
+set_arguments _HOME/modules/textadept/run.lua /^function M.set_arguments(filename, run, compile)$/;" f class:textadept.run
set_chars_default _HOME/core/.buffer.luadoc /^function set_chars_default(buffer) end$/;" f class:buffer
set_default_fold_display_text _HOME/core/.view.luadoc /^function set_default_fold_display_text(view, text) end$/;" f class:view
set_empty_selection _HOME/core/.buffer.luadoc /^function set_empty_selection(buffer, pos) end$/;" f class:buffer