mirror of
https://github.com/windwp/nvim-ts-autotag.git
synced 2025-01-01 13:59:13 -06:00
add option to enable close and rename
This commit is contained in:
parent
20c76f93fc
commit
36f1422bfe
@ -38,13 +38,15 @@ local JSX_TAG = {
|
||||
}
|
||||
|
||||
|
||||
M.enableRename = true
|
||||
M.enableClose = true
|
||||
M.enable_rename = true
|
||||
M.enable_close = true
|
||||
|
||||
M.setup = function (opts)
|
||||
opts = opts or {}
|
||||
M.tbl_filetypes = opts.filetypes or M.tbl_filetypes
|
||||
M.tbl_skipTag = opts.skip_tag or M.tbl_skipTag
|
||||
M.enable_rename = opts.enable_rename or M.enable_rename
|
||||
M.enable_close = opts.enable_close or M.enable_close
|
||||
end
|
||||
|
||||
local function is_in_table(tbl, val)
|
||||
@ -314,14 +316,16 @@ M.attach = function (bufnr)
|
||||
local config = configs.get_module('autotag')
|
||||
M.setup(config)
|
||||
if is_in_table(M.tbl_filetypes, vim.bo.filetype) then
|
||||
vim.cmd[[inoremap <silent> <buffer> > ><c-c>:lua require('nvim-ts-autotag.internal').closeTag()<CR>a]]
|
||||
bufnr = bufnr or vim.api.nvim_get_current_buf()
|
||||
if M.enableRename == true then
|
||||
vim.cmd("augroup nvim_ts_xmltag_" .. bufnr)
|
||||
vim.cmd[[autocmd!]]
|
||||
vim.cmd[[autocmd InsertLeave <buffer> call v:lua.require('nvim-ts-autotag.internal').renameTag() ]]
|
||||
vim.cmd[[augroup end]]
|
||||
end
|
||||
if M.enable_close == true then
|
||||
vim.cmd[[inoremap <silent> <buffer> > ><c-c>:lua require('nvim-ts-autotag.internal').closeTag()<CR>a]]
|
||||
end
|
||||
if M.enable_rename == true then
|
||||
bufnr = bufnr or vim.api.nvim_get_current_buf()
|
||||
vim.cmd("augroup nvim_ts_xmltag_" .. bufnr)
|
||||
vim.cmd[[autocmd!]]
|
||||
vim.cmd[[autocmd InsertLeave <buffer> call v:lua.require('nvim-ts-autotag.internal').renameTag() ]]
|
||||
vim.cmd[[augroup end]]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -173,7 +173,6 @@ for _, value in pairs(data) do
|
||||
end
|
||||
if #run_data == 0 then run_data = data end
|
||||
local autotag = require('nvim-ts-autotag')
|
||||
autotag.test = true
|
||||
autotag.enableRename = false
|
||||
|
||||
local _, ts_utils = pcall(require, 'nvim-treesitter.ts_utils')
|
||||
|
Loading…
Reference in New Issue
Block a user