aboutsummaryrefslogtreecommitdiffstats
path: root/autoload
AgeCommit message (Collapse)Author
2015-11-23Fix normal mode `G` mappingTeddy Wing
Pressing `G` would bring the cursor to the first line in the buffer instead of the last line in the buffer because the count in the mapping was always `v:count1`. This meant that the `G` mapping behaved like `1G` when no count was specified. This change fixes the `G` mapping to use `v:count` so that it goes to the last line in the buffer as expected. We also add support for arbitrary mappings to choose whether they want to be `v:count` or `v:count1` depending on what value is specified in the mapping dict.
2015-08-16autoload/auditory.vim: Change `s:mappings` to `g:auditory_mappings`Teddy Wing
Make the mappings dictionary global to allow it to be user-customisable. This way users can add new commands or sounds to be mapped without modifying the plugin directly. Seems like it could be useful.
2015-08-16autoload/auditory.vim: Remove old functionsTeddy Wing
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.
2015-08-16Don't turn on Galaxy Far Far away when not `g:auditory_on`Teddy Wing
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.
2015-08-16Create a setting for Galaxy Far Far Away soundsTeddy Wing
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.
2015-08-16autoload/auditory.vim: Fix `AuditoryToggle` + `Auditory[On|Off]`Teddy Wing
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.
2015-08-16Add function and command to toggle mappingsTeddy Wing
* 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.
2015-08-16Unmap insert mode sounds from `auditory#Unmap()`Teddy Wing
* 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
2015-08-16autoload/auditory.vim: Allow unmapping of non-normal mode commandsTeddy Wing
Add support for unmapping a map from any mode where it was defined, not just normal mode mappings from `auditory#Unmap()`.
2015-08-16autoload/auditory.vim: Move `d` mappings to `s:mappings`Teddy Wing
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.
2015-08-02autoload/auditory.vim: Correctly map to user mappingsTeddy Wing
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.
2015-08-02autoload/auditory.vim: Extract `map_to` to auditory#AssignMappingsTeddy Wing
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.
2015-07-28autoload/auditory.vim: Restore user mappings when turning offTeddy Wing
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.
2015-07-26autoload/auditory.vim: Initial Unmap functionTeddy Wing
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.
2015-07-19auditory#StoreUserMapping: Operate on a single mappingTeddy Wing
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.
2015-07-19autoload/auditory.vim: Add function to store user mappingsTeddy Wing
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.
2015-07-19auditory.vim: `AssignNormalModeMappings` -> `AssignMappings`Teddy Wing
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.
2015-07-19autoload/auditory.vim: Unsilence search commandsTeddy Wing
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.
2015-07-19autoload/auditory.vim: Reenable visual mode 'x' mappingTeddy Wing
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.
2015-07-18autoload/auditory.vim: Ensure we `<cr>` if we're not pipingTeddy Wing
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>.
2015-07-18autoload/autoload.vim: Use `nnoremap` instead of `nmap`Teddy Wing
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.
2015-07-18autoload/auditory.vim: Always map with <silent>Teddy Wing
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.
2015-07-18autoload/auditory.vim: Only map with `<silent>` if using `execute`Teddy Wing
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.
2015-07-18autoload/auditory.vim: Delete auditory#NormalModeMappings()Teddy Wing
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.
2015-07-18auditory.vim: Assign mappings with AssignNormalModeMappings()Teddy Wing
Assign our normal mode mappings with our new function that uses the mapping dictionary.
2015-07-18auditory#AssignNormalModeMappings: Use ternary for pipe variableTeddy Wing
Assign the pipe variable with a ternary operator to make the function more concise.
2015-07-18autoload/auditory.vim: Change format of mapping dictionaryTeddy Wing
Convert it from a dictionary literal to successive appends to the mapping dictionary to allow me to keep the various comments and FIXMEs.
2015-07-18autoload/auditory.vim: Make dictionary of mappingsTeddy Wing
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 \})
2014-11-15autoload/auditory.vim: Fix `d` not saving to register bugTeddy Wing
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.
2014-11-15autoload/auditory.vim: Update Cantina pathNew-SoundsTeddy Wing
Cantina sound files are now in the Resources/Songs/ directory.
2014-11-15autoload/auditory.vim: Update insert mode file listingTeddy Wing
Use the new C# scale files in insert mode for a wider range of notes.
2014-11-10autoload/auditory.vim: Add `dd` supportTeddy Wing
Add support for deleting a line using `dd`. Previously this didn't work because I created a custom operator for the `d` command.
2014-11-09autoload/auditory.vim: Add custom `d` operatorTeddy Wing
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.
2014-11-09autoload/auditory.vim: Add new Cantina audio filesTeddy Wing
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.
2014-11-09autoload/auditory.vim: Enable <space> & <backspace> mappings with FIXMETeddy Wing
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.
2014-11-09autoload/auditory.vim: Enable scrolling mappings with FIXMEsTeddy Wing
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.
2014-11-09autoload/auditory.vim: Add undo & redo mappingsTeddy Wing
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.
2014-11-09autoload/auditory.vim: Move sound file arrays outside functionsTeddy Wing
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.
2014-11-09autoload/auditory.vim: Add HML jump mappingsTeddy Wing
2014-11-09autoload/auditory.vim: Fix '0' mappingTeddy Wing
'0' wasn't doing what 0 is normally supposed to do. Modify the mapping to make it work.
2014-11-09Move functions to autoloadTeddy Wing
Clean up functions, move everything into autoload/, move code around a little bit.