GithubHelp home page GithubHelp logo

vim-astro's Introduction

vim-astro

Vim syntax highlighting and indentation for Astro

This is mostly just HTML syntax highlighting with some keywords added

Dependencies

The JavaScript highlighting depends on pangloss/vim-javascript. That ships with sheerun/vim-polyglot so if you're already using that then you should be set.

Installation

The simplest way to install vim-astro is via a package manager like Pathogen, Vundle, NeoBundle, Plug, or minpac.

For example, using minpac:

call minpac#add('rajasegar/vim-astro')

Or using Plug:

Plug 'rajasegar/vim-astro', {'branch': 'main'}

Options

To disable indentation within --- and <style> tags, set one of these variables in your vimrc:

let g:astro_indent_script = 0
let g:astro_indent_style = 0

Integrations

  • ALE: vim-astro should work out of the box with eslint and a few other linters/fixers. PRs welcome if the one you want is missing.
  • matchit.vim: vim-astro should work out of the box and allow moving between HTML tags as well as flow control like #if/:else//if.

Tests

Indentation tests are provided and any contributions would be much appreciated. They can be run with make test which will clone vader.vim into the current working directory and run the test suite.

vim-astro's People

Contributors

rajasegar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vim-astro's Issues

Indenting is very slow

Currently, indenting a .astro file with this plugin is very, very slow - a test on a 27-line file took 8 seconds.

I tried to profile the GetAstroIndent function, and the culprit seems to be the execute 'let indent = ' . get(language, 'indentexpr', -1) line:

FUNCTION  GetAstroIndent()
    Defined: ~/Projects/vim-astro/indent/astro.vim line 41
Called 26 times
Total time:   8.593040
 Self time:   0.001695

count  total (s)   self (s)
   45              0.000092   for language in s:languages
   44              0.000605     let opening_tag_line = searchpair(language.pairs[0], '', language.pairs[1], 'bWr')
                            
   44              0.000041     if opening_tag_line
   25   8.591538   0.000205       execute 'let indent = ' . get(language, 'indentexpr', -1)
   25              0.000019       break
   19              0.000008     endif
   45              0.000039   endfor
                            
   26              0.000050   if exists('l:indent')
   25              0.000213     if (opening_tag_line == prevnonblank(v:lnum - 1) || opening_tag_line == v:lnum) || getline(v:lnum) =~ '\v^\s*\</style'
    3              0.000003       return 0
   22              0.000007     endif
                            
                            
   22              0.000100     if (opening_tag_line == prevnonblank(v:lnum - 1) || opening_tag_line == v:lnum) || getline(v:lnum) =~ '\v^\s*---'
    1              0.000001       return 0
   21              0.000005     endif
    1              0.000001   else
                                " Couldn't find language, fall back to html
    1   0.000034   0.000020     execute 'let indent = ' . s:html_indent
   22              0.000008   endif
                            
   22              0.000017   return indent

FUNCTIONS SORTED ON TOTAL TIME
count  total (s)   self (s)  function
   26   8.593040   0.001695  GetAstroIndent()

FUNCTIONS SORTED ON SELF TIME
count  total (s)   self (s)  function
   26   8.593040   0.001695  GetAstroIndent()

Is there any possible way to speed this up?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.