vim-js icon indicating copy to clipboard operation
vim-js copied to clipboard

TypeScript Support

Open K-NRS opened this issue 5 years ago • 17 comments

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?

K-NRS avatar May 08 '20 10:05 K-NRS

Which plugin are you using for highlighting TypeScript now?

yuezk avatar May 08 '20 15:05 yuezk

# Plug 'leafgarland/typescript-vim'  
Plug 'HerringtonDarkholme/yats.vim'  
Plug 'peitalin/vim-jsx-typescript'

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

K-NRS avatar May 08 '20 15:05 K-NRS

@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

zorgick avatar May 08 '20 21:05 zorgick

@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.

K-NRS avatar May 09 '20 00:05 K-NRS

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

yuezk avatar May 09 '20 05:05 yuezk

@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.

zorgick avatar May 09 '20 07:05 zorgick

@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.

K-NRS avatar May 09 '20 10:05 K-NRS

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

image

yuezk avatar May 09 '20 10:05 yuezk

@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.

yuezk avatar May 09 '20 10:05 yuezk

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

K-NRS avatar May 09 '20 11:05 K-NRS

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

zorgick avatar May 09 '20 12:05 zorgick

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

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

image

glepnir avatar May 19 '20 05:05 glepnir

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 ,

glepnir avatar May 19 '20 05:05 glepnir

@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.

K-NRS avatar May 19 '20 10:05 K-NRS

@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

glepnir avatar May 19 '20 11:05 glepnir