blob: e650be93129bde2989b9a84e75b91d9bfad57f5e [file] [log] [blame]
Bram Moolenaarc236c162008-07-13 17:41:49 +00001" Vim filetype plugin
Bram Moolenaar0ed0eea2010-07-26 22:21:27 +02002" Language: Sass
3" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
Tim Popea907c912023-12-28 12:49:07 -05004" Last Change: 2023 Dec 28
Bram Moolenaarc236c162008-07-13 17:41:49 +00005
6" Only do this when not done yet for this buffer
7if exists("b:did_ftplugin")
8 finish
9endif
10let b:did_ftplugin = 1
11
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020012let b:undo_ftplugin = "setl com< cms< def< inc< inex< ofu< sua<"
Bram Moolenaarc236c162008-07-13 17:41:49 +000013
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020014setlocal comments=://
Bram Moolenaarc236c162008-07-13 17:41:49 +000015setlocal commentstring=//\ %s
Bram Moolenaarc08ee742019-12-05 22:47:25 +010016setlocal includeexpr=SassIncludeExpr(v:fname)
Bram Moolenaarc236c162008-07-13 17:41:49 +000017setlocal omnifunc=csscomplete#CompleteCSS
Bram Moolenaar0ed0eea2010-07-26 22:21:27 +020018setlocal suffixesadd=.sass,.scss,.css
Bram Moolenaarc08ee742019-12-05 22:47:25 +010019if &filetype =~# '\<s[ac]ss]\>'
20 setlocal iskeyword+=-
21 setlocal iskeyword+=$
22 setlocal iskeyword+=%
23 let b:undo_ftplugin .= ' isk<'
24endif
Bram Moolenaarc236c162008-07-13 17:41:49 +000025
Tim Popea907c912023-12-28 12:49:07 -050026if get(g:, 'sass_recommended_style', 1)
27 setlocal shiftwidth=2 softtabstop=2 expandtab
28 let b:undo_ftplugin .= ' sw< sts< et<'
29endif
30
Bram Moolenaarc08ee742019-12-05 22:47:25 +010031let &l:define = '^\C\v\s*%(\@function|\@mixin|\=)|^\s*%(\$[[:alnum:]-]+:|[%.][:alnum:]-]+\s*%(\{|$))@='
Bram Moolenaar0ed0eea2010-07-26 22:21:27 +020032let &l:include = '^\s*@import\s\+\%(url(\)\=["'']\='
Bram Moolenaarc236c162008-07-13 17:41:49 +000033
Bram Moolenaarc08ee742019-12-05 22:47:25 +010034function! SassIncludeExpr(file) abort
35 let partial = substitute(a:file, '\%(.*/\|^\)\zs', '_', '')
36 if !empty(findfile(partial))
37 return partial
38 endif
39 return a:file
40endfunction
41
Bram Moolenaarc236c162008-07-13 17:41:49 +000042" vim:set sw=2: