1local info = {
2 version = 1.002,
3 comment = "ini for textadept for context/metafun",
4 author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
5 copyright = "PRAGMA ADE / ConTeXt Development Team",
6 license = "see context related readme files",
7}
8
9
10
11
12
13if not textadept then
14 return
15end
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39package.path = table.concat ( {
40
41 _USERHOME .. "/?.lua",
42
43 _USERHOME .. "/lexers/?.lua",
44 _USERHOME .. "/modules/?.lua",
45 _USERHOME .. "/themes/?.lua",
46 _USERHOME .. "/data/?.lua",
47
48 package.path
49
50}, ';')
51
52
53
54
55local sessionpath = os.getenv(not WIN32 and 'HOME' or 'USERPROFILE') .. '/.textadept'
56local sessionfile = not CURSES and 'session' or 'session_term'
57
58textadept.session.default_session = sessionpath .. "/" .. sessionfile
59textadept.session.save_on_quit = true
60textadept.session.max_recent_files = 25
61
62
63
64require("scite-context-lexer")
65require("textadept-context-runner")
66require("textadept-context-files")
67require("scite-context-theme")
68require("textadept-context-settings")
69require("textadept-context-types")
70
71
72
73
74buffer:set_theme("scite-context-theme")
75
76
77
78
79
80
81
82
83
84
85
86
87local events_connect = events.connect
88
89local function events_newbuffer()
90 local buffer = _G.buffer
91 local SETDIRECTFUNCTION = _SCINTILLA.properties.direct_function[1]
92 local SETDIRECTPOINTER = _SCINTILLA.properties.doc_pointer[2]
93 local SETLUASTATE = _SCINTILLA.functions.change_lexer_state[1]
94 local SETLEXERLANGUAGE = _SCINTILLA.properties.lexer_language[2]
95 buffer.lexer_language = 'lpeg'
96 buffer:private_lexer_call(SETDIRECTFUNCTION, buffer.direct_function)
97 buffer:private_lexer_call(SETDIRECTPOINTER, buffer.direct_pointer)
98 buffer:private_lexer_call(SETLUASTATE, _LUA)
99 buffer.property['lexer.lpeg.home'] = _USERHOME..'/lexers/?.lua;'.. _HOME..'/lexers'
100
101 buffer:private_lexer_call(SETLEXERLANGUAGE, 'text')
102 if buffer == ui.command_entry then
103 buffer.caret_line_visible = false
104 end
105end
106
107
108
109local ctrl_keys = {
110 '[', ']', '/', '\\', 'Z', 'Y', 'X', 'C', 'V', 'A', 'L', 'T', 'D', 'U'
111}
112
113local ctrl_shift_keys = {
114 'L', 'T', 'U', 'Z'
115}
116
117local function events_newview()
118 local buffer = _G.buffer
119 for i=1, #ctrl_keys do
120 buffer:clear_cmd_key(string.byte(ctrl_keys[i]) | buffer.MOD_CTRL << 16)
121 end
122 for i=1, #ctrl_shift_keys do
123 buffer:clear_cmd_key(string.byte(ctrl_shift_keys[i]) | (buffer.MOD_CTRL | buffer.MOD_SHIFT) << 16)
124 end
125 if #_VIEWS > 1 then
126
127 local SETLEXERLANGUAGE = _SCINTILLA.properties.lexer_language[2]
128 buffer:private_lexer_call(SETLEXERLANGUAGE, buffer._lexer or 'text')
129 end
130end
131
132events.connect = function(where,what,location)
133 if location == 1 then
134 if where == events.BUFFER_NEW then
135 return events_connect(where,events_newbuffer,location)
136 elseif where == events.VIEW_NEW then
137 return events_connect(where,events_newview,location)
138 end
139 end
140 return events_connect(where,what,location)
141end
142
143local savedrequire = require
144
145require = function(name,...)
146 return savedrequire(name == "lexer" and "scite-context-lexer" or name,...)
147end
148 |