From bbafc099977587010ee3e233dcec2937a00b0894 Mon Sep 17 00:00:00 2001 From: jaredgoldman Date: Sun, 7 Apr 2024 17:41:50 -0400 Subject: [PATCH] feat: add autopairs --- init.lua | 5 +++-- lazy-lock.json | 2 +- lua/config/lualine.lua | 7 +++++-- lua/config/pairs.lua | 21 +++++++++++++++++++++ lua/plugins.lua | 10 +++++++++- requirements.md | 4 ++-- 6 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 lua/config/pairs.lua diff --git a/init.lua b/init.lua index f566feb..d71d184 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,6 @@ -require("colorscheme") -require("options") require("plugins") +require("options") +require("colorscheme") require("lsp") require("config.telescope") require("config.comment") @@ -11,4 +11,5 @@ require("config.theme") require("config.lualine") require("config.fterm") require("config.harpoon") +require("config.pairs") require("keymaps") diff --git a/lazy-lock.json b/lazy-lock.json index 0d840c3..f4158f6 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -6,7 +6,7 @@ "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "copilot.vim": { "branch": "release", "commit": "49e0348bfb913fae63ca5ddb987a8bccd193da86" }, + "copilot.vim": { "branch": "release", "commit": "7097b09e52621a97d11f254e04de5e5a0f26e5f5" }, "harpoon": { "branch": "harpoon2", "commit": "da326d0438ac68dee9b6b62a734be940a8bd8405" }, "lazy.nvim": { "branch": "main", "commit": "31ddbea7c10b6920c9077b66c97951ca8682d5c8" }, "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, diff --git a/lua/config/lualine.lua b/lua/config/lualine.lua index 4414826..dd90b16 100644 --- a/lua/config/lualine.lua +++ b/lua/config/lualine.lua @@ -1,8 +1,11 @@ -- local base16 = require'lualine.themes.base16' -local ayu_dark = require'lualine.themes.ayu_dark' +-- local ayu_dark = require'lualine.themes.ayu_dark' +-- local base16 = require'lualine.themes.base16' +-- local codedark = require'lualine.themes.codedark' +local horizon = require'lualine.themes.horizon' -- Change the background of lualine_c section for normal mode require('lualine').setup { - options = { theme = ayu_dark }, + options = { theme = horizon}, } diff --git a/lua/config/pairs.lua b/lua/config/pairs.lua new file mode 100644 index 0000000..d162c0e --- /dev/null +++ b/lua/config/pairs.lua @@ -0,0 +1,21 @@ +local npairs = require("nvim-autopairs") +local Rule = require('nvim-autopairs.rule') +local ts_conds = require('nvim-autopairs.ts-conds') + +npairs.setup({ + check_ts = true, + ts_config = { + lua = {'string'},-- it will not add a pair on that treesitter node + javascript = {'template_string'}, + java = false,-- don't check treesitter on java + } +}) + + +-- press % => %% only while inside a comment or string +npairs.add_rules({ + Rule("%", "%", "lua") + :with_pair(ts_conds.is_ts_node({'string','comment'})), + Rule("$", "$", "lua") + :with_pair(ts_conds.is_not_ts_node({'function'})) +}) diff --git a/lua/plugins.lua b/lua/plugins.lua index d8e354a..3a11f5c 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -64,5 +64,13 @@ require("lazy").setup({ "ThePrimeagen/harpoon", branch = "harpoon2", requires = { { "nvim-lua/plenary.nvim" } } - } + }, + { + 'windwp/nvim-autopairs', + event = "InsertEnter", + config = true + -- use opts = {} for passing setup options + -- this is equalent to setup({}) function + }, + 'nvim-treesitter/nvim-treesitter' }) diff --git a/requirements.md b/requirements.md index 8e297b7..10efeb4 100644 --- a/requirements.md +++ b/requirements.md @@ -4,9 +4,9 @@ - telescope x - theming x - tabfluline x - - rice + - rice x - terminal x -- harpoon +- harpoon x - extended history x - auto-pairs - lua vim linting