| Age | Commit message (Collapse) | Author |
|
Delete some old code that isn't used any more. This was when I first
made the plugin. These functions were used to start a song when insert
mode was activated and stop the song on insert leave.
Since we're not playing full songs any more, and our insert sounds are
tied to key presses, these functions are no longer needed.
|
|
My change from 71ec214cdb8814ecb71c837bf947583fda54d37e caused Galaxy
Far Far Away sounds to be turned on any time you had
`g:auditory_galaxy_far_far_away` turned on, regardless of whether
`g:auditory_on` was also turned on.
Fix this because we never want sounds to play when `g:auditory_on` is
off.
We now rely on `auditory#AssignInsertMappings()` to know whether to use
Galaxy Far Far Away or default insert mode sounds.
Need to toggle `g:auditory_galaxy_far_far_away` in that function because
we're calling the toggle function so we need to set it to the opposite
of what we want.
In the future if we add more insert mode sounds we'll have to change
this structure around but it should work for now.
|
|
Adding a configuration variable for these sounds allows them to be
turned on by default without having to
`:AuditoryToggleGalaxyFarFarAway`, so if you prefer these sounds you can
enable them at the outset.
|
|
When using `:AuditoryToggle` in conjunction with `:AuditoryOn` or
`:AuditoryOff`, things would get messed up. This is because
`:AuditoryToggle` relies on `g:auditory_on` in order to know whether to
turn sounds on or off, but the variable was only getting set in
`auditory#ToggleMappings`, not in the functions that `:AuditoryOn` or
`:AuditoryOff` call.
Move the setting of the variable into `auditory#AssignMappings` and
`auditory#Unmap` so that the right thing will happen regardless of which
on/off/toggle commands you run.
|
|
* Create `auditory#ToggleMappings()` that turns sounds on if they're off
and off if they're on
* Create an `:AuditoryToggle` command that runs the toggle function in a
more user-friendly callable way
With a toggle command, turning Auditory on or off can be as simple as
hitting 1 custom mapping. With our previous `AuditoryOn` and
`AuditoryOff`, you would have to use 2 mappings: 1 for on and another
for off.
|
|
* Move the insert mode autocommand definition into a new function that
turns on insert mode sounds
* Create a function to turn off insert mode sounds
* Call these from our normal `AssignMappings` and `Unmap` functions so
we can turn all our sounds on and off in one fell swoop
|
|
Add support for unmapping a map from any mode where it was defined, not
just normal mode mappings from `auditory#Unmap()`.
|
|
Put our `d`, `v_d`, and `dd` mappings in the `s:mappings` dictionary so
that they get automatically activated and deactivated when our map and
unmap functions go through the dict.
This required some modifications to `auditory#AssignMappings()` to allow
it to accept `map_to` commands that don't have a preceding
`auditory#Play()` call (because in the case of our `d` mappings, the
audio is played inside the function they call.
Also ensure we're not adding a pipe to the command if there's no
preceding audio part.
|
|
If a user has defined:
nnoremap j gj
then when you press `j` with Auditory turned on, it should make the
sound and do `gj`.
Previously it did `j` instead. Now it does `gj`. No more blatant
disregard for user mappings.
|
|
Take out the `map_to` field for Auditory's mappings and instead do what
it needs to do in `AssignMappings`. Makes the code a bit more DRY.
We replace it where necessary with a `count` field that tells whether we
should `v:count1` the mapping.
|
|
In `auditory#Unmap()`, after unmapping Auditory maps, remap user-defined
mappings.
Say you redefined `j` -> `gj`. When turning Auditory off, we would
previously just unmap `j`, resulting in `j` -> `j`. Now that we're
restoring user mapppings, `j` once again gets mapped to `gj`.
Also keep track of the mode that Auditory uses for its mappings when
storing a user-defined mapping so that we're only saving and restoring
them if they're defined in the mode used by Auditory.
User mappings get saved in `auditory#AssignMappings()`, or the function
that essentially turns on the plugin.
Fix the `if` condition that checks `if l:user_mapping`. This gave me a
lot of trouble because I needed to match it against emtpy string,
instead of a boolean condition. Use the proper condition to get it
actually working.
|
|
Unmaps all normal mode commands. This will be used to turn Auditory off.
We'll want to also turn custom user mappings back on in the process but
that's for a later commit.
|
|
Refactor to operate on one mapping passed in as an argument instead of
the whole `s:mappings` dictionary. This will allow me to call the
function inside `auditory#AssignMappings` and avoid having 2 `for` loops
when 1 will suffice.
|
|
Get any mappings users have defined for the keys/commands that we use
for playing audio and store them in our `mappings` dictionary. This will
allow us to be friendly and have the keys do what users have defined
them to do instead of using the stock Vim actions for everything.
Storing these mappings will also allow us to easily restore user
mappings when we make a way to turn the plugin's sounds off by unmapping
our custom sound maps.
|
|
Rename the function because we're not only assigning normal mode
mappings here, we're also assigning visual mode mappings. And we might
be assigning mappings for other modes here too in the future, so this
name doesn't make sense.
I had originally called it this to distinguish it from the insert mode
set defined in plugin/auditory.vim with the `CursorMovedI` autocommand,
but I think this should be more clear about what it's doing.
Edit: Also modify the comment above this section for similar reasons.
|
|
The search commands, as I has specified previously in the verbose
mappings from before, should not be silenced, otherwise you can't see
the useful output that they provide in the command line area.
Add a way to make a mapping silent or not using a new field in the
mappings dictionary.
|
|
Needed to come up with a way to add it to the `mappings` dictionary
without overriding the existing normal mode 'x' mapping. Prefixed it
with `v_` for the dictionary key so that it doesn't conflict, but that
could easily be the start of a mapping (for whatever reason), so added a
`map_from` field to make it explicit what we're mapping from in cases
where the dict key is unclear.
Also added another field to the dict to specify a custom mapping
command. It will default to `nnoremap` as that's the one we use for most
of our commands, but you can change it if you need another mode as we do
for this visual 'x' mapping.
|
|
If we're not piping to an `execute` command in the mapping, we need to
`<cr>` to execute the sound player and type the normal mode command.
Otherwise the normal mode command gets typed in command mode which is
not what we want and messes things up greatly.
Figured I would just tack the `<cr>` on to the pipe variable rather than
create a new one since it's the inverse of what we need in that
situation. Hopefully the intention is clear enough but I'll grant that
this doesn't expose the most clarity.
Edit: Added a comment for better explanation of the <cr>.
|
|
I wanted to use `nmap` so that user-defined commands would come through,
but that caused the sounds to play recursively, a problem I now remember
from when I originally wrote this. Change it to `nnoremap` by default to
get around this. We'll look into whether it's possible to get
user-defined mappings attached somehow. Maybe in the save-and-restore
process.
|
|
Turns out my assumption that we didn't need <silent> when `execute`ing
in 83449bf7e30d45f91eccbcdffd56abb126be56c1 was incorrect. When
performing <C-d>, the audio play command appears in the command line,
which is not the behaviour we want.
Let's just revert to always using `<silent>` and figure that should work
for us.
Figured out between the last commit and this one that my manual testing
wasn't with the latest code. I was using
a037e921a4b9b0539c93450fe3df1f6c8175ceab this whole time because I
didn't have my development setup configured correctly. Now I can
actually see what's going on as I make changes (what a concept!).
Also bring back the ternary since we're not setting any more variables
for this condition any more.
|
|
We don't need to use `<silent>` in our mappings if we're going back to a
regular non-command mode command, so listen for commands where we
`execute` in the mapping and don't `<silent>` them.
Reverted the ternary I had added previously to make this workable with
the now 2 variables that need to listen for `execute`.
Also add some line wrapping to the map creation for better readability.
|
|
Now that we're assigning our mappings using the mapping dictionary, we
can remove the old function that applied the mappings manually.
It definitely less clear an readable I'll admit, but this allows us more
flexibility and hopefully customisability. The original plan with the
mapping dictionary was to allow toggling of the mappings on and off, so
hopefully it will help with that.
|
|
Assign our normal mode mappings with our new function that uses the
mapping dictionary.
|
|
Assign the pipe variable with a ternary operator to make the function
more concise.
|
|
Convert it from a dictionary literal to successive appends to the
mapping dictionary to allow me to keep the various comments and FIXMEs.
|
|
Create a dictionary with all our mappings. We'll use this to activate
them programmatically. I think it might also be interesting to provide
this as a configurable variable within the plugin so that users can
change the built-in mappings if they so choose.
Note that this doesn't currently work because you can't have comments in
dictionary literals in Vimscript. Thanks to Raimondi on #vim for
confirming that for me after I played around with this.
Also thanks to bairui/dahu for his suggestion for emulating comments in
dict literals: https://gist.github.com/dahu/18b48c70444d8078f7d7
" Barry Arthur, July 2015
" Kludge emulating comments in dict literals
" :-0 surprised?!
function! StripComments(comment_leader, dict)
return filter(a:dict, 'v:key !~ "^" . escape(a:comment_leader, "\"")')
endfunction
let x = StripComments('REM', {
\ 'a' : 1
\, 'REM This is a nasty workaround mimicking comments in dict literals' :-0
\, 'b' : 2
\, 'REM Duplicate keys are not tolerated within dict literals, hence the numbered comment keys' :-0
\, 'c' : 3
\, 'REM For the younger audience members, REM stands for "remark" and was the comment leader in BASIC' :-0
\, 'd' : 4
\})
|
|
Previously my custom `d` and `dd` operators wouldn't save their
deletions to the unnamed register. For normal custom operators this is
exactly what you want, but not when you're making your own delete
operator.
When you notice this it becomes _extremely_ annoying. Fixing it here so
now deleted text goes into the unnamed register.
|
|
Cantina sound files are now in the Resources/Songs/ directory.
|
|
Use the new C# scale files in insert mode for a wider range of notes.
|
|
Add support for deleting a line using `dd`. Previously this didn't work
because I created a custom operator for the `d` command.
|
|
Create a custom delete operator that plays the delete sound.
NOTES:
* Doesn't do `dd`
* I just looked at the tcomment plugin source and realised that I should
be using plugin mappings so these can be more easily overridden. Make
a note to look into that.
|
|
Add Spencer's new Cantina audio files to the cantina list. The new audio
files are shorter individually (that's why there are more of them). This
makes it easier to play the Cantina song at faster or slower ranges of
tempos.
|
|
Uncomment the space and delete mappings. Note that I had to remove count
support on the delete key because it's another one of those that was
giving me errors for that.
|
|
This way the sounds on scoll commands acutally work. They no longer
support counts :( and the <c-b> command for some reason needs to be
entered twice in order for it to work. Enable these for now just so we
can get the sounds but add FIXMEs so we know that these are borked.
|
|
Again had an issue with adding a count to one of the mappings, in this
case with redo. Leaving the mapping active except not supporting a
count. Hopefully we can figure out how to fix that.
|
|
Make arrays that store audio filenames script-local variables instead of
function-local variables.
Doing this because I have a hunch that it will be good for performance,
so the arrays don't have to be reinitialised on every execution of the
insert mode play functions.
|
|
|
|
'0' wasn't doing what 0 is normally supposed to do. Modify the mapping
to make it work.
|
|
Clean up functions, move everything into autoload/, move code around a
little bit.
|