diff options
author | Teddy Wing | 2018-03-05 20:39:16 +0100 |
---|---|---|
committer | Teddy Wing | 2018-03-05 20:39:16 +0100 |
commit | 1826d17d9b0e9aec18d1b50ac0874defb46901b3 (patch) | |
tree | b3d2866164be1c8421a16d09aa1b892465f5f38c /plugin | |
parent | d413b825dc5c7e6b4324e29660661e414e82e688 (diff) | |
download | vim-rails-locale-alternate-1826d17d9b0e9aec18d1b50ac0874defb46901b3.tar.bz2 |
Move `ftplugin` to `plugin`
Make this a regular plugin instead of a filetype plugin. Rails locale
files are YAML files, but we don't want these commands to be available
for all YAML files, only those that match the path for Rails locales.
We won't be able to do the path match and filetype separation with an
ftplugin, so instead we'll set up the commands to be defined by
`autocmd`s that match the Rails locale path.
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/rails_locale_alternate.vim | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/plugin/rails_locale_alternate.vim b/plugin/rails_locale_alternate.vim new file mode 100644 index 0000000..0fa0d23 --- /dev/null +++ b/plugin/rails_locale_alternate.vim @@ -0,0 +1,16 @@ +function! s:AlternateLocale(key) + let filename = expand('%') + let alternate = substitute(filename, '\a\{2}\.yml', a:key . '.yml', '') + return alternate +endfunction + + +function! s:SplitAlternate(key, modifiers) + execute a:modifiers . ' split ' . s:AlternateLocale(a:key) +endfunction + + +command! -buffer -nargs=1 RailsLocaleAlternate :call s:SplitAlternate(<q-args>, <q-mods>) +command! -buffer -nargs=1 ERailsLocaleAlternate :execute 'edit ' . s:AlternateLocale(<q-args>) +command! -buffer -nargs=1 SRailsLocaleAlternate :call s:SplitAlternate(<q-args>, '') +command! -buffer -nargs=1 VRailsLocaleAlternate :call s:SplitAlternate(<q-args>, 'vertical') |