pangloss / vim-javascript

Vastly improved Javascript indentation and syntax support in Vim.
http://www.vim.org/scripts/script.php?script_id=4452
3.79k stars 358 forks source link

Syntax highlighting broken after a template string #1177

Open yuezk opened 5 years ago

yuezk commented 5 years ago

The code syntax after a template string was highlighted as a string incorrectly. Below is the snapshot:

image

The minimal vim config

call plug#begin('~/.vim/plugged')

Plug 'pangloss/vim-javascript'

call plug#end()

filetype plugin on
filetype indent on

The test code:

const myVariable = "hello world";
const checkHightlighting = check(({
  firstVariable,
  secondVariable,
  thirdVariable,
  fourthVariable,
  fifthVariable = "createdObject",
  sixthVariable = `create${myVariable}`
}) => {
  return verify => {
    const noHighlightingHere = true;
    return verify(noHighlightingHere);
  };
},
[myVariable]);
FabioAntunes commented 4 years ago

If it helps here's another example that breaks syntax highlighting:

Something.prototype.generaterOutput = function(data) {
    const text = `{1:F01${this.getText1()}0001000001}{2:I${this.getText2()}${this.getText3(data)}N}{3:${this.getText4()}}{4:${this.getText5()}\r\n-}`;

    return text;
};
richchurcher commented 4 years ago

Another example, using the latest version (via vim-polyglot):

  getEditURL = communication => `/communications/${this.props.contract.id}/${communication.id}`

works

Works fine without the newline, but as formatted by Prettier:

  getEditURL = communication =>
    `/communications/${this.props.contract.id}/${communication.id}`

broken

breaks! Would love to contribute a fix, but Vim highlighting has always been a bit of a mystery to me :confused:

ArthurJahn commented 4 years ago

latest version works fine for me. See if you are using the plugin syntax highlight with the command:

:echo filter(split(execute(':scriptname'), "\n"), 'v:val =~? "javascript"')

The result might be like:

[' 29: ~/.vim/bundle/vim-javascript/ftdetect/flow.vim', ' 30: ~/..vim/bundle//vim-javascript/ftdetect/javascript.vim', '108: /usr/local/Cellar/vim/8.1.1900/share/vim/vim81/ftplugin/j
avascript.vim', '112: ~/.vim/bundle/vim-javascript/syntax/javascript.vim', '113: /usr/local/Cellar/vim/8.1.1900/share/vim/vim81/syntax/javascript.vim']

See if it lists vim-javascript, if not, reload your .vimrc or verify the installation.