From 99adb304112a59fbc7c29ee3802ddcaad73afcd2 Mon Sep 17 00:00:00 2001 From: Valery Kharshats Date: Wed, 28 Apr 2021 02:04:16 -0400 Subject: [PATCH] Improve Typescript React support I use vim-coc and looks like it sets filetype typescriptreact for tsx files. Anyways I'm keeping previous functionality just in case somebody used it. For my current setup the implementation is much simple. ``` let g:context#commentstring#table['typescriptreact'] = { \ 'tsxRegion': '{/*%s*/}' \} ``` --- autoload/context/commentstring.vim | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/autoload/context/commentstring.vim b/autoload/context/commentstring.vim index 1f1c06e..ec2da71 100644 --- a/autoload/context/commentstring.vim +++ b/autoload/context/commentstring.vim @@ -17,33 +17,21 @@ let g:context#commentstring#table.html = { let g:context#commentstring#table.xhtml = g:context#commentstring#table.html -let g:context#commentstring#table['javascript.jsx'] = { +let s:react = { \ 'jsComment' : '// %s', \ 'jsImport' : '// %s', \ 'jsxStatment' : '// %s', \ 'jsxRegion' : '{/*%s*/}', \ 'jsxTag' : '{/*%s*/}', \} - -let g:context#commentstring#table['typescript.jsx'] = { - \ 'jsComment' : '// %s', - \ 'jsImport' : '// %s', - \ 'jsxStatment' : '// %s', - \ 'jsxRegion' : '{/*%s*/}', - \ 'jsxTag' : '{/*%s*/}', - \} - -let g:context#commentstring#table['typescript.tsx'] = { - \ 'tsComment' : '// %s', - \ 'tsImport' : '// %s', - \ 'tsxStatment' : '// %s', - \ 'tsxRegion' : '{/*%s*/}', - \ 'tsxTag' : '{/*%s*/}', - \} - +let g:context#commentstring#table['javascript.jsx'] = s:react +let g:context#commentstring#table['typescript.jsx'] = s:react +let g:context#commentstring#table['typescript.tsx'] = s:react +let g:context#commentstring#table['typescriptreact'] = { + \ 'tsxRegion': '{/*%s*/}' + \} let g:context#commentstring#table.vue = { \ 'javaScript' : '//%s', \ 'cssStyle' : '/*%s*/', \} -