aboutsummaryrefslogtreecommitdiff
path: root/modules/lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2020-02-18 15:58:16 -0500
committermitchell <70453897+667e-11@users.noreply.github.com>2020-02-18 15:58:16 -0500
commit2a9d3e73daa332ffe652c9b33c160b784e51ed0e (patch)
treee7d0f0dc75319c674711771bfc41213a5dac8370 /modules/lua
parentd5ba0b9a714cfc265f69d3d03974cfbfa0281176 (diff)
downloadtextadept-2a9d3e73daa332ffe652c9b33c160b784e51ed0e.tar.gz
textadept-2a9d3e73daa332ffe652c9b33c160b784e51ed0e.zip
Added snippet trigger word completion.
Also refactored snippet lookup, added options to Lua and C modules to include snippet triggers in autocompletion lists, swapped snippet keybindings, and fixed a bug recognizing lexer-specific snippet files as global.
Diffstat (limited to 'modules/lua')
-rw-r--r--modules/lua/init.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/lua/init.lua b/modules/lua/init.lua
index ac6b824b..c199e4e8 100644
--- a/modules/lua/init.lua
+++ b/modules/lua/init.lua
@@ -6,6 +6,9 @@ local M = {}
---
-- The lua module.
-- It provides utilities for editing Lua code.
+-- @field autocomplete_snippets (boolean)
+-- Whether or not to include snippets in autocompletion lists.
+-- The default value is `false`.
module('_M.lua')]]
-- Autocompletion and documentation.
@@ -49,6 +52,8 @@ M.tags = {
-- @usage _M.lua.expr_types['^spawn%b()%s*$'] = 'proc'
M.expr_types = {['^[\'"]'] = 'string', ['^io%.p?open%s*%b()%s*$'] = 'file'}
+M.autocomplete_snippets = true
+
local XPM = textadept.editing.XPM_IMAGES
local xpms = {m = XPM.CLASS, f = XPM.METHOD, F = XPM.VARIABLE, t = XPM.TYPEDEF}
@@ -58,6 +63,10 @@ textadept.editing.autocompleters.lua = function()
local line, pos = buffer:get_cur_line()
local symbol, op, part = line:sub(1, pos):match('([%w_%.]-)([%.:]?)([%w_]*)$')
if symbol == '' and part == '' then return nil end -- nothing to complete
+ if symbol == '' and M.autocomplete_snippets then
+ local _, snippets = textadept.editing.autocompleters.snippet()
+ for i = 1, #snippets do list[#list + 1] = snippets[i] end
+ end
symbol, part = symbol:gsub('^_G%.?', ''), part ~= '_G' and part or ''
-- Attempt to identify string type and file type symbols.
local buffer = buffer