Skip to content

Commit

Permalink
Added autopairs
Browse files Browse the repository at this point in the history
  • Loading branch information
liul85 committed Aug 5, 2022
1 parent 1b52c2b commit 91d28a3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ require "alpha-nvim"
require "rust"
require "fzf"
require "treesitter"
require "autopairs"
33 changes: 33 additions & 0 deletions lua/autopairs.lua
Original file line number Diff line number Diff line change
@@ -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 = "" } })
3 changes: 3 additions & 0 deletions lua/plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ return packer.startup(function(use)

-- Treesitter interface
use 'nvim-treesitter/nvim-treesitter'

-- autopairs
use "windwp/nvim-autopairs"
-- Automatically set up your configuration after cloning packer.nvim
-- Put this at the end after all plugins
if PACKER_BOOTSTRAP then
Expand Down
3 changes: 3 additions & 0 deletions lua/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ nvim_treesitter.setup {
-- `false` will disable the whole extension
enable = true,
},
autopairs = {
enable = true,
},
}

0 comments on commit 91d28a3

Please sign in to comment.