vim-closetag
vim-closetag copied to clipboard
Autoclose dosent work on jsx and tsx
` call s:Declare('g:closetag_filetypes', 'html,xhtml,phtml') call s:Declare('g:closetag_xhtml_filetypes', 'xhtml')
call s:Declare('g:closetag_filenames', '*.html,*.xhtml,*.phtml,*.js,*.jsx,*.ts,*.tsx')
call s:Declare('g:closetag_xhtml_filenames', '*.xhtml,*.js,*.jsx,*.ts,*.tsx')
call s:Declare('g:closetag_shortcut', '>')
call s:Declare('g:closetag_close_shortcut', '')
call s:Declare('g:closetag_emptyTags_caseSensitive', 1)
call s:Declare('g:closetag_enable_react_fragment', 1)
call s:Declare('g:closetag_regions', {
\ 'typescript.tsx': 'jsxRegion,tsxRegion',
\ 'javascript.jsx': 'jsxRegion',
\ 'typescriptreact': 'jsxRegion,tsxRegion',
\ 'javascriptreact': 'jsxRegion',
\ })
` it works on .js files and .ts files but not for jsx and tsx, any help would be appreaciated :)
For me only works in html files, doesn't work for js and jsx files
I´m using this in my init.vim, and it´s working fine for jsx and tsx.
let g:closetag_filenames = '*.html,*.xhtml,*.jsx,*.tsx'
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx,*.tsx'
let g:closetag_filetypes = 'html,js'
let g:closetag_xhtml_filetype = 'xhtml,jsx,tsx'
let g:closetag_emptyTags_caseSensitive = 1
let g:closetag_regions = {
\ 'typescript.tsx': 'jsxRegion,tsxRegion',
\ 'javascript.jsx': 'jsxRegion',
\ }
let g:closetag_shortcut = '>'
I'm using in my init.lua with nvim but some feature is not work. Please help me.
HTML = WORK JSX = WORK TSX = NOT WORK !! <<<<
-- set vim options here (vim.<first_key>.<second_key> = value) options = { opt = { -- set to true or false etc. relativenumber = true, -- sets vim.opt.relativenumber number = true, -- sets vim.opt.number spell = false, -- sets vim.opt.spell signcolumn = "auto", -- sets vim.opt.signcolumn to auto wrap = false, -- sets vim.opt.wrap }, g = { mapleader = " ", -- sets vim.g.mapleader autoformat_enabled = true, -- enable or disable auto formatting at start (lsp.formatting.format_on_save must be enabled) cmp_enabled = true, -- enable completion at start autopairs_enabled = true, -- enable autopairs at start diagnostics_enabled = true, -- enable diagnostics at start status_diagnostics_enabled = true, -- enable diagnostics in statusline icons_enabled = true, -- disable icons in the UI (disable if no nerd font is available, requires :PackerSync after changing) ui_notifications_enabled = true, -- disable notifications when toggling UI elements transparent_enabled = true, -- enable transparent background closetag_filenames = ".html,.xhtml,.phtml", closetag_xhtml_filenames = ".xhtml,*.{t,j}sx", closetag_filetypes = "html,xhtml,phtml", closetag_xhtml_filetypes = "xhtml,{t,j}sx", closetag_shortcut = ">", closetag_close_shortcut = "
>", closetag_enable_react_fragment = 1, }, },
In my init.lua this works
vim.cmd([[
let g:closetag_filenames = '*.html,*.xhtml,*.jsx,*.tsx'
let g:closetag_xhtml_filenames = '*.xhtml,*.jsx,*.tsx'
let g:closetag_filetypes = 'html,js'
let g:closetag_xhtml_filetype = 'xhtml,jsx,tsx'
let g:closetag_emptyTags_caseSensitive = 1
let g:closetag_regions = {
\ 'typescript.tsx': 'jsxRegion,tsxRegion',
\ 'javascript.jsx': 'jsxRegion',
\ }
let g:closetag_shortcut = '>'
]])
@northnSouth Thanks, I experienced the same problem in TSX files, I had my configs in a .vim file but I tried using your solution and it worked,
I also have this issue but with any filetype different than html. I'm currently trying to use this with eelixir
and eruby
, but it just does not work, don't know why. This is my whole init.lua
right now:
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
'git',
'clone',
'--filter=blob:none',
'https://github.com/folke/lazy.nvim.git',
'--branch=stable', -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require('lazy').setup({
{
'alvan/vim-closetag',
lazy = false,
config = function()
vim.cmd("let g:closetag_filetypes='html,eelixir,eruby'")
end,
},
})
If I manually change the filetype of any file to html, it starts working 😅
I have tried the same configs shown in this thread and it just does not work for any of those filetypes (js, jsx etc), nor it works for erb and eex when I add it to closetag_filetypes
. I have also tried to add *.erb
and *.eex
to closetag_filenames
but to no avail. This plugin just suddenly stopped working )):: Which is really sad, since it is a very good plugin!
Edit: I have also tried to run the command :CloseTagEnableBuffer
inside a .eex
file (eelixir filetype), but it still does not activate it.
I´m using this in my init.vim, and it´s working fine for jsx and tsx.
let g:closetag_filenames = '*.html,*.xhtml,*.jsx,*.tsx' let g:closetag_xhtml_filenames = '*.xhtml,*.jsx,*.tsx' let g:closetag_filetypes = 'html,js' let g:closetag_xhtml_filetype = 'xhtml,jsx,tsx' let g:closetag_emptyTags_caseSensitive = 1 let g:closetag_regions = { \ 'typescript.tsx': 'jsxRegion,tsxRegion', \ 'javascript.jsx': 'jsxRegion', \ } let g:closetag_shortcut = '>'
Hi @Hdoc1509 , I'm quite confusing on this configuration. Why remove
\ 'typescriptreact': 'jsxRegion,tsxRegion',
\ 'javascriptreact': 'jsxRegion',
from g:closetag_regions
?
I cannot make the configuration work for all of js/jsx/ts/tsx at the same time. Could anyone help me?
I also have this issue but with any filetype different than html. I'm currently trying to use this with
eelixir
anderuby
, but it just does not work, don't know why. This is my wholeinit.lua
right now:local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' if not vim.loop.fs_stat(lazypath) then vim.fn.system({ 'git', 'clone', '--filter=blob:none', 'https://github.com/folke/lazy.nvim.git', '--branch=stable', -- latest stable release lazypath, }) end vim.opt.rtp:prepend(lazypath) require('lazy').setup({ { 'alvan/vim-closetag', lazy = false, config = function() vim.cmd("let g:closetag_filetypes='html,eelixir,eruby'") end, }, })
If I manually change the filetype of any file to html, it starts working 😅
I have tried the same configs shown in this thread and it just does not work for any of those filetypes (js, jsx etc), nor it works for erb and eex when I add it to
closetag_filetypes
. I have also tried to add*.erb
and*.eex
toclosetag_filenames
but to no avail. This plugin just suddenly stopped working )):: Which is really sad, since it is a very good plugin!Edit: I have also tried to run the command
:CloseTagEnableBuffer
inside a.eex
file (eelixir filetype), but it still does not activate it.
In lazy, you need to specify these global variables in init
, so this plugin will recognize them when loading.
For me this seems to be the minimal config to get this working Neovim v0.8.3
vim.g.closetag_filetypes = 'html,js,typescriptreact'
vim.g.closetag_emptyTags_caseSensitive = 1
vim.g.closetag_regions = {
['typescript.tsx'] = 'jsxRegion,tsxRegion',
['javascript.jsx'] = 'jsxRegion',
}
anyone solve the problem where the the auto close tag is applying outside the region??
For me this seems to be the minimal config to get this working
Neovim v0.8.3
vim.g.closetag_filetypes = 'html,js,typescriptreact' vim.g.closetag_emptyTags_caseSensitive = 1 vim.g.closetag_regions = { ['typescript.tsx'] = 'jsxRegion,tsxRegion', ['javascript.jsx'] = 'jsxRegion', }
are you appending this to your init.lua file if not where ?
I´m using this in my init.vim, and it´s working fine for jsx and tsx.
let g:closetag_filenames = '*.html,*.xhtml,*.jsx,*.tsx' let g:closetag_xhtml_filenames = '*.xhtml,*.jsx,*.tsx' let g:closetag_filetypes = 'html,js' let g:closetag_xhtml_filetype = 'xhtml,jsx,tsx' let g:closetag_emptyTags_caseSensitive = 1 let g:closetag_regions = { \ 'typescript.tsx': 'jsxRegion,tsxRegion', \ 'javascript.jsx': 'jsxRegion', \ } let g:closetag_shortcut = '>'
Hi @Hdoc1509 , I'm quite confusing on this configuration. Why remove
\ 'typescriptreact': 'jsxRegion,tsxRegion', \ 'javascriptreact': 'jsxRegion',
from
g:closetag_regions
?
Hi @linrongbin16, I only set those options and everything worked fine. You can check the config file in this commit from my nvim-config on that time.
At this moment, I'm using nvim-ts-autotag.
Additionally, you can check out my current treesitter config where nvim-ts-autotag
is setup.