├── .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 |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*]*>+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=+]*>+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=/+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=/+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=/+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=/+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 | --------------------------------------------------------------------------------