Git Product home page Git Product logo

vim-vue's Introduction

vim-vue CircleCI

Vim syntax highlighting for Vue components.

This was initially forked from darthmall/vim-vue. I already have an implementation for this but found his code much cleaner. That's why I created a new version instead of a PR.

Installation

Install with Vundle

Plugin 'posva/vim-vue'

Install with Pathogen

cd ~/.vim/bundle && \
git clone https://github.com/posva/vim-vue.git

Install without a plugin manager (Vim 8)

git clone https://github.com/posva/vim-vue.git ~/.vim/pack/plugins/start/vim-vue

Integration with Syntastic or ALE

Currently only eslint is available. Please make sure eslint and eslint-plugin-vue are installed and properly configured:

npm i -g eslint eslint-plugin-vue

Contributing

If your language is not getting highlighted open an issue or a PR with the fix. You only need to add a line to the syntax/vue.vim file.

Don't forget to write Vader tests for the code you write. You can run the tests by executing make test in the terminal.

FAQ

Where is Jade?

Jade has been renamed to pug. Therefore you have to replace all your jade occurrences with pug. The new plugin for pug can be found on the same repository (the name has already been updated).

My syntax highlighting stops working randomly

This is because Vim tries to highlight text in an efficient way. Especially in files that include multiple languages, it can get confused. To work around this, you can run :syntax sync fromstart when it happens.

You can also setup an autocmd for this, so that every time a Vue file is opened, :syntax sync fromstart will be executed pre-emptively:

autocmd FileType vue syntax sync fromstart

See :h :syn-sync-first and this article for more details.

How can I use existing configuration/plugins in Vue files?

If you already have some configuration for filetypes like html, css and javascript (e.g. linters, completion), an easy way to use them in Vue files is by setting compound filetypes like this:

autocmd BufRead,BufNewFile *.vue setlocal filetype=vue.html.javascript.css

โš ๏ธ This may cause problems, because some plugins will then treat the whole buffer as html/javascript/css instead of only the part inside the tags. Ideally, you should configure everything that you want to use in Vue files individually.

How to use commenting functionality with multiple languages in Vue files?

caw.vim features built-in support for file context through context_filetype.vim. Just install both plugins and context-aware commenting will work in most files. The fenced code is detected by predefined regular expressions.

To use NERDCommenter with Vue files, you can use its "hooks" feature to temporarily change the filetype. Click for an example.
let g:ft = ''
function! NERDCommenter_before()
  if &ft == 'vue'
    let g:ft = 'vue'
    let stack = synstack(line('.'), col('.'))
    if len(stack) > 0
      let syn = synIDattr((stack)[0], 'name')
      if len(syn) > 0
        exe 'setf ' . substitute(tolower(syn), '^vue_', '', '')
      endif
    endif
  endif
endfunction
function! NERDCommenter_after()
  if g:ft == 'vue'
    setf vue
    let g:ft = ''
  endif
endfunction

Vim slows down when using this plugin How can I fix that?

Add let g:vue_disable_pre_processors=1 in your .vimrc to disable checking for prepocessors. When checking for preprocessor languages, multiple syntax highlighting checks are done, which can slow down vim. This variable prevents vim-vue from supporting every pre-processor language highlighting.

vim-vue's People

Contributors

adriaanzon avatar agirorn avatar chaoyuelee avatar clovery avatar darthmall avatar edwardbetts avatar esdras avatar franklx avatar fvictorio avatar glore avatar herrbischoff avatar huangdawei avatar izumisy avatar j-a-m-l avatar jmerizia avatar kaihendry avatar kesor avatar kikyous avatar knight42 avatar michaelfoss avatar milot-mirdita avatar nimser avatar posva avatar ryym avatar slice avatar w0rp avatar whitelynx avatar woat avatar z1lk avatar

Watchers

 avatar  avatar

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.