aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept
diff options
context:
space:
mode:
Diffstat (limited to 'modules/textadept')
-rw-r--r--modules/textadept/command_entry.lua14
-rw-r--r--modules/textadept/file_types.lua26
-rw-r--r--modules/textadept/run.lua20
-rw-r--r--modules/textadept/snippets.lua16
4 files changed, 38 insertions, 38 deletions
diff --git a/modules/textadept/command_entry.lua b/modules/textadept/command_entry.lua
index b335774c..34ebc7e8 100644
--- a/modules/textadept/command_entry.lua
+++ b/modules/textadept/command_entry.lua
@@ -173,7 +173,7 @@ local prev_key_mode
---
-- Opens the command entry, subjecting it to any key bindings defined in table
--- *keys*, highlighting text with lexer name *lexer*, and displaying
+-- *keys*, highlighting text with lexer name *lang*, and displaying
-- *height* number of lines at a time, and then when the `Enter` key is pressed,
-- closes the command entry and calls function *f* (if non-`nil`) with the
-- command entry's text as an argument.
@@ -190,22 +190,22 @@ local prev_key_mode
-- `Esc` and `Enter` are automatically defined to cancel and finish the
-- command entry, respectively.
-- This parameter may be omitted completely.
--- @param lexer Optional string lexer name to use for command entry text. The
+-- @param lang Optional string lexer name to use for command entry text. The
-- default value is `'text'`.
-- @param height Optional number of lines to display in the command entry. The
-- default value is `1`.
-- @see editing_keys
-- @usage ui.command_entry.run(ui.print)
-- @name run
-function M.run(f, keys, lexer, height)
+function M.run(f, keys, lang, height)
if M:auto_c_active() then M:auto_c_cancel() end -- may happen in curses
if not assert_type(f, 'function/nil', 1) and not keys then
- f, keys, lexer = run_lua, lua_keys, 'lua'
+ f, keys, lang = run_lua, lua_keys, 'lua'
elseif type(assert_type(keys, 'table/string/nil', 2)) == 'string' then
- lexer, height, keys = keys, assert_type(lexer, 'number/nil', 3), {}
+ lang, height, keys = keys, assert_type(lang, 'number/nil', 3), {}
else
if not keys then keys = {} end
- assert_type(lexer, 'string/nil', 3)
+ assert_type(lang, 'string/nil', 3)
assert_type(height, 'number/nil', 4)
end
if not keys['esc'] then keys['esc'] = M.focus end -- hide
@@ -228,7 +228,7 @@ function M.run(f, keys, lexer, height)
M:select_all()
prev_key_mode = _G.keys.mode
M.focus()
- M:set_lexer(lexer or 'text')
+ M:set_lexer(lang or 'text')
M.height = M:text_height(1) * (height or 1)
_G.keys._command_entry, _G.keys.mode = keys, '_command_entry'
end
diff --git a/modules/textadept/file_types.lua b/modules/textadept/file_types.lua
index b65de67f..3e55d292 100644
--- a/modules/textadept/file_types.lua
+++ b/modules/textadept/file_types.lua
@@ -11,7 +11,7 @@ local M = {}
-- properties since the module is not loaded when Textadept starts.
-- Arguments:
--
--- * _`lexer`_: The language lexer's name.
+-- * _`name`_: The language lexer's name.
module('textadept.file_types')]]
-- Events.
@@ -35,19 +35,19 @@ M.patterns = {['^#!.+[/ ][gm]?awk']='awk',['^#!.+[/ ]lua']='lua',['^#!.+[/ ]octa
local GETLEXERLANGUAGE = _SCINTILLA.properties.lexer_language[1]
-- LuaDoc is in core/.buffer.luadoc.
local function get_lexer(buffer, current)
- local lexer = buffer:private_lexer_call(GETLEXERLANGUAGE)
- return current and lexer:match('[^/]+$') or lexer:match('^[^/]+')
+ local name = buffer:private_lexer_call(GETLEXERLANGUAGE)
+ return current and name:match('[^/]+$') or name:match('^[^/]+')
end
-- Attempts to detect the language based on a buffer's first line of text or
-- that buffer's filename.
-- @param buffer The buffer to detect the language of.
--- @return lexer language or nil
+-- @return lexer name or nil
local function detect_language(buffer)
local line = buffer:get_line(1)
-- Detect from first line.
- for patt, lexer in pairs(M.patterns) do
- if line:find(patt) then return lexer end
+ for patt, lexer_name in pairs(M.patterns) do
+ if line:find(patt) then return lexer_name end
end
-- Detect from file extension.
return buffer.filename and M.extensions[buffer.filename:match('[^/\\.]+$')]
@@ -57,19 +57,19 @@ local SETDIRECTPOINTER = _SCINTILLA.properties.doc_pointer[2]
local SETLEXERLANGUAGE = _SCINTILLA.properties.lexer_language[2]
local GETERROR = _SCINTILLA.properties.status[1]
-- LuaDoc is in core/.buffer.luadoc.
-local function set_lexer(buffer, lang)
- assert_type(lang, 'string/nil', 2)
- if not lang then lang = detect_language(buffer) or 'text' end
+local function set_lexer(buffer, name)
+ assert_type(name, 'string/nil', 2)
+ if not name then name = detect_language(buffer) or 'text' end
buffer:private_lexer_call(SETDIRECTPOINTER, buffer.direct_pointer)
- buffer:private_lexer_call(SETLEXERLANGUAGE, lang)
+ buffer:private_lexer_call(SETLEXERLANGUAGE, name)
local errmsg = buffer:private_lexer_call(GETERROR)
if #errmsg > 0 then
buffer:private_lexer_call(SETLEXERLANGUAGE, 'text')
error(errmsg, 2)
end
- buffer._lexer = lang
- if package.searchpath(lang, package.path) then _M[lang] = require(lang) end
- if buffer ~= ui.command_entry then events.emit(events.LEXER_LOADED, lang) end
+ buffer._lexer = name
+ if package.searchpath(name, package.path) then _M[name] = require(name) end
+ if buffer ~= ui.command_entry then events.emit(events.LEXER_LOADED, name) end
local last_line = view.first_visible_line + view.lines_on_screen
buffer:colorize(1, buffer:position_from_line(last_line + 1)) -- refresh
end
diff --git a/modules/textadept/run.lua b/modules/textadept/run.lua
index 13932d1a..d76ae030 100644
--- a/modules/textadept/run.lua
+++ b/modules/textadept/run.lua
@@ -90,16 +90,16 @@ local function scan_for_error(message, ext_or_lexer)
end
detail.warning =
message:lower():find('warning') and not message:lower():find('error')
- -- Compile and run commands specify the file extension or lexer used to
- -- determine the command, so the error patterns used are guaranteed to be
- -- correct. Build commands have no such context and instead iterate
+ -- Compile and run commands specify the file extension or lexer name used
+ -- to determine the command, so the error patterns used are guaranteed to
+ -- be correct. Build commands have no such context and instead iterate
-- through all possible error patterns. Only consider the error/warning
- -- valid if the extracted filename's extension or lexer matches the error
- -- pattern's extension or lexer.
+ -- valid if the extracted filename's extension or lexer name matches the
+ -- error pattern's extension or lexer name.
if ext_or_lexer then return detail end
local ext = detail.filename:match('[^/\\.]+$')
- local lexer = textadept.file_types.extensions[ext]
- if ext == key or lexer == key then return detail end
+ local lexer_name = textadept.file_types.extensions[ext]
+ if key == ext or key == lexer_name then return detail end
::continue::
end
::continue::
@@ -186,9 +186,9 @@ local function compile_or_run(filename, commands)
if buffer.modify then buffer:save() end
end
local ext = filename:match('[^/\\.]+$')
- local lexer = filename == buffer.filename and buffer:get_lexer() or
+ local lang = filename == buffer.filename and buffer:get_lexer() or
textadept.file_types.extensions[ext]
- local command = commands[filename] or commands[ext] or commands[lexer]
+ local command = commands[filename] or commands[ext] or commands[lang]
local dirname, basename = '', filename
if filename:find('[/\\]') then
dirname, basename = filename:match('^(.+)[/\\]([^/\\]+)$')
@@ -199,7 +199,7 @@ local function compile_or_run(filename, commands)
['%p'] = filename, ['%d'] = dirname, ['%f'] = basename,
['%e'] = basename:match('^(.+)%.') -- no extension
}
- run_command(command, dirname, event, macros, commands[ext] and ext or lexer)
+ run_command(command, dirname, event, macros, commands[ext] and ext or lang)
end
---
diff --git a/modules/textadept/snippets.lua b/modules/textadept/snippets.lua
index a59884d8..52200c36 100644
--- a/modules/textadept/snippets.lua
+++ b/modules/textadept/snippets.lua
@@ -10,8 +10,8 @@ local M = {}
--
-- Define snippets in the global `snippets` table in key-value pairs. Each pair
-- consists of either a string trigger word and its snippet text, or a string
--- lexer language (from the *lexers/* directory) with a table of trigger words
--- and snippet texts. When searching for a snippet to insert based on a trigger
+-- lexer name (from the *lexers/* directory) with a table of trigger words and
+-- snippet texts. When searching for a snippet to insert based on a trigger
-- word, Textadept considers snippets in the current lexer to have priority,
-- followed by the ones in the global table. This means if there are two
-- snippets with the same trigger word, Textadept inserts the one specific to
@@ -149,12 +149,12 @@ local function find_snippet(grep, no_trigger)
local trigger = not no_trigger and buffer:text_range(
buffer:word_start_position(buffer.current_pos), buffer.current_pos) or ''
if no_trigger then grep = true end
- local lexer = buffer:get_lexer(true)
+ local lang = buffer:get_lexer(true)
local name_patt = '^' .. trigger
-- Search in the snippet tables.
local snippet_tables = {snippets}
- if type(snippets[lexer]) == 'table' then
- table.insert(snippet_tables, 1, snippets[lexer])
+ if type(snippets[lang]) == 'table' then
+ table.insert(snippet_tables, 1, snippets[lang])
end
for _, snippets in ipairs(snippet_tables) do
if not grep and snippets[trigger] then return trigger, snippets[trigger] end
@@ -173,15 +173,15 @@ local function find_snippet(grep, no_trigger)
-- "trigger.ext". Prefer "lexer."-prefixed snippets.
local p1, p2, p3 = basename:match('^([^.]+)%.?([^.]*)%.?([^.]*)$')
if not grep and
- (p1 == lexer and p2 == trigger or p1 == trigger and p3 == '') or
+ (p1 == lang and p2 == trigger or p1 == trigger and p3 == '') or
grep and
- (p1 == lexer and p2 and p2:find(name_patt) or
+ (p1 == lang and p2 and p2:find(name_patt) or
p1 and p1:find(name_patt) and p3 == '') then
local f = io.open(string.format('%s/%s', M.paths[i], basename))
text = f:read('a')
f:close()
if not grep then return trigger, text end
- matching_snippets[p1 == lexer and p2 or p1] = text
+ matching_snippets[p1 == lang and p2 or p1] = text
end
end
end