Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working for typescriptreact and javascriptreact/typescriptreact file types #70

Closed
fans3210 opened this issue Jul 16, 2021 · 3 comments

Comments

@fans3210
Copy link

fans3210 commented Jul 16, 2021

I found the close tag not working in javascriptreact and typescriptreact file types. File name is xx.jsx or xx.tsx.

After explicitly changing file type to tsx or jsx, or even some nonsense words "haha", everything works again.

It seems like if my region is invalid or empty, then the autoclose works well, if I really input a valid region, then things breaks

I'm using nvim0.5 with native lsp configs, plugins: nvim-treesitter, nvim-lspconfig

Debug Info:
synstack is empty list,

let g:closetag_filenames = "*.html,*.xhtml,*.phtml,*.erb,*.jsx,*.tsx"
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx,*.tsx'

let g:closetag_filetypes = 'html,xhtml,phtml,jsx,tsx,javascript,javascriptreact,typescriptreact'
let g:closetag_xhtml_filetypes = 'xhtml,javascript.jsx,jsx,tsx,javascriptreact,typescriptreact'

let g:closetag_emptyTags_caseSensitive = 1

" dict
" Disables auto-close if not in a "valid" region (based on filetype)
"
let g:closetag_regions = {
    \ 'typescript.tsx': 'jsxRegion,tsxRegion',
    \ 'javascript.jsx': 'jsxRegion',
    \ 'typescriptreact': 'jsxRegion,tsxRegion',
    \ 'javascriptreact': 'jsxRegion',
    \ }

" Shortcut for closing tags, default is '>'
"
let g:closetag_shortcut = '>'

" Add > at current position without closing the current tag, default is ''
"
let g:closetag_close_shortcut = '<leader>>' 

@bushblade
Copy link

Hi @fans3210 did you find any solution to this? I am also facing the same issue.

@garbray
Copy link

garbray commented Sep 9, 2021

Hey guys I had the same issue, and just switch my config to the following

let g:closetag_filenames = "*.html,*.jsx,*.tsx,*.vue,*.xhml,*.xml"
let g:closetag_regions = {
  \ 'typescript.tsx': 'jsxRegion,tsxRegion',
  \ 'javascript.jsx': 'jsxRegion',
  \ }

let g:closetag_shortcut = '>'

@bushblade
Copy link

I actually switched to windwp/nvim-ts-autotag which seems to work well for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants