| Age | Commit message (Collapse) | Author |
|
|
|
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
\})
|
|
Found the `maparg()` function over the weekend which I can now use to
toggle Auditory mappings and sounds on and off.
|
|
I see this in the sources of all the plugins I look at. Figure I should
be a good Vim plugin citizen and do this too. This should also provide a
convenient way to turn off the plugin when starting Vim.
|
|
Forgot to add a date completed entry to the mplayer task.
|
|
|
|
Check off adding an error message when mplayer is missing.
|
|
Instead of echoing and error, just echo a message about mplayer not
being installed. Errors look pretty annoying on initial load, and I
don't think this is worth the red background colour. It could be that a
user has two machines, one with mplayer installed and one without. In
that case, I don't want people to have to disable the plugin on one
machine. That seems like too much to ask.
I think this is a nice middle-ground between alerting users that
something is needed by the plugin and not barfing if it's not there.
|
|
On plugin load, if mplayer isn't installed then fail ungracefully. Since
we depend on mplayer in order to play any sounds, my thinking now is
that I want to fail immediately.
Still trying to decide if this is be best course of action. Maybe I just
want an informative message instead of a complete failure.
|
|
Check off adding pathogen installation instructions.
|
|
Provide basic instructions. I'm only familiar with pathogen, so that's
what the example uses. You're free to use Vundle, NeoBundle, etc. if you
prefer.
|
|
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.
|
|
Check off new sound file updating.
|
|
|
|
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 a few new TODOs from earlier this week.
|
|
Move Cantina to songs
|
|
Delete old notes
|
|
Mark `dd` task complete.
|
|
Add a note to map 'D' for deleting to the end of a line.
|
|
Add support for deleting a line using `dd`. Previously this didn't work
because I created a custom operator for the `d` command.
|
|
Add some issues and ideas I thought about post-hackathon.
|
|
Let people know that this plugin requires mplayer. Note that we don't
currently check for it in the plugin, but we should.
|
|
|
|
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.
|
|
|
|
Each audio file is an 8th note.
|
|
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.
|
|
|