aboutsummaryrefslogtreecommitdiff
path: root/modules/textadept/mime_types.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2013-06-21 13:11:41 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2013-06-21 13:11:41 -0400
commit004bb689fcd3b945f0ca724ed73f9e1215f6ec34 (patch)
tree46def5ca1dcc233d3cae88ae18cddc85b6e80fba /modules/textadept/mime_types.lua
parent587431211265436e38ce7ec78bf30237541b0f97 (diff)
downloadtextadept-004bb689fcd3b945f0ca724ed73f9e1215f6ec34.tar.gz
textadept-004bb689fcd3b945f0ca724ed73f9e1215f6ec34.zip
Always emit `events.LANGUAGE_MODULE_LOADED`; modules/textadept/mime_types.lua
Creates an empty language-specific module if none exists. This enables users to add keys and snippets for any lexer without an existing language-specific module. It also allows themes to override styles for any lexer.
Diffstat (limited to 'modules/textadept/mime_types.lua')
-rw-r--r--modules/textadept/mime_types.lua11
1 files changed, 5 insertions, 6 deletions
diff --git a/modules/textadept/mime_types.lua b/modules/textadept/mime_types.lua
index 39ba8be7..be21824e 100644
--- a/modules/textadept/mime_types.lua
+++ b/modules/textadept/mime_types.lua
@@ -88,12 +88,11 @@ local function set_lexer(buffer, lang)
buffer._lexer = lang
buffer:private_lexer_call(SETDIRECTPOINTER, buffer.direct_pointer)
buffer:private_lexer_call(SETLEXERLANGUAGE, lang)
- if package.searchpath(lang, package.path) then
- _M[lang] = require(lang)
- local post_init = lang..'.post_init'
- if package.searchpath(post_init, package.path) then require(post_init) end
- events.emit(events.LANGUAGE_MODULE_LOADED, lang)
- end
+ _M[lang] = package.searchpath(lang, package.path) and require(lang) or {}
+ keys[lang], snippets[lang] = keys[lang] or {}, snippets[lang] or {}
+ local post_init = lang..'.post_init'
+ if package.searchpath(post_init, package.path) then require(post_init) end
+ events.emit(events.LANGUAGE_MODULE_LOADED, lang)
local last_line = buffer.first_visible_line + buffer.lines_on_screen
buffer:colourise(0, buffer:position_from_line(last_line + 1))
end