summaryrefslogtreecommitdiffstats
path: root/ftplugin/svelte.vim
blob: a7037418ada1cc033bf85fbc917e5ee12564761d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
let s:base = expand("<sfile>:h:h")
let Filter = { _, v -> stridx(v, s:base) == -1 && stridx(v, $VIMRUNTIME) == -1 && v !~ "after" }
let files = filter(globpath(&rtp, 'ftplugin/svelte.vim', 1, 1), Filter)
if len(files) > 0
  exec 'source ' . files[0]
  finish
endif
if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'svelte') == -1

" Vim filetype plugin
" Language:   Svelte 3 (HTML/JavaScript)
" Author:     Evan Lecklider <evan@lecklider.com>
" Maintainer: Evan Lecklide <evan@lecklider.com>
" URL:        https://github.com/evanleck/vim-svelte
if (exists('b:did_ftplugin'))
  finish
endif
let b:did_ftplugin = 1

" Matchit support
if exists('loaded_matchit') && !exists('b:match_words')
  let b:match_ignorecase = 0

  " In order:
  "
  " 1. Svelte control flow keywords.
  " 2. Parens.
  " 3-5. HTML tags pulled from Vim itself.
  "
  " https://github.com/vim/vim/blob/5259275347667a90fb88d8ea74331f88ad68edfc/runtime/ftplugin/html.vim#L29-L35
  let b:match_words =
        \ '#\%(if\|await\|each\)\>:\:\%(else\|catch\|then\)\>:\/\%(if\|await\|each\)\>,' .
        \ '{:},' .
        \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' .
        \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' .
        \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'
endif

" ALE fixing and linting.
if exists('g:loaded_ale')
  if !exists('b:ale_fixers')
    let b:ale_fixers = ['eslint', 'prettier', 'prettier_standard']
  endif

  if !exists('b:ale_linter_aliases')
    let b:ale_linter_aliases = ['css', 'javascript']
  endif

  if !exists('b:ale_linters')
    let b:ale_linters = ['stylelint', 'eslint']
  endif
endif

endif