yuezk / vim-js

💯The most accurate syntax highlighting plugin for JavaScript and Flow.js
MIT License
140 stars 8 forks source link

TypeScript Support #12

Open K-NRS opened 4 years ago

K-NRS commented 4 years ago

Hello, the plugin is the best in vim javascript syntaxes. It would be nice to have a syntax plugin for TypeScript too. What do you think about this?

yuezk commented 4 years ago

Which plugin are you using for highlighting TypeScript now?

K-NRS commented 4 years ago
# Plug 'leafgarland/typescript-vim'  
Plug 'HerringtonDarkholme/yats.vim'  
Plug 'peitalin/vim-jsx-typescript'

These are. But so bad. Almost like syntax off.

zorgick commented 4 years ago

@K-NRS Maybe you have something else in your config that disturbs language highlighting for typescript. Check, if you have this command set regexpengine = 1, and better delete it for good, because that broke my ts highlight with any plugin. Currently I'm using this trio,

Plug 'yuezk/vim-js'                                                                                                                                                                                              
Plug 'HerringtonDarkholme/yats.vim'                                               
Plug 'maxmellon/vim-jsx-pretty'

and it covers all my needs in webdev, even in complex files, like in the picture image

K-NRS commented 4 years ago

@zorgick I dont think the problem is about regexpengine and i couldn't see anything related to typescript in your picture. I have no problem with js files. I just wanted to ask, "will this plugin have TypeScript support?"

My vim shows .ts and .tsx files like this: image

It doesn't even look like javascript files colorized by yuezk/vim-js and happens "'redrawtime' exceeded, syntax highlighting disabled" in some .ts and .tsx files. Not comfortable at all.

yuezk commented 4 years ago

@K-NRS How about replace Plug 'peitalin/vim-jsx-typescript' with Plug 'maxmellon/vim-jsx-pretty' and try again?

zorgick commented 4 years ago

@K-NRS the point is in the separation of concerns. Vim-js is a wonderful plugin that can't treat your js file any better. Yats is a reliable plugin that will do the same for your ts files. Thus, it is a redundancy to repeat the funtionality of yats in vimjs plugin.

Please reconsider your config, and try to make it as minimalistic as possible. You'd rather leave ONLY these 3 plugins, that I use, and check if your highlighting works.

Refer to this problem about regexengine click.

The picture I provided is a tsx file of 1200 lines. Without yats vim would highlight only exports, this and const/let, leaving jsx as simple text.

K-NRS commented 4 years ago

@yuezk still it's almost the same. image

When i look at scriptnames, i only see yats and vim-jsx-pretty as typescript plugin. And does not colorize function names, dots and operators (?. , || , &&) etc...

My vimrc file is already pretty minimal. But I will try with a much simpler vimrc in a container. I saw /usr/share/nvim/runtime/syntax/typescript.vim at the end of the scriptnames.

yuezk commented 4 years ago

@K-NRS Just curious, which plugin do you use to add this?

image

yuezk commented 4 years ago

@zorgick I also want to know which plugin are you using for adding the lint message here? image

I was looking for this feature for a long time.

K-NRS commented 4 years ago

@yuezk Neovim with coc.nvim. Enable its codeLens or make diagnostic.virtualText: true

zorgick commented 4 years ago

@yuezk it's vim-lsp. I switched to it after coc, and it's really fast and easy to set up

glepnir commented 4 years ago

@K-NRS I also use them, these is behavior on my vim

HerringtonDarkholme/yats.vim, 
MaxMEllon/vim-jsx-pretty,on_ft

image

glepnir commented 4 years ago

Notice that the vim and neovim had add the typescript syntax based on HerringtonDarkholme/yats.vim, https://github.com/neovim/neovim/commit/bd23fefb391816648ebd701096bf9973f6256750 https://github.com/vim/vim/commit/12ee7ff00b91d852e060bb24951d1c94239863eb ,

K-NRS commented 4 years ago

@K-NRS I also use them, these is behavior on my vim

HerringtonDarkholme/yats.vim, 
MaxMEllon/vim-jsx-pretty,on_ft

image

My current configuration too is like that now. The syntax could not be colored like VSCode in Vim. I accepted this until there is a new change.

glepnir commented 4 years ago

@K-NRS you can get the current cursor word syntaxt group then check what color set and config it.You may not be able to get the same colorscheme as vscode. Syntax highlight via regular configuration in vim may conflict with other highlight plugins, such as rainbow.vim. The current highlighting is easier for me to accept. This is my colorscheme and i config typescript support you can reference it.

https://github.com/hardcoreplayers/oceanic-material/blob/fdf2f35f4677a241c2c66c66e0f700ee9e45db72/colors/oceanic_material.vim#L595