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 / 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 = '/'
@rgieseke
rgieseke / snapopen.lua
Created January 2, 2011 13:56
Modified snapopen to use shortened filenames, requires common.display_filename.
-- Copyright 2007-2011 Mitchell mitchell<att>caladbolg.net. See LICENSE.
-- Modified to use shortened filenames
local L = _G.locale.localize
---
-- Snapopen for the textadept module.
module('_m.textadept.snapopen', package.seeall)
if WIN32 then
@rgieseke
rgieseke / testlatex.lua
Created June 18, 2011 11:12
Latex lexer with only l.* token names
-- Copyright 2006-2011 Mitchell mitchell<att>caladbolg.net. See LICENSE.
-- Modified by Robert Gieseke.
-- LaTeX LPeg lexer.
local l = lexer
local token, style, color, word_match = l.token, l.style, l.color, l.word_match
local P, R, S = l.lpeg.P, l.lpeg.R, l.lpeg.S
local table = _G.table
module(...)