Skip to content

Instantly share code, notes, and snippets.

@rgieseke
rgieseke / ta-rectselect.lua
Created June 1, 2010 19:44
Rectangular selection for Textadept
-- Rectangular selection
-- Add the following to your init.lua
keys.ar = { function()
local events = events
local gui = gui
local KEYSYMS = _m.textadept.keys.KEYSYMS
gui.statusbar_text = 'Rectangular selection'
events.emit('update_ui')
rselect = events.connect('keypress',
-- Experimental command line arguments processing
args = {}
local helptext = [[
Textadept - Version ...
Usage:
textadept [arguments] [file ..] - edit text files
-- Experimental search for Textadept using the status bar
-- ctrl-f, ctrl-g: next, ctrl-shift-g: previous
-- backspace: delete all, delete: delete one char
keys.cf = {function()
local KEYSYMS = _m.textadept.keys.KEYSYMS
local string_char = string.char
local search_term = ''
gui.statusbar_text = 'Search: '
events.emit('update_ui')
events.connect('keypress', function(code, shift, control, alt)
module('_m.common.filename', package.seeall)
function insert_filename()
local current_dir = (buffer.filename or ''):match('.+[/\\]')
if not current_dir then
current_dir = _HOME
end
filename =
gui.dialog('fileselect',
'--title', "Insert filename",
module('_m.common.open', package.seeall)
local filtered_folders = {'^%.?$', '%.hg$', '%.git'}
function open(path)
local lfs = require 'lfs'
local items, files = {}, {}
for item in lfs.dir(path) do
if lfs.attributes(path..'/'..item).mode == 'directory' then
if not _m.textadept.snapopen.exclude(item, filtered_folders) then
module('_m.common.vc', package.seeall)
function hg_status()
local path = buffer.filename:match('(.+)/')
local command = 'cd '..path..'; hg root 2>&1'
local f = io.popen(command)
local ans = f:read("*a")
f:close()
if ans:match(".hg not found") then
_m.textadept.snapopen.open({path})
@rgieseke
rgieseke / init.lua
Created November 11, 2010 11:20
Modification of Textadept's menu.lua
require 'textadept'
-- requires latest menu.lua from hg:
-- http://code.google.com/p/textadept/source/browse/modules/textadept/menu.lua
-- toggle menubar
local menubar_visible = true
keys['af10'] = {
function ()
if menubar_visible then
@rgieseke
rgieseke / python_syntax_check.lua
Created November 30, 2010 19:45
Textadept: Check Python syntax after saving.
events.connect('file_after_save',
function() -- show Python syntax errors as annotations
if buffer:get_lexer() == 'python' then
local lfs = require 'lfs'
local buffer = buffer
buffer:annotation_clear_all()
local filepath = buffer.filename:iconv(_CHARSET, 'UTF-8')
local filedir, filename = '', filepath
if filepath:find('[/\\]') then
filedir, filename = filepath:match('^(.+[/\\])([^/\\]+)$')
@rgieseke
rgieseke / zoom.lua
Created December 12, 2010 19:45
Keyboard short cuts for zooming in Textadept
keys['c+'] = {function()
local buffer = buffer
buffer.zoom = buffer.zoom + 1
local c = _SCINTILLA.constants
buffer.margin_width_n[0] = 4 * buffer:text_width(c.STYLE_LINENUMBER, "9")
end
}
keys['c-'] = {function()
local buffer = buffer
@rgieseke
rgieseke / ack.lua
Created December 19, 2010 10:01
Textadept: Ack plugin
module('_m.common.ack', package.seeall)
-- load with
-- require 'common.ack'
-- in init.lua
options = '--nocolor --nogroup '
local L = _G.locale.localize
local sep = '/'