chg: Switch to cmp-vimtex
This commit is contained in:
parent
2fedf661e7
commit
bae5eb0cfd
3 changed files with 66 additions and 65 deletions
|
@ -8,11 +8,11 @@ npairs.setup({
|
||||||
})
|
})
|
||||||
|
|
||||||
npairs.add_rules({
|
npairs.add_rules({
|
||||||
Rule("\\(", "\\)", {"tex", "latex"}),
|
Rule("\\(", "\\)", { "tex", "latex" }),
|
||||||
Rule("\\[", "\\]", {"tex", "latex"}),
|
Rule("\\[", "\\]", { "tex", "latex" }),
|
||||||
},
|
},
|
||||||
-- disable for .vim files, but it work for another filetypes
|
-- disable for .vim files, but it work for another filetypes
|
||||||
Rule("a","a","-vim")
|
Rule("a", "a", "-vim")
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Add spaces between brackets
|
-- Add spaces between brackets
|
||||||
|
@ -59,7 +59,7 @@ end
|
||||||
|
|
||||||
-- Add space around =
|
-- Add space around =
|
||||||
npairs.add_rules {
|
npairs.add_rules {
|
||||||
Rule('=', '', { "-tex", "-vim", "-sh" })
|
Rule('=', '', { "-tex", "-vim", "-sh", "-dockerfile" })
|
||||||
:with_pair(cond.not_inside_quote())
|
:with_pair(cond.not_inside_quote())
|
||||||
:with_pair(function(opts)
|
:with_pair(function(opts)
|
||||||
local last_char = opts.line:sub(opts.col - 1, opts.col - 1)
|
local last_char = opts.line:sub(opts.col - 1, opts.col - 1)
|
||||||
|
@ -89,20 +89,21 @@ npairs.add_rules {
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Insertion with surrounding check
|
-- Insertion with surrounding check
|
||||||
function rule2(a1,ins,a2,lang)
|
function rule2(a1, ins, a2, lang)
|
||||||
npairs.add_rule(
|
npairs.add_rule(
|
||||||
Rule(ins, ins, lang)
|
Rule(ins, ins, lang)
|
||||||
:with_pair(function(opts) return a1..a2 == opts.line:sub(opts.col - #a1, opts.col + #a2 - 1) end)
|
:with_pair(function(opts) return a1 .. a2 == opts.line:sub(opts.col - #a1, opts.col + #a2 - 1) end)
|
||||||
:with_move(cond.none())
|
:with_move(cond.none())
|
||||||
:with_cr(cond.none())
|
:with_cr(cond.none())
|
||||||
:with_del(function(opts)
|
:with_del(function(opts)
|
||||||
local col = vim.api.nvim_win_get_cursor(0)[2]
|
local col = vim.api.nvim_win_get_cursor(0)[2]
|
||||||
return a1..ins..ins..a2 == opts.line:sub(col - #a1 - #ins + 1, col + #ins + #a2) -- insert only works for #ins == 1 anyway
|
return a1 .. ins .. ins .. a2 ==
|
||||||
|
opts.line:sub(col - #a1 - #ins + 1, col + #ins + #a2) -- insert only works for #ins == 1 anyway
|
||||||
end)
|
end)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
-- Only use it for ocaml
|
|
||||||
rule2('(','*',')','ocaml')
|
|
||||||
rule2('(*',' ','*)','ocaml')
|
|
||||||
rule2('(',' ',')')
|
|
||||||
|
|
||||||
|
-- Only use it for ocaml
|
||||||
|
rule2('(', '*', ')', 'ocaml')
|
||||||
|
rule2('(*', ' ', '*)', 'ocaml')
|
||||||
|
rule2('(', ' ', ')')
|
||||||
|
|
|
@ -24,18 +24,18 @@ cmp.setup({
|
||||||
}),
|
}),
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
{ name = "omni" },
|
{ name = "vimtex" },
|
||||||
-- { name = 'vsnip' }, -- For vsnip users.
|
-- { name = 'vsnip' }, -- For vsnip users.
|
||||||
-- { name = 'luasnip' }, -- For luasnip users.
|
-- { name = 'luasnip' }, -- For luasnip users.
|
||||||
{ name = 'ultisnips' }, -- For ultisnips users.
|
{ name = 'ultisnips' }, -- For ultisnips users.
|
||||||
-- { name = 'snippy' }, -- For snippy users.
|
-- { name = 'snippy' }, -- For snippy users.
|
||||||
}, {{ name = 'buffer' }}
|
}, { { name = 'buffer' } }
|
||||||
),
|
),
|
||||||
experimental = { ghost_text = true },
|
experimental = { ghost_text = true },
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Set configuration for specific filetype.
|
-- Set configuration for specific filetype.
|
||||||
cmp.setup.filetype('gitcommit', {
|
cmp.setup.filetype('gitcommit', {
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
|
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
|
||||||
}, {
|
}, {
|
||||||
|
@ -45,20 +45,20 @@ cmp.setup({
|
||||||
|
|
||||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||||
cmp.setup.cmdline({ '/', '?' }, {
|
cmp.setup.cmdline({ '/', '?' }, {
|
||||||
mapping = cmp.mapping.preset.cmdline(),
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'buffer' }
|
{ name = 'buffer' }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||||
cmp.setup.cmdline(':', {
|
cmp.setup.cmdline(':', {
|
||||||
mapping = cmp.mapping.preset.cmdline(),
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'path' }
|
{ name = 'path' }
|
||||||
}, {
|
}, {
|
||||||
{ name = 'cmdline' }
|
{ name = 'cmdline' }
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Insert `(` after select function or method item
|
-- Insert `(` after select function or method item
|
||||||
|
|
|
@ -34,7 +34,7 @@ require("lazy").setup({
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"hrsh7th/cmp-nvim-lsp",
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
"hrsh7th/cmp-buffer",
|
"hrsh7th/cmp-buffer",
|
||||||
"hrsh7th/cmp-omni", -- For LaTeX completion
|
"micangl/cmp-vimtex",
|
||||||
"hrsh7th/cmp-path",
|
"hrsh7th/cmp-path",
|
||||||
"hrsh7th/cmp-cmdline",
|
"hrsh7th/cmp-cmdline",
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue