Skip to content

Instantly share code, notes, and snippets.

View OdatNurd's full-sized avatar

Terence Martin OdatNurd

View GitHub Profile
@OdatNurd
OdatNurd / font_size_limit.py
Created January 10, 2018 22:01
Sublime Text font size limiting on "zoom"
import sublime
import sublime_plugin
# This is a modified version of the Default/font.py file that ships with
# sublime, which includes versions of the increase and decrease font size
# commands that limit the size the font can be at each extreme.
# This includes an event listener that catches any attempt to use the
# "standard" font commands and rewrites the command to use these ones instead.
@OdatNurd
OdatNurd / exec.py
Created March 2, 2018 06:43
The exec.py plugin from Sublime Text 2.0.2 modified to use incremental decoding
import sublime, sublime_plugin
import os, sys, codecs
import thread
import subprocess
import functools
import time
# This is the exec.py file taken from the Default package in Sublime Text 2.0.2
# which has been modified to use incremental decoding of build system output
# the way it's done in Sublime Text 3.
@OdatNurd
OdatNurd / folding_listener.py
Last active March 7, 2018 23:23
Fold all newly loaded files and all files loaded from the session file at Sublime startup
import sublime
import sublime_plugin
def fold(view):
view.run_command("fold_by_level", {"level": 2})
def plugin_loaded():
for window in sublime.windows():
for view in window.views():
fold(view)
@OdatNurd
OdatNurd / Default.sublime-commands
Created June 20, 2018 22:14
Sample Sublime Plugin to implement a buffer panel
[
{
"caption": "BufferList: Show Buffers",
"command": "show_buffers",
"args": {
"give_focus": true
}
}
]
@OdatNurd
OdatNurd / Default.sublime-keymap
Created June 18, 2018 23:22
Sample Sublime Plugin for a buzzword lorem ipsum that can generate multiple paragraphs at once
[
// Use our own buzzword lorem ipsum generator. It generates buzzword lorem
// using a rolling stock of 5 paragraphs and lets you generate multiple
// items at once.
{
"keys": ["tab"],
"command": "buzzword_ipsum",
"context": [
{ "key": "selection_empty", "operator": "equal", "operand": "true", "match_all": true },
{ "key": "preceding_text", "operator": "regex_match", "operand": "^.*lorem\\d*$", "match_all": true },
@OdatNurd
OdatNurd / output.txt
Last active February 14, 2019 19:56
Use AST to parse Sublime API files
sublime
-------
sublime.version()
sublime.platform()
sublime.arch()
sublime.channel()
sublime.executable_path()
sublime.executable_hash()
sublime.packages_path()
sublime.installed_packages_path()
@OdatNurd
OdatNurd / Python.sublime-build
Last active May 7, 2019 12:57
A version of the exec command from Sublime Text 3 modified to buffer output to the panel by lines
{
"target": "buffered_exec",
"cancel": {"kill": true},
"shell_cmd": "python -u \"$file\"",
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
"env": {"PYTHONIOENCODING": "utf-8"},
@OdatNurd
OdatNurd / Default.sublime-keymap
Created May 2, 2020 04:42
Sublime Text Buzzword Lorem Ipsum
[
// Use our own buzzword lorem ipsum generator. It generates buzzword lorem
// using a rolling stock of 5 paragraphs and lets you generate multiple
// items at once.
{
"keys": ["tab"],
"command": "buzzword_ipsum",
"context": [
{ "key": "selection_empty", "operator": "equal", "operand": "true", "match_all": true },
{ "key": "preceding_text", "operator": "regex_match", "operand": "^.*lorem\\d*$", "match_all": true },
@OdatNurd
OdatNurd / collect_versions.py
Created March 13, 2020 19:28
Collect minimum build version information for Sublime Text API endpoints
#!/usr/bin/env python3
import os
import ast
import glob
import zipfile
# Classes that are part of the API in general; the source files contain some
# helper classes that are just noise
_classes = [
# From the sublime module
@OdatNurd
OdatNurd / Sample Build.sublime-build
Last active September 9, 2020 18:28
Sample plugin for allowing you to select what Makefile to use for a build
{
"target": "makefile_build",
"cancel": {"kill": true},
"shell_cmd": "make -f \\${selected_makefile}",
"file_regex": "^(..[^:\n]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "\\${selected_makefile_path}",
"selector": "source.makefile",
"syntax": "Packages/Makefile/Make Output.sublime-syntax",