From 1826d17d9b0e9aec18d1b50ac0874defb46901b3 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 5 Mar 2018 20:39:16 +0100 Subject: 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. --- ftplugin/ruby_rails_locale_alternate.vim | 16 ---------------- plugin/rails_locale_alternate.vim | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 ftplugin/ruby_rails_locale_alternate.vim create mode 100644 plugin/rails_locale_alternate.vim diff --git a/ftplugin/ruby_rails_locale_alternate.vim b/ftplugin/ruby_rails_locale_alternate.vim deleted file mode 100644 index 0fa0d23..0000000 --- a/ftplugin/ruby_rails_locale_alternate.vim +++ /dev/null @@ -1,16 +0,0 @@ -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(, ) -command! -buffer -nargs=1 ERailsLocaleAlternate :execute 'edit ' . s:AlternateLocale() -command! -buffer -nargs=1 SRailsLocaleAlternate :call s:SplitAlternate(, '') -command! -buffer -nargs=1 VRailsLocaleAlternate :call s:SplitAlternate(, 'vertical') 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(, ) +command! -buffer -nargs=1 ERailsLocaleAlternate :execute 'edit ' . s:AlternateLocale() +command! -buffer -nargs=1 SRailsLocaleAlternate :call s:SplitAlternate(, '') +command! -buffer -nargs=1 VRailsLocaleAlternate :call s:SplitAlternate(, 'vertical') -- cgit v1.2.3