-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4743222
commit 800a118
Showing
4 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
local bait = require 'bait' | ||
local hilbish = require 'hilbish' | ||
hilbish.abbr = { | ||
_abbrevs = {} | ||
} | ||
|
||
function hilbish.abbr.add(opts) | ||
hilbish.abbr._abbrevs[opts.abbr] = opts | ||
end | ||
|
||
print 'abbr loaded' | ||
hilbish.abbr.add { | ||
abbr = 'tt', | ||
expand = 'echo titties' | ||
} | ||
|
||
hilbish.abbr.add { | ||
abbr = 'idk', | ||
expand = 'i dont know', | ||
anywhere = true | ||
} | ||
|
||
bait.catch('hilbish.rawInput', function(c) | ||
if c == ' ' then -- space | ||
-- check if the last "word" was a valid abbreviation | ||
local line = hilbish.editor.getLine() | ||
local lineSplits = string.split(line, ' ') | ||
local thisAbbr = hilbish.abbr._abbrevs[lineSplits[#lineSplits]] | ||
|
||
if thisAbbr and (#lineSplits == 1 or thisAbbr.anywhere == true) then | ||
hilbish.editor.deleteByAmount(-lineSplits[#lineSplits]:len()) | ||
hilbish.editor.insert(thisAbbr.expand) | ||
end | ||
end | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters