Skip to content

Commit ced5cb3

Browse files
committed
Extract ftplugins
1 parent d23ab2f commit ced5cb3

File tree

8 files changed

+22
-50
lines changed

8 files changed

+22
-50
lines changed

after/ftplugin/coffee/rails.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
source <sfile>:h:h/javascript/rails.vim

after/ftplugin/css/rails.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
if expand('%:p') =~# '[\/]assets[\/]'
2+
call rails#sprockets_setup('css')
3+
endif
4+
if expand('%:p') =~# '[\/]javascript[\/]packs[\/]'
5+
call rails#webpacker_setup('css')
6+
endif
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
if expand('%:p') =~# '[\/]assets[\/]'
2+
call rails#sprockets_setup('js')
3+
endif
4+
if expand('%:p') =~# '[\/]javascript[\/]packs[\/]'
5+
call rails#webpacker_setup('js')
6+
endif

after/ftplugin/less/rails.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
source <sfile>:h:h/css/rails.vim

after/ftplugin/ruby/rails.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
if !exists('*RailsDetect') || !RailsDetect()
2+
finish
3+
endif
4+
5+
call rails#ruby_setup()

after/ftplugin/sass/rails.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
source <sfile>:h:h/scss/rails.vim

after/ftplugin/scss/rails.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
source <sfile>:h:h/css/rails.vim

autoload/rails.vim

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,18 +2350,6 @@ function! s:findasset(path, dir) abort
23502350
return path . post
23512351
endfunction
23522352

2353-
function! rails#is_embedded_ruby() abort
2354-
let groups = [
2355-
\ 'erubyBlock', 'erubyExpression', 'erubyComment', 'erubyOneLiner',
2356-
\ 'hamlRuby']
2357-
call map(groups, 'hlID(v:val)')
2358-
for id in synstack(line('.'), col('.'))
2359-
if index(groups, id) >= 0 || synIDattr(id, 'name') =~# '^ruby'
2360-
return 1
2361-
endif
2362-
endfor
2363-
endfunction
2364-
23652353
function! s:cfile_delegate(expr) abort
23662354
let expr = empty(a:expr) ? matchstr(&includeexpr, '.*\<v:fname\>.*') : a:expr
23672355
if empty(expr)
@@ -4846,9 +4834,6 @@ function! rails#sprockets_setup(type) abort
48464834
\ '^\s*[[:punct:]]\+=\s*\%(link\|require\|depend_on\|stub\)\w*'
48474835

48484836
let &l:suffixesadd = join(s:suffixes(a:type), ',')
4849-
if &filetype =~# '\<eruby\>'
4850-
setlocal suffixesadd+=.rb
4851-
endif
48524837

48534838
let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') . '|setlocal pa= sua= inc='
48544839

@@ -4858,9 +4843,6 @@ function! rails#sprockets_setup(type) abort
48584843
let map = string(maparg('<Plug><cfile>', 'c'))
48594844
endif
48604845
let map = 'rails#sprockets_cfile(' . map . ')'
4861-
if &filetype =~# 'eruby'
4862-
let map = 'rails#is_embedded_ruby() ? rails#ruby_cfile() : ' . map
4863-
endif
48644846
exe 'cmap <buffer><script><expr> <Plug><cfile>' map
48654847
let b:undo_ftplugin .= "|exe 'sil! cunmap <buffer> <Plug><cfile>'"
48664848
endfunction
@@ -4875,34 +4857,6 @@ function! rails#webpacker_setup(type) abort
48754857
let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') . '|setlocal pa= sua='
48764858
endfunction
48774859

4878-
function! s:set_path_options() abort
4879-
let self = rails#buffer()
4880-
let name = self.name()
4881-
4882-
let assetdir = matchstr(name, '^\%(public/\|\w\+/assets/\)\zs[^/]\+')
4883-
if !empty(assetdir)
4884-
call rails#sprockets_setup(assetdir)
4885-
elseif name =~# '^app/javascript\>'
4886-
let suf = rails#pack_suffixes('css')
4887-
if len(suf) && name =~# '\%(' . escape(join(suf, '\|'), '.') . '\)$'
4888-
call rails#webpacker_setup('css')
4889-
else
4890-
call rails#webpacker_setup('js')
4891-
endif
4892-
else
4893-
if empty(&l:suffixesadd) && &filetype =~# '\<\%(ruby\|eruby\|haml\|markdown\)\>'
4894-
setlocal suffixesadd=.rb
4895-
endif
4896-
if &l:suffixesadd =~# '\.rb\>'
4897-
cmap <buffer><script><expr> <Plug><cfile> rails#ruby_cfile()
4898-
endif
4899-
endif
4900-
4901-
if &l:suffixesadd =~# '\.rb\>'
4902-
call rails#ruby_setup()
4903-
endif
4904-
endfunction
4905-
49064860
function! rails#ruby_setup() abort
49074861
if !s:active()
49084862
return
@@ -4930,8 +4884,7 @@ function! rails#ruby_setup() abort
49304884

49314885
let engine_paths = s:gem_subdirs('app')
49324886
call rails#update_path(path, engine_paths)
4933-
4934-
let b:undo_ftplugin = get(b:, 'undo_ftplugin', 'exe') . '|setlocal pa= sua= inc='
4887+
cmap <buffer><script><expr> <Plug><cfile> rails#ruby_cfile()
49354888
endfunction
49364889

49374890
function! rails#buffer_setup() abort
@@ -4942,8 +4895,6 @@ function! rails#buffer_setup() abort
49424895
let ft = self.getvar('&filetype')
49434896
let b:rails_cached_file_type = self.calculate_file_type()
49444897

4945-
call s:set_path_options()
4946-
49474898
let rp = s:gsub(self.app().path(),'[ ,]','\\&')
49484899
if stridx(&tags,rp.'/tags') == -1
49494900
let &l:tags = rp . '/tags,' . rp . '/tmp/tags,' . &tags

0 commit comments

Comments
 (0)