How to add Dart syntactic highlight to VIM?

Asked

Viewed 96 times

2

I am starting the studies of Flutter. For this, I am using as editor the . I consider it an option to use an IDE, but for quick and small things, use the vim is mandatory for how I am studying.

The vim that I receive does not come with the syntactic highlight for Dart. How do I activate it?

I’m using the vim in WSL (Ubuntu 18.04) and via Git Bash, if this is relevant to the response

  • 1

    With some plugins manager, I believe install the Dart-lang/Dart-vim-plugin be quite simple

  • 1

    @Andersoncarloswoss, I’ve actually done in the WSL following what is described there (including, installed using the vim-plug after half an hour seeing the differences between managers). I’m here rethinking to install in Git Bash and add knowledge to the community.

  • 1

    I always used the vim-plug and never had problem :D

1 answer

3


As mentioned by @Acwoss, the first step is to install a plugin manager from .

For the sake of simplicity, it seemed easier to use the vim-plug.

According to the guide of vim-plug, the first thing to do is to make it self-loadable vim. A priori, just put the script .vim in the directory ~/.vim/autoload to do this. The file for this is already ready for this: just download the plug.vim of the repository. The only branch with active development at the moment is the master, the rest being rather old. So we need to access, from the Github user junegunn, the respository vim-plug, in the branch master, and download the file plug.vim inside the directory ~/.vim/autoload. Github provides access to static files within the domain raw.githubusercontent.com, in the following URL formation:

https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
\_______________________________/ \_____/  \______/ \____/ \______/ 
               |                     |          |     |        |
               |                     v          |     v        v
               |            Usuário do GitHub   v   Branch    Path
               v                           Repositório
     Domínio de arquivos estáticos

In the README, the plugin manager author tells to download via the following command:

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

But what does it mean?

  • curl: command used to connect to some URL
  • -f: fault silently
  • -L: follow the redirect links (http status 3xx)
  • -o <file>: directs the downloaded content to the file <file>
  • --create-dirs: guarantees the existence of the necessary directories (as if it were a mkdir -p ~/.vim/autoload) to save the output

After doing this, just put in the configuration file (usually the ~/.vimrc) a block of vim-plug. The block starts with call plug#begin() and ends with call plug#end().

Within this block, you can specify the plugins you want using the following syntax:

call plug#begin()

" comentário vem precedidos de aspas

Plug 'junegunn/vim-easy-align'
" |           |
"Comando   Usuário/repositório no github

Plug 'https://github.com/junegunn/vim-github-dashboard.git'
"        |
"      Também aceita qualquer repositório git com a URL completa,
"      o github é inferido na inexistência

call plug#end()

There are a few more nuances to the vim-plug, but the main in order to add syntactic highlighting is this

The plugin I want is the dart-lang/dart-vim-plugin. So just put it on ~/.vimrc:

call plug#begin()

Plug dart-lang/dart-vim-plugin

call plug#end()

When you start the vim, it is necessary to ask for the vim-plug install the necessary, through the command PlugInstall. And voi-la:

destaque sintático de dart no vim

The same steps worked for Git Bash and Ubuntu via WSL

Browser other questions tagged

You are not signed in. Login or sign up in order to post.