-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.lua
90 lines (70 loc) · 2.31 KB
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
-- additional modules
local multiedit = require'multiedit'
local textredux = require'textredux'
local editing = textadept.editing
textredux.hijack()
-- helper functions
local last_dir = nil
local snapopen_woot = function()
local directory = io.get_project_root() or (buffer.filename and buffer.filename:match('^(.+)[/\\]')) or last_dir or _USERHOME
last_dir = directory
textredux.fs.snapopen(directory, filter, exclude_FILTER)
end
local print = function(...)
local tmp = ui.SILENT_PRINT
ui.SILENT_PRINT = true
ui.print(...)
ui.SILENT_PRINT = tmp
end
-- parameters
io.SNAPOPEN_MAX = 10000
editing.AUTOCOMPLETE_ALL = true
-- events
events.connect(events.LEXER_LOADED, function(lang)
buffer.tab_width = 4
buffer.use_tabs = true
buffer.auto_c_ignore_case = true
editing.AUTOCOMPLETE_ALL = true
end)
events.connect(events.DOUBLE_CLICK, function(lang)
editing.highlight_word()
end)
-- keys
keys.cp = snapopen_woot
keys['c '] = {editing.autocomplete, 'word'}
keys.ac = {ui.command_entry.enter_mode, 'lua_command', 'lua'}
keys.cq = editing.block_comment
keys.ar = reset
keys['c.'] = {ui.goto_view, 1, true}
keys['c,'] = {ui.goto_view, -1, true}
-- why we need modifiers?
keys['"'] = {multiedit.enclose, '"', '"'}
keys["'"] = {multiedit.enclose, "'", "'"}
keys["("] = {multiedit.enclose, "(", ")"}
keys["["] = {multiedit.enclose, "[", "]"}
keys["{"] = {multiedit.enclose, "{", "}"}
-- mimics sublimes ctrl-d
keys.cd = multiedit.select_word
keys.af3 = multiedit.select_all_words
-- exchange all standard bindings with the multiedit version
keys['\n'] = multiedit.newline
keys.left = multiedit.char_left
keys.cleft = multiedit.word_left
keys.sleft = multiedit.char_left_extend
keys.csleft = multiedit.word_left_extend
keys.right = multiedit.char_right
keys.sright = multiedit.char_right_extend
keys.cright = multiedit.word_right
keys.csright = multiedit.word_right_extend
keys.home = multiedit.line_start
keys.shome = multiedit.line_start_extend
keys["end"] = multiedit.line_end
keys["send"] = multiedit.line_end_extend
-- i'm not sure how to handle these events yet...
-- just be careful for now :>
--keys.sup = multiedit.prevent_crap
--keys.sdown = multiedit.prevent_crap
--keys.spgup = multiedit.prevent_crap
--keys.spgdn = multiedit.prevent_crap
--keys.csup = multiedit.prevent_crap
--keys.csdown = multiedit.prevent_crap