2021-04-18 18:06:11 +03:00
|
|
|
local npairs = require('nvim-autopairs')
|
|
|
|
local ts = require 'nvim-treesitter.configs'
|
|
|
|
local log = require('nvim-autopairs._log')
|
|
|
|
|
|
|
|
ts.setup {
|
2021-04-21 07:39:36 +03:00
|
|
|
ensure_installed = 'maintained',
|
|
|
|
highlight = {enable = true},
|
2021-04-18 18:06:11 +03:00
|
|
|
}
|
|
|
|
_G.npairs = npairs;
|
|
|
|
vim.api.nvim_set_keymap('i' , '<CR>','v:lua.npairs.check_break_line_char()', {expr = true , noremap = true})
|
|
|
|
|
|
|
|
|
|
|
|
local data = {
|
|
|
|
{
|
|
|
|
name = "lua if add endwise" ,
|
|
|
|
filepath = './tests/endwise/init.lua',
|
|
|
|
filetype = "lua",
|
|
|
|
linenr = 5,
|
|
|
|
key = [[<cr>]],
|
|
|
|
before = [[if data== 'fdsafdsa' then| ]],
|
|
|
|
after = [[end ]]
|
|
|
|
},
|
|
|
|
{
|
2021-05-04 03:55:43 +03:00
|
|
|
-- only = true;
|
2021-04-20 06:41:22 +03:00
|
|
|
name = "add newline have endwise" ,
|
2021-04-18 18:06:11 +03:00
|
|
|
filepath = './tests/endwise/init.lua',
|
|
|
|
filetype = "lua",
|
|
|
|
linenr = 5,
|
|
|
|
key = [[<cr>]],
|
2021-04-20 06:41:22 +03:00
|
|
|
before = [[if data== 'fdsafdsa' then|end]],
|
|
|
|
after = [[end]]
|
2021-04-18 18:06:11 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name = "don't add endwise on match rule" ,
|
|
|
|
filepath = './tests/endwise/init.lua',
|
|
|
|
filetype = "lua",
|
|
|
|
linenr = 5,
|
|
|
|
key = [[<cr>]],
|
|
|
|
before ={
|
|
|
|
[[if data == 'xdsad' then| ]],
|
|
|
|
[[ local abde='das' ]],
|
|
|
|
[[end]]
|
|
|
|
},
|
|
|
|
after = [[ local abde='das' ]]
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-04-21 07:39:36 +03:00
|
|
|
local run_data = _G.Test_filter(data)
|
2021-04-18 18:06:11 +03:00
|
|
|
|
|
|
|
local _, ts_utils = pcall(require, 'nvim-treesitter.ts_utils')
|
|
|
|
_G.TU = ts_utils
|
|
|
|
|
|
|
|
|
|
|
|
describe('[endwise tag]', function()
|
2021-04-21 07:39:36 +03:00
|
|
|
_G.Test_withfile(run_data,{
|
|
|
|
before = function(value)
|
|
|
|
npairs.clear_rules()
|
|
|
|
npairs.add_rules(require('nvim-autopairs.rules.endwise-'..value.filetype))
|
|
|
|
end
|
|
|
|
})
|
2021-04-18 18:06:11 +03:00
|
|
|
end)
|