mirror of
https://github.com/ilyakooo0/nvim-autopairs.git
synced 2024-09-11 07:15:44 +03:00
Add exclude_filetypes
This commit is contained in:
parent
055e3f6c5f
commit
14bad1f3cd
@ -190,6 +190,12 @@ npairs.add_rules({
|
|||||||
.."<esc>viwU"
|
.."<esc>viwU"
|
||||||
end)
|
end)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- you can exclude filetypes
|
||||||
|
npairs.add_rule(
|
||||||
|
Rule("$$","$$")
|
||||||
|
:with_pair(cond.exclude_filetypes({"lua"}))
|
||||||
|
)
|
||||||
--- check ./lua/nvim-autopairs/rules/basic.lua
|
--- check ./lua/nvim-autopairs/rules/basic.lua
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -8,7 +8,6 @@ local cond = {}
|
|||||||
-- true when it is correct
|
-- true when it is correct
|
||||||
-- nil when it is not determine
|
-- nil when it is not determine
|
||||||
|
|
||||||
|
|
||||||
cond.none = function()
|
cond.none = function()
|
||||||
return function() return false end
|
return function() return false end
|
||||||
end
|
end
|
||||||
@ -199,4 +198,16 @@ cond.is_end_line = function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
cond.exclude_filetypes = function(filetypes)
|
||||||
|
return function(opts)
|
||||||
|
log.debug('exclude_filetypes')
|
||||||
|
for _, filetype in pairs(filetypes) do
|
||||||
|
if vim.bo.filetype == filetype then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return cond
|
return cond
|
||||||
|
@ -378,6 +378,26 @@ local data = {
|
|||||||
before = [[Vec| ]],
|
before = [[Vec| ]],
|
||||||
after = [[Vec<|> ]],
|
after = [[Vec<|> ]],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
setup_func = function()
|
||||||
|
npairs.add_rule(Rule("!", "!"):with_pair(cond.exclude_filetypes({"lua"})))
|
||||||
|
end,
|
||||||
|
name="disable pairs in lua",
|
||||||
|
filetype="lua",
|
||||||
|
key="!",
|
||||||
|
before = [[x| ]],
|
||||||
|
after = [[x!| ]]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
setup_func = function()
|
||||||
|
npairs.add_rule(Rule("!", "!"):with_pair(cond.exclude_filetypes({"lua"})))
|
||||||
|
end,
|
||||||
|
name="enable pairs in html",
|
||||||
|
filetype="html",
|
||||||
|
key="!",
|
||||||
|
before = [[x| ]],
|
||||||
|
after = [[x!|! ]]
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
local run_data = {}
|
local run_data = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user