SHARE
TWEET

.textadept/init.lua

a guest Nov 10th, 2013 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. require 'textadept'
  2.  
  3. -- _M.file_browser = require 'file_browser'
  4.  
  5. --ui.set_theme(not CURSES and 'custom' or 'custom_term')
  6. if not CURSES then ui.set_theme('dark-custom') end
  7.  
  8. textadept.editing.AUTOPAIR = false
  9. textadept.editing.TYPEOVER_CHARS = false
  10. --buffer.auto_c_auto_hide = false
  11. --buffer.end_at_last_line = false
  12.  
  13. events.connect(events.BUFFER_NEW, function(...)
  14.         buffer.end_at_last_line = false
  15.         buffer.auto_c_auto_hide = false
  16.   buffer.auto_c_drop_rest_of_word = true
  17.         buffer.edge_colour = 0x800080
  18.         buffer.edge_column = 80
  19.         buffer.edge_mode = _SCINTILLA.constants.EDGE_LINE
  20.         buffer.tab_width = 4
  21.         buffer.use_tabs = true
  22.  
  23.         local INDIC_BRACEMATCH = textadept.editing.INDIC_BRACEMATCH
  24.         buffer.indic_style[INDIC_BRACEMATCH] = buffer.INDIC_ROUNDBOX
  25.         buffer.indic_fore[INDIC_BRACEMATCH] = 0x00FF00
  26.         buffer.indic_alpha[INDIC_BRACEMATCH] = 192
  27.         buffer.indic_under[INDIC_BRACEMATCH] = true
  28. end)
  29.  
  30. --highlight the active pane
  31. events.connect(events.VIEW_BEFORE_SWITCH, function()
  32.   buffer.h_scroll_bar = false
  33.   buffer.v_scroll_bar = false
  34.   buffer:marker_enable_highlight(false)
  35. end)
  36.  
  37. events.connect(events.VIEW_AFTER_SWITCH, function()
  38.   buffer.h_scroll_bar = true
  39.   buffer.v_scroll_bar = true
  40.   buffer:marker_enable_highlight(true)
  41. end)
  42.  
  43. --magic auto wrapping
  44. --[[ keys[' '] = function()
  45.         if buffer:get_lexer() == "container"  then
  46.                 local buffer = buffer
  47.                 if buffer.column[buffer.current_pos] < buffer.edge_column then
  48.                         return false
  49.                 end
  50.                 buffer:begin_undo_action()
  51.                 while buffer.column[buffer.current_pos] > buffer.edge_column do
  52.                         buffer:word_left()
  53.                 end
  54.                 buffer:new_line()
  55.                 buffer:line_end()
  56.                 buffer:add_text(" ")
  57.                 buffer:end_undo_action()
  58.         else return false
  59.         end
  60. end ]]
  61.  
  62. --redirect error messages to message buffer
  63. events.connect(events.ERROR, function(text)
  64.         gui.print("Error: " .. tostring(text) .. '\n')
  65.         return false
  66. end, 1)
  67.  
  68.  
  69. --make Alt+Left/Right reduce/increase indentation
  70. keys['aleft'] = buffer.back_tab
  71. keys['aright'] = buffer.tab
  72.  
  73.  
  74. --prevent accidentally closing buffer when saving
  75. local save = keys['cs']
  76. local close = keys['cw']
  77. local last_save_time = 0
  78.  
  79. keys['cs'] = function(...)
  80.         last_save_time = os.time()
  81.         return save(...)
  82. end
  83.  
  84. keys['cw'] = function(...)
  85.         if os.time() - last_save_time >= 1 then close() end
  86. end
  87.  
  88.  
  89. --custom key bindings
  90. keys['f3'] = ui.find.find_next
  91. keys['sf3'] = ui.find.find_prev
  92. keys['cg'] = textadept.editing.goto_line
  93. keys['f9'] = textadept.bookmarks.toggle
  94. keys['sf9'] = {textadept.bookmarks.goto_mark}
  95. keys[not CURSES and 'c]' or 'f3'] = {textadept.bookmarks.goto_mark, false}
  96. keys[not CURSES and 'c[' or 'f2'] = {textadept.bookmarks.goto_mark, true}
  97. keys['c-'] = {view.split, view}
  98. keys['c\\'] = {view.split, view, true}
  99. keys['c\b'] = {view.unsplit, view}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top