diff options
author | 2016-06-27 22:06:46 -0400 | |
---|---|---|
committer | 2016-06-27 22:06:46 -0400 | |
commit | 556a0fa7dd9fe28898d2922b304fa86e8318aad3 (patch) | |
tree | efe64353d74315e84bacd859d05665b419905ce0 | |
parent | 1b8baa82041e1a322b5b347cfa721dca6a28f900 (diff) |
Show file-based snippets in the selection dialog; modules/textadept/snippets.lua
-rw-r--r-- | modules/textadept/snippets.lua | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/modules/textadept/snippets.lua b/modules/textadept/snippets.lua index 0a44c2b2..f519f07e 100644 --- a/modules/textadept/snippets.lua +++ b/modules/textadept/snippets.lua @@ -379,11 +379,22 @@ function M._select() for trigger, text in pairs(snippets) do if type(text) == 'string' then list[#list + 1] = trigger..'|'..text end end - if snippets[buffer:get_lexer(true)] then - for trigger, text in pairs(snippets[buffer:get_lexer(true)]) do + local lexer = buffer:get_lexer(true) + if snippets[lexer] then + for trigger, text in pairs(snippets[lexer]) do if type(text) == 'string' then list[#list + 1] = trigger..'|'..text end end end + for i = 1, #M._paths do + for basename in lfs.dir(M._paths[i]) do + local first, second = basename:match('^([^.]+)%.?([^.]*)') + if second == '' or first == lexer then + local f = io.open(M._paths[i]..'/'..basename) + list[#list + 1] = (second ~= '' and second or first)..'|'..f:read('*a') + f:close() + end + end + end table.sort(list) for i = 1, #list do items[#items + 1], items[#items + 2] = list[i]:match('^([^|]+)|(.+)$') |