summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/user/autopairs.lua33
-rw-r--r--lua/user/plugins.lua1
-rw-r--r--lua/user/treesitter.lua3
3 files changed, 37 insertions, 0 deletions
diff --git a/lua/user/autopairs.lua b/lua/user/autopairs.lua
new file mode 100644
index 0000000..577e571
--- /dev/null
+++ b/lua/user/autopairs.lua
@@ -0,0 +1,33 @@
+-- Setup nvim-cmp.
+local status_ok, npairs = pcall(require, "nvim-autopairs")
+if not status_ok then
+ return
+end
+
+npairs.setup {
+ check_ts = true,
+ ts_config = {
+ lua = { "string", "source" },
+ javascript = { "string", "template_string" },
+ java = false,
+ },
+ disable_filetype = { "TelescopePrompt", "spectre_panel" },
+ fast_wrap = {
+ map = "<M-e>",
+ chars = { "{", "[", "(", '"', "'" },
+ pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""),
+ offset = 0, -- Offset from pattern match
+ end_key = "$",
+ keys = "qwertyuiopzxcvbnmasdfghjkl",
+ check_comma = true,
+ highlight = "PmenuSel",
+ highlight_grey = "LineNr",
+ },
+}
+
+local cmp_autopairs = require "nvim-autopairs.completion.cmp"
+local cmp_status_ok, cmp = pcall(require, "cmp")
+if not cmp_status_ok then
+ return
+end
+cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = { tex = "" } })
diff --git a/lua/user/plugins.lua b/lua/user/plugins.lua
index d16c0c4..65e808f 100644
--- a/lua/user/plugins.lua
+++ b/lua/user/plugins.lua
@@ -44,6 +44,7 @@ return packer.startup(function(use)
use "wbthomason/packer.nvim" -- Have packer manage itself
use "nvim-lua/popup.nvim" -- An implementation of the Popup API from vim in Neovim
use "nvim-lua/plenary.nvim" -- Useful lua functions used ny lots of plugins
+ use "windwp/nvim-autopairs" -- Autopairs, integrates with both cmp and treesitter
-- Colorschemes
use "lunarvim/colorschemes" -- A bunch of colorschemes you can try out
diff --git a/lua/user/treesitter.lua b/lua/user/treesitter.lua
index 7d45bd4..b840ccd 100644
--- a/lua/user/treesitter.lua
+++ b/lua/user/treesitter.lua
@@ -17,6 +17,9 @@ configs.setup {
ensure_installed = "maintained",
sync_install = false,
ignore_install = { "" }, -- List of parsers to ignore installing
+ autopairs = {
+ enable = true,
+ },
highlight = {
enable = true, -- false will disable the whole extension
disable = { "" }, -- list of language that will be disabled