├── .github └── FUNDING.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── assets └── vim-astro.png ├── autoload └── astro.vim ├── doc ├── astro.txt └── tags ├── ftdetect └── astro.vim ├── ftplugin └── astro.vim ├── indent └── astro.vim └── syntax └── astro.vim /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | custom: https://paypal.me/wuelnerdotexe 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # testing 4 | /test 5 | 6 | # vimfiles 7 | *.swp 8 | *.un~ 9 | *~ 10 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | ## [1.2.0] - 2022-10-06 8 | 9 | ### Added 10 | 11 | - Merge pull request [#3](https://github.com/wuelnerdotexe/vim-astro/pull/3) from `romainl/ftplugin-and-autoload` 12 | - Add `ftplugin/astro.vim` and `autoload/astro.vim` 13 | 14 | ## [1.1.3] - 2022-08-24 15 | 16 | ### Fixed 17 | 18 | - Filetype is detected in all versions of Vim and Neovim. 19 | 20 | ## [1.1.2] - 2022-08-22 21 | 22 | ### Fixed 23 | 24 | - The astro fence delimiter is detected and colored correctly. 25 | 26 | ## [1.1.1] - 2022-08-07 27 | 28 | ### Fixed 29 | 30 | - Regions that were causing conflicts with JavaScript code blocks and expressions are renamed. Now those blocks are replaced by the exclusive code blocks for Astro. 31 | - Regular expressions are fixed to correctly detect Astro directives. 32 | 33 | ## [1.1.0] - 2022-08-06 34 | 35 | ### Added 36 | 37 | - A new variable is added to enable stylus support. 38 | - Demonstration images are added. 39 | 40 | ## [1.0.1] - 2022-08-05 41 | 42 | ### Fixed 43 | 44 | - Removed unused variable for enable indentation. 45 | 46 | ## [1.0.0] - 2022-08-05 47 | 48 | - Initial release 49 | 50 |

With 💖 from LATAM to the world!

51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Wuelner Martínez 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Astro support for Vim or Neovim 2 | 3 | > 🧑‍🚀 Not sure what Astro is? See their website at [astro.build](https://astro.build)! 4 | 5 | Provides syntax highlighting and indentation support for `.astro` files. 6 | 7 |
8 | 9 | Theme: Enfocado Dark Neon. 10 |
11 | 12 | ## Features 13 | 14 | - Syntax highlighting for embedded languages: 15 | - JavaScript and JSX. 16 | - TypeScript and TSX. 17 | - CSS, SCSS, SASS, and LESS. 18 | - Stylus (need external support). 19 | - Indentation (experimental). 20 | - Code folding. 21 | - No dependencies from external syntax plugins. 22 | - Full integration with Vim functions. [Read more](https://github.com/wuelnerdotexe/vim-astro/pull/3). 23 | 24 | ## Installation 25 | 26 | Install via your preferred package manager. Example using [vim-plug](https://github.com/junegunn/vim-plug): 27 | 28 | ```vim 29 | Plug 'wuelnerdotexe/vim-astro' 30 | ``` 31 | 32 | alternatively, install manually. 33 | 34 | ## Configuration 35 | 36 | The following variables control certain syntax highlighting features. You can add them to your `.vimrc` or `init.vim`. 37 | 38 | ```vim 39 | let g:astro_typescript = 'enable' 40 | ``` 41 | 42 | Enables TypeScript and TSX for `.astro` files. 43 | 44 | Default Value: 'disable' 45 | 46 | ```vim 47 | let g:astro_stylus = 'enable' 48 | ``` 49 | 50 | Enables Stylus for `.astro` files. 51 | 52 | Default Value: 'disable' 53 | 54 | NOTE: Vim does not provide Stylus support by default, but you can install [vim-stylus](https://github.com/wavded/vim-stylus) to support it. 55 | 56 | ## Maintainer 57 | 58 | > Hi 👋, I'm **[Wuelner](https://linktr.ee/wuelnerdotexe)**, a **software developer from Guatemala**, passionate about creating minimalist solutions using solid fundamentals focused on **"how things should be"**. 59 | 60 | ## Credits 61 | 62 | - Based on: Plugin [vim-svelte](https://github.com/evanleck/vim-svelte) by. [Evan Lecklider's](https://github.com/evanleck). 63 | 64 | ## License 65 | 66 | [MIT © Wuelner Martínez.](https://github.com/wuelnerdotexe/vim-astro/blob/main/LICENSE) 67 | 68 |

With 💖 from LATAM to the world!

69 | -------------------------------------------------------------------------------- /assets/vim-astro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wuelnerdotexe/vim-astro/9b4674ecfe1dd84b5fb9b4de1653975de6e8e2e1/assets/vim-astro.png -------------------------------------------------------------------------------- /autoload/astro.vim: -------------------------------------------------------------------------------- 1 | function! astro#IdentifyScope(start, end) abort 2 | let pos_start = searchpairpos(a:start, '', a:end, 'bnW') 3 | let pos_end = searchpairpos(a:start, '', a:end, 'nW') 4 | 5 | return pos_start != [0, 0] 6 | \ && pos_end != [0, 0] 7 | \ && pos_start[0] != getpos('.')[1] 8 | endfunction 9 | 10 | function! astro#AstroComments() abort 11 | if astro#IdentifyScope('^---\n\s*\S', '^---\n\n') 12 | \ || astro#IdentifyScope('^\s*') 13 | " ECMAScript comments 14 | setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:// 15 | setlocal commentstring=//%s 16 | 17 | elseif astro#IdentifyScope('^\s*') 18 | " CSS comments 19 | setlocal comments=s1:/*,mb:*,ex:*/ 20 | setlocal commentstring=/*%s*/ 21 | 22 | else 23 | " HTML comments 24 | setlocal comments=s: 25 | setlocal commentstring= 26 | endif 27 | endfunction 28 | 29 | " https://code.visualstudio.com/docs/languages/jsconfig 30 | function! astro#CollectPathsFromConfig() abort 31 | let config_json = findfile('tsconfig.json', '.;') 32 | if empty(config_json) 33 | let config_json = findfile('jsconfig.json', '.;') 34 | if empty(config_json) 35 | return 36 | endif 37 | endif 38 | 39 | let paths_from_config = config_json 40 | \ ->readfile() 41 | \ ->join() 42 | \ ->json_decode() 43 | \ ->get('compilerOptions', {}) 44 | \ ->get('paths', {}) 45 | 46 | if !empty(paths_from_config) 47 | let b:astro_paths = paths_from_config 48 | \ ->map({key, val -> [ 49 | \ key->glob2regpat(), 50 | \ val[0]->substitute('\/\*$', '', '') 51 | \ ]}) 52 | \ ->values() 53 | endif 54 | 55 | let b:undo_ftplugin ..= " | unlet! b:astro_paths" 56 | endfunction 57 | 58 | function! astro#AstroInclude(filename) abort 59 | let decorated_filename = a:filename 60 | \ ->substitute("^", "@", "") 61 | 62 | let found_path = b: 63 | \ ->get("astro_paths", []) 64 | \ ->indexof({ key, val -> decorated_filename =~ val[0]}) 65 | 66 | if found_path != -1 67 | let alias = b:astro_paths[found_path][0] 68 | let path = b:astro_paths[found_path][1] 69 | \ ->substitute('\(\/\)*$', '/', '') 70 | 71 | return decorated_filename 72 | \ ->substitute(alias, path, '') 73 | endif 74 | 75 | return a:filename 76 | endfunction 77 | -------------------------------------------------------------------------------- /doc/astro.txt: -------------------------------------------------------------------------------- 1 | *astro.txt* Astro language indentation and syntax support in Vim or Neovim. 2 | 3 | ============================================================================== 4 | 5 | 1. Configuration *astro-configuration* 6 | 7 | The following variables control certain syntax highlighting features. 8 | You can add them to your `.vimrc` or `init.vim`. 9 | 10 | `let g:astro_typescript = 'enable'` 11 | 12 | Enables TypeScript and TSX for `.astro` files. 13 | 14 | Default Value: 'disable' 15 | 16 | `let g:astro_stylus = 'enable'` 17 | 18 | Enables Stylus for `.astro` files. 19 | 20 | Default Value: 'disable' 21 | 22 | NOTE: You need install a external plugin for support stylus in astro files. 23 | ============================================================================== 24 | vim:textwidth=78:tabstop=8:filetype=help: 25 | -------------------------------------------------------------------------------- /doc/tags: -------------------------------------------------------------------------------- 1 | astro-configuration astro.txt /*astro-configuration* 2 | astro.txt astro.txt /*astro.txt* 3 | -------------------------------------------------------------------------------- /ftdetect/astro.vim: -------------------------------------------------------------------------------- 1 | " Vim ftdetect file. 2 | " Language: Astro 3 | " Author: Wuelner Martínez 4 | " Maintainer: Wuelner Martínez 5 | " URL: https://github.com/wuelnerdotexe/vim-astro 6 | " Last Change: 2022 Aug 24 7 | 8 | " Whether to set the Astro filetype on *.astro files. 9 | autocmd BufNewFile,BufRead *.astro setfiletype astro 10 | " vim: ts=8 11 | -------------------------------------------------------------------------------- /ftplugin/astro.vim: -------------------------------------------------------------------------------- 1 | " Vim filetype plugin file 2 | " Language: Astro 3 | " Maintainer: Romain Lafourcade 4 | " Last Change: 2022 Dec 5 5 | 6 | if exists("b:did_ftplugin") 7 | finish 8 | endif 9 | let b:did_ftplugin = 1 10 | 11 | let s:cpo_save = &cpo 12 | set cpo-=C 13 | 14 | let b:undo_ftplugin = "setlocal" 15 | \ .. " formatoptions<" 16 | \ .. " path<" 17 | \ .. " suffixesadd<" 18 | \ .. " matchpairs<" 19 | \ .. " comments<" 20 | \ .. " commentstring<" 21 | \ .. " iskeyword<" 22 | \ .. " define<" 23 | \ .. " include<" 24 | \ .. " includeexpr<" 25 | 26 | " Create self-resetting autocommand group 27 | augroup Astro 28 | autocmd! 29 | augroup END 30 | 31 | " Set 'formatoptions' to break comment lines but not other lines, 32 | " and insert the comment leader when hitting or using "o". 33 | setlocal formatoptions-=t 34 | setlocal formatoptions+=croql 35 | 36 | " Remove irrelevant part of 'path'. 37 | setlocal path-=/usr/include 38 | 39 | " Seed 'path' with default directories for :find, gf, etc. 40 | setlocal path+=src/** 41 | setlocal path+=public/** 42 | 43 | " Help Vim find extension-less filenames 44 | let &l:suffixesadd = 45 | \ ".astro" 46 | \ .. ",.js,.jsx,.es,.es6,.cjs,.mjs,.jsm" 47 | \ .. ",.json" 48 | \ .. ",.scss,.sass,.css" 49 | \ .. ",.svelte" 50 | \ .. ",.ts,.tsx,.d.ts" 51 | \ .. ",.vue" 52 | 53 | " From $VIMRUNTIME/ftplugin/html.vim 54 | setlocal matchpairs+=<:> 55 | 56 | " Matchit configuration 57 | if exists("loaded_matchit") 58 | let b:match_ignorecase = 0 59 | 60 | " From $VIMRUNTIME/ftplugin/javascript.vim 61 | let b:match_words = 62 | \ '\:\,' 63 | \ .. '<\@<=\([^ \t>/]\+\)\%(\s\+[^>]*\%([^/]>\|$\)\|>\|$\):<\@<=/\1>,' 64 | \ .. '<\@<=\%([^ \t>/]\+\)\%(\s\+[^/>]*\|$\):/>' 65 | 66 | " From $VIMRUNTIME/ftplugin/html.vim 67 | let b:match_words ..= 68 | \ ',' 69 | \ .. '<:>,' 70 | \ .. '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' 71 | \ .. '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' 72 | \ .. '<\@<=\([^/!][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>' 73 | 74 | let b:undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_words" 75 | endif 76 | 77 | " Change what constitutes a word, mainly useful for CSS/SASS 78 | setlocal iskeyword+=- 79 | setlocal iskeyword+=$ 80 | setlocal iskeyword+=% 81 | 82 | " Define paths/aliases for module resolution 83 | call astro#CollectPathsFromConfig() 84 | 85 | " Find ESM imports 86 | setlocal include=^\\s*\\(import\\\|import\\s\\+[^\/]\\+from\\)\\s\\+['\"] 87 | 88 | " Process aliases if file can't be found 89 | setlocal includeexpr=astro#AstroInclude(v:fname) 90 | 91 | " Set 'define' to a comprehensive value 92 | " From $VIMRUNTIME/ftplugin/javascript.vim and 93 | " $VIMRUNTIME/ftplugin/sass.vim 94 | let &l:define = 95 | \ '\(^\s*(*async\s\+function\|(*function\)' 96 | \ .. '\|^\s*\(\*\|static\|async\|get\|set\|\i\+\.\)' 97 | \ .. '\|^\s*\(\ze\i\+\)\(([^)]*).*{$\|\s*[:=,]\)' 98 | \ .. '\|^\s*\(export\s\+\|export\s\+default\s\+\)*\(var\|let\|const\|function\|class\)' 99 | \ .. '\|\' 100 | \ .. '\|^\C\v\s*%(\@function|\@mixin|\=)|^\s*%(\$[[:alnum:]-]+:|[%.][:alnum:]-]+\s*%(\{|$))@=' 101 | 102 | " HTML comments by default 103 | setlocal comments=s: 104 | setlocal commentstring= 105 | 106 | " Set &comments and &commentstring according to current scope 107 | autocmd Astro CursorMoved call astro#AstroComments() 108 | 109 | let &cpo = s:cpo_save 110 | unlet s:cpo_save 111 | 112 | " vim: textwidth=78 tabstop=8 shiftwidth=4 softtabstop=4 expandtab 113 | -------------------------------------------------------------------------------- /indent/astro.vim: -------------------------------------------------------------------------------- 1 | " Vim indent file (experimental). 2 | " Language: Astro 3 | " Author: Wuelner Martínez 4 | " Maintainer: Wuelner Martínez 5 | " URL: https://github.com/wuelnerdotexe/vim-astro 6 | " Last Change: 2022 Aug 07 7 | " Based On: Evan Lecklider's vim-svelte 8 | " Changes: See https://github.com/evanleck/vim-svelte 9 | " Credits: See vim-svelte on github 10 | 11 | " Only load this indent file when no other was loaded yet. 12 | if exists('b:did_indent') 13 | finish 14 | endif 15 | 16 | let b:html_indent_script1 = 'inc' 17 | let b:html_indent_style1 = 'inc' 18 | 19 | " Embedded HTML indent. 20 | runtime! indent/html.vim 21 | let s:html_indent = &l:indentexpr 22 | unlet b:did_indent 23 | 24 | let b:did_indent = 1 25 | 26 | setlocal indentexpr=GetAstroIndent() 27 | setlocal indentkeys=<>>,/,0{,{,},0},0),0],0\,<<>,,!^F,*,o,O,e,; 28 | 29 | " Only define the function once. 30 | if exists('*GetAstroIndent') 31 | finish 32 | endif 33 | 34 | let s:cpoptions_save = &cpoptions 35 | set cpoptions&vim 36 | 37 | function! GetAstroIndent() 38 | let l:current_line_number = v:lnum 39 | 40 | if l:current_line_number == 0 41 | return 0 42 | endif 43 | 44 | let l:current_line = getline(l:current_line_number) 45 | 46 | if l:current_line =~ '^\s*', '', '', 'bW') && 61 | \ l:previous_line =~ ';$' && l:current_line !~ '}' 62 | return l:previous_line_indent 63 | endif 64 | 65 | if synID(l:previous_line_number, match( 66 | \ l:previous_line, '\S' 67 | \ ) + 1, 0) == hlID('htmlTag') && synID(l:current_line_number, match( 68 | \ l:current_line, '\S' 69 | \ ) + 1, 0) != hlID('htmlEndTag') 70 | let l:indents_match = l:indent == l:previous_line_indent 71 | let l:previous_closes = l:previous_line =~ '/>$' 72 | 73 | if l:indents_match && 74 | \ !l:previous_closes && l:previous_line =~ '<\(\u\|\l\+:\l\+\)' 75 | return l:previous_line_indent + shiftwidth() 76 | elseif !l:indents_match && l:previous_closes 77 | return l:previous_line_indent 78 | endif 79 | endif 80 | 81 | return l:indent 82 | endfunction 83 | 84 | let &cpoptions = s:cpoptions_save 85 | unlet s:cpoptions_save 86 | " vim: ts=8 87 | -------------------------------------------------------------------------------- /syntax/astro.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file. 2 | " Language: Astro 3 | " Author: Wuelner Martínez 4 | " Maintainer: Wuelner Martínez 5 | " URL: https://github.com/wuelnerdotexe/vim-astro 6 | " Last Change: 2022 Aug 22 7 | " Based On: Evan Lecklider's vim-svelte 8 | " Changes: See https://github.com/evanleck/vim-svelte 9 | " Credits: See vim-svelte on github 10 | 11 | " Quit when a (custom) syntax file was already loaded. 12 | if !exists('main_syntax') 13 | if exists('b:current_syntax') 14 | finish 15 | endif 16 | let main_syntax = 'astro' 17 | elseif exists('b:current_syntax') && b:current_syntax == 'astro' 18 | finish 19 | endif 20 | 21 | " Astro syntax variables are initialized. 22 | let g:astro_typescript = get(g:, 'astro_typescript', 'disable') 23 | let g:astro_stylus = get(g:, 'astro_stylus', 'disable') 24 | 25 | let s:cpoptions_save = &cpoptions 26 | set cpoptions&vim 27 | 28 | " Embedded HTML syntax. 29 | runtime! syntax/html.vim 30 | 31 | " htmlTagName: expand HTML tag names to include mixed case and periods. 32 | syntax match htmlTagName contained "\<[a-zA-Z\.]*\>" 33 | 34 | " astroDirectives: add Astro Directives to HTML arguments. 35 | syntax match astroDirectives contained '\<[a-z]\+:[a-z|]*\>' containedin=htmlTag 36 | 37 | unlet b:current_syntax 38 | 39 | if g:astro_typescript == 'enable' 40 | " Embedded TypeScript syntax. 41 | syntax include @astroJavaScript syntax/typescript.vim 42 | 43 | " javaScriptExpression: a javascript expression is used as an arg value. 44 | syntax clear javaScriptExpression 45 | syntax region javaScriptExpression 46 | \ contained start=+&{+ 47 | \ keepend end=+};+ 48 | \ contains=@astroJavaScript,@htmlPreproc 49 | 50 | " javaScript: add TypeScript support to HTML script tag. 51 | syntax clear javaScript 52 | syntax region javaScript 53 | \ start=+]*>+ 54 | \ keepend 55 | \ end=+]*>+me=s-1 56 | \ contains=htmlScriptTag,@astroJavaScript,@htmlPreproc,htmlCssStyleComment 57 | else 58 | " Embedded JavaScript syntax. 59 | syntax include @astroJavaScript syntax/javascript.vim 60 | endif 61 | 62 | " astroFence: detect the Astro fence. 63 | syntax match astroFence contained +^---$+ 64 | 65 | " astrojavaScript: add TypeScript support to Astro code fence. 66 | syntax region astroJavaScript 67 | \ start=+^---$+ 68 | \ keepend 69 | \ end=+^---$+ 70 | \ contains=htmlTag,@astroJavaScript,@htmlPreproc,htmlCssStyleComment,htmlEndTag,astroFence 71 | \ fold 72 | 73 | unlet b:current_syntax 74 | 75 | if g:astro_typescript == 'enable' 76 | " Embedded TypeScript React (TSX) syntax. 77 | syntax include @astroJavaScriptReact syntax/typescriptreact.vim 78 | else 79 | " Embedded JavaScript React (JSX) syntax. 80 | syntax include @astroJavaScriptReact syntax/javascriptreact.vim 81 | endif 82 | 83 | " astroJavaScriptExpression: add {JSX or TSX} support to Astro expresions. 84 | execute 'syntax region astroJavaScriptExpression start=+{+ keepend end=+}+ ' . 85 | \ 'contains=@astroJavaScriptReact, @htmlPreproc containedin=' . join([ 86 | \ 'htmlArg', 'htmlBold', 'htmlBoldItalic', 'htmlBoldItalicUnderline', 87 | \ 'htmlBoldUnderline', 'htmlBoldUnderlineItalic', 'htmlH1', 'htmlH2', 88 | \ 'htmlH3', 'htmlH4', 'htmlH5', 'htmlH6', 'htmlHead', 'htmlItalic', 89 | \ 'htmlItalicBold', 'htmlItalicBoldUnderline', 'htmlItalicUnderline', 90 | \ 'htmlItalicUnderlineBold', 'htmlLeadingSpace', 'htmlLink', 91 | \ 'htmlStrike', 'htmlString', 'htmlTag', 'htmlTitle', 'htmlUnderline', 92 | \ 'htmlUnderlineBold', 'htmlUnderlineBoldItalic', 93 | \ 'htmlUnderlineItalic', 'htmlUnderlineItalicBold', 'htmlValue' 94 | \ ], ',') 95 | 96 | " cssStyle: add CSS style tags support in TypeScript React. 97 | syntax region cssStyle 98 | \ start=+]*>+ 99 | \ keepend 100 | \ end=+]*>+me=s-1 101 | \ contains=htmlTag,@htmlCss,htmlCssStyleComment,@htmlPreproc,htmlEndTag 102 | \ containedin=@astroJavaScriptReact 103 | 104 | unlet b:current_syntax 105 | 106 | " Embedded SCSS syntax. 107 | syntax include @astroScss syntax/scss.vim 108 | 109 | " cssStyle: add SCSS style tags support in Astro. 110 | syntax region scssStyle 111 | \ start=/\_[^>]*\(lang\)=\("\|''\)[^\2]*scss[^\2]*\2\_[^>]*>/ 112 | \ keepend 113 | \ end=++me=s-1 114 | \ contains=@astroScss,astroSurroundingTag 115 | \ fold 116 | 117 | unlet b:current_syntax 118 | 119 | " Embedded SASS syntax. 120 | syntax include @astroSass syntax/sass.vim 121 | 122 | " cssStyle: add SASS style tags support in Astro. 123 | syntax region sassStyle 124 | \ start=/\_[^>]*\(lang\)=\("\|''\)[^\2]*sass[^\2]*\2\_[^>]*>/ 125 | \ keepend 126 | \ end=++me=s-1 127 | \ contains=@astroSass,astroSurroundingTag 128 | \ fold 129 | 130 | unlet b:current_syntax 131 | 132 | " Embedded LESS syntax. 133 | syntax include @astroLess syntax/less.vim 134 | 135 | " cssStyle: add LESS style tags support in Astro. 136 | syntax region lessStyle 137 | \ start=/\_[^>]*\(lang\)=\("\|''\)[^\2]*less[^\2]*\2\_[^>]*>/ 138 | \ keepend 139 | \ end=++me=s-1 140 | \ contains=@astroLess,astroSurroundingTag 141 | \ fold 142 | 143 | unlet b:current_syntax 144 | 145 | " Embedded Stylus syntax. 146 | " NOTE: Vim does not provide stylus support by default, but you can install 147 | " this plugin to support it: https://github.com/wavded/vim-stylus 148 | if g:astro_stylus == 'enable' 149 | try 150 | " Embedded Stylus syntax. 151 | syntax include @astroStylus syntax/stylus.vim 152 | 153 | " stylusStyle: add Stylus style tags support in Astro. 154 | syntax region stylusStyle 155 | \ start=/\_[^>]*\(lang\)=\("\|''\)[^\2]*stylus[^\2]*\2\_[^>]*>/ 156 | \ keepend 157 | \ end=++me=s-1 158 | \ contains=@astroStylus,astroSurroundingTag 159 | \ fold 160 | 161 | unlet b:current_syntax 162 | catch 163 | echomsg "you need install a external plugin for support stylus in .astro files" 164 | endtry 165 | endif 166 | 167 | " astroSurroundingTag: add surround HTML tag to script and style. 168 | syntax region astroSurroundingTag 169 | \ start=+<\(script\|style\)+ 170 | \ end=+>+ 171 | \ contains=htmlTagError,htmlTagN,htmlArg,htmlValue,htmlEvent,htmlString 172 | \ contained 173 | \ fold 174 | 175 | " Define the default highlighting. 176 | " Only used when an item doesn't have highlighting yet. 177 | highlight default link astroDirectives Special 178 | highlight default link astroFence Comment 179 | 180 | let b:current_syntax = 'astro' 181 | if main_syntax == 'astro' 182 | unlet main_syntax 183 | endif 184 | 185 | " Sync from start because of the wacky nesting. 186 | syntax sync fromstart 187 | 188 | let &cpoptions = s:cpoptions_save 189 | unlet s:cpoptions_save 190 | " vim: ts=8 191 | --------------------------------------------------------------------------------