From d31f42a76d3a4f02a9a3008a3bdb43f8fa18af45 Mon Sep 17 00:00:00 2001 From: Raj Sharma Date: Tue, 27 Aug 2024 20:26:51 +0530 Subject: [PATCH] feat: just better now --- lazy-lock.json | 26 +++--- lua/community.lua | 2 +- lua/lazy_setup.lua | 58 ++++++------ lua/plugins/astrocore.lua | 179 +++++++++++++++++++++++++------------- lua/plugins/harpoon.lua | 10 +++ lua/plugins/mason.lua | 1 + lua/plugins/user.lua | 146 +++++++++++++++---------------- lua/polish.lua | 17 ---- 8 files changed, 245 insertions(+), 194 deletions(-) create mode 100644 lua/plugins/harpoon.lua diff --git a/lazy-lock.json b/lazy-lock.json index 676b1dd..6e0355a 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,12 +1,12 @@ { - "AstroNvim": { "branch": "main", "commit": "42219c51e30843591ae62e27047d2a628612b38f" }, + "AstroNvim": { "branch": "main", "commit": "88065492801354330e2ccec245891230f865cce0" }, "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, - "aerial.nvim": { "branch": "master", "commit": "d5ba0e3cfede432cec7e6ab28724c4a554ea0f09" }, + "aerial.nvim": { "branch": "master", "commit": "e585934fef8d253dbc5655cff3deb3444e064e6c" }, "alpha-nvim": { "branch": "main", "commit": "b6f4129302db197a7249e67a90de3f2b676de13e" }, - "astrocommunity": { "branch": "main", "commit": "18978b14446256e68eae39b3c7770d15dfc025bd" }, - "astrocore": { "branch": "main", "commit": "8a66da8b8d4dfd783703195a6448aad75837d947" }, - "astrolsp": { "branch": "main", "commit": "e8290b739fa08c181a2149be5d94db0a91a42cd0" }, + "astrocommunity": { "branch": "main", "commit": "daeef59276dacf4e6903a5d32fec9f2854b0621b" }, + "astrocore": { "branch": "main", "commit": "928911605f98ead768d9fd56760ad782b31ef0c8" }, + "astrolsp": { "branch": "main", "commit": "5d92b868586c4b79298003b307e8dc3e9a357816" }, "astrotheme": { "branch": "main", "commit": "41b7d8430a55fd771e41bd763af4c3fd1c2fc0b5" }, "astroui": { "branch": "main", "commit": "0bc327c4a69f2e2b1a45449d5064d8e27e650d66" }, "better-escape.nvim": { "branch": "master", "commit": "f45b52f8f87792e8659526f23261ffe278a54be5" }, @@ -16,16 +16,17 @@ "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "conform.nvim": { "branch": "master", "commit": "62eba813b7501b39612146cbf29cd07f1d4ac29c" }, "copilot.lua": { "branch": "master", "commit": "86537b286f18783f8b67bccd78a4ef4345679625" }, "dressing.nvim": { "branch": "master", "commit": "71349f24c6e07b39f33600985843c289ca735308" }, "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, "gitsigns.nvim": { "branch": "main", "commit": "0b04035bb7b3c83e999b9676e2fb46fd0aa9f910" }, "guess-indent.nvim": { "branch": "main", "commit": "6cd61f7a600bb756e558627cd2e740302c58e32d" }, + "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" }, "heirline.nvim": { "branch": "master", "commit": "0d797435e54645a5f98bad7ad6046aac1ef95c1e" }, - "indent-blankline.nvim": { "branch": "master", "commit": "3fe94b8034dd5241cb882bb73847303b58857ecf" }, + "indent-blankline.nvim": { "branch": "master", "commit": "db926997af951da38e5004ec7b9fbdc480b48f5d" }, "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, "lazydev.nvim": { "branch": "main", "commit": "491452cf1ca6f029e90ad0d0368848fac717c6d2" }, + "lsp_signature.nvim": { "branch": "master", "commit": "a38da0a61c172bb59e34befc12efe48359884793" }, "lspkind.nvim": { "branch": "master", "commit": "cff4ae321a91ee3473a92ea1a8c637e3a9510aec" }, "luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "62360f061d45177dda8afc1b0fd1327328540301" }, @@ -34,26 +35,27 @@ "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, "mini.bufremove": { "branch": "main", "commit": "e6044aa28e61d4dd9ec86194d6f81743eced0c1c" }, "neo-tree.nvim": { "branch": "main", "commit": "8c75e8a2949cd6cd35525799200a8d34471ee9eb" }, - "neoconf.nvim": { "branch": "main", "commit": "30b4b1cfed6776778c70ae1b92c5be417e055774" }, + "neoconf.nvim": { "branch": "main", "commit": "39bf4e553d184ede39bda04baf902f9145c189cc" }, "neodev.nvim": { "branch": "main", "commit": "1f4ebcc10852518166ce165e57d425a4265a10d4" }, - "none-ls.nvim": { "branch": "main", "commit": "0d1b3fa2ad0b371b94cb4b9a27ba6e5a1a915c91" }, + "none-ls.nvim": { "branch": "main", "commit": "203f5ebde4a1af48ba2eb146401b5be2e7866942" }, "nui.nvim": { "branch": "main", "commit": "a0fd35fcbb4cb479366f1dc5f20145fd718a3733" }, "nvim-autopairs": { "branch": "master", "commit": "19606af7c039271d5aa96bceff101e7523af3136" }, "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, "nvim-colorizer.lua": { "branch": "master", "commit": "194ec600488f7c7229668d0e80bd197f3a2b84ff" }, "nvim-dap": { "branch": "master", "commit": "281a2e4cd1e7a17cea7ecb1745d84a8ab1249925" }, "nvim-dap-ui": { "branch": "master", "commit": "a5606bc5958db86f8d92803bea7400ee26a8d7e4" }, - "nvim-lspconfig": { "branch": "master", "commit": "dddd0945c0f31a0abd843425927a1712d2db2e10" }, + "nvim-lspconfig": { "branch": "master", "commit": "8a3610d29df83d8632f8ee7c3afc779c12725531" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, - "nvim-treesitter": { "branch": "master", "commit": "d5969c481e811958123f25c2c559cb7b4b6ca217" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "ced6375723b20616282f9f6a1018a63ae19b106a" }, + "nvim-treesitter": { "branch": "master", "commit": "7499f7379459db3b31c75cf5cec45f785be6e2c7" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "41e3abf6bfd9a9a681eb1f788bdeba91c9004b2b" }, "nvim-ts-autotag": { "branch": "main", "commit": "0cb76eea80e9c73b88880f0ca78fbd04c5bdcac7" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "375c2d86cee6674afd75b4f727ce3a80065552f7" }, "nvim-ufo": { "branch": "main", "commit": "a5390706f510d39951dd581f6d2a972741b3fa26" }, "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" }, "nvim-window-picker": { "branch": "main", "commit": "41cfaa428577c53552200a404ae9b3a0b5719706" }, "plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" }, + "presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, "promise-async": { "branch": "main", "commit": "38a4575da9497326badd3995e768b4ccf0bb153e" }, "resession.nvim": { "branch": "master", "commit": "cc819b0489938d03e4f3532a583354f0287c015b" }, "smart-splits.nvim": { "branch": "master", "commit": "1a2b268a7ec7aeef879cdd15973339010ec134f7" }, diff --git a/lua/community.lua b/lua/community.lua index 5b6fa62..3f0c02d 100644 --- a/lua/community.lua +++ b/lua/community.lua @@ -5,8 +5,8 @@ ---@type LazySpec return { "AstroNvim/astrocommunity", + { import = "astrocommunity.recipes.telescope-lsp-mappings" }, { import = "astrocommunity.pack.lua" }, - -- import/override with your plugins folder { import = "astrocommunity.completion.copilot-lua" }, { "copilot.lua", diff --git a/lua/lazy_setup.lua b/lua/lazy_setup.lua index 939d7b7..8814e38 100644 --- a/lua/lazy_setup.lua +++ b/lua/lazy_setup.lua @@ -1,32 +1,32 @@ require("lazy").setup({ - { - "AstroNvim/AstroNvim", - version = "^4", -- Remove version tracking to elect for nighly AstroNvim - import = "astronvim.plugins", - opts = { -- AstroNvim options must be set here with the `import` key - mapleader = " ", -- This ensures the leader key must be configured before Lazy is set up - maplocalleader = ",", -- This ensures the localleader key must be configured before Lazy is set up - icons_enabled = true, -- Set to false to disable icons (if no Nerd Font is available) - pin_plugins = nil, -- Default will pin plugins when tracking `version` of AstroNvim, set to true/false to override - update_notifications = true, -- Enable/disable notification about running `:Lazy update` twice to update pinned plugins - }, - }, - { import = "community" }, - { import = "plugins" }, + { + "AstroNvim/AstroNvim", + version = "^4", -- Remove version tracking to elect for nighly AstroNvim + import = "astronvim.plugins", + opts = { -- AstroNvim options must be set here with the `import` key + mapleader = " ", -- This ensures the leader key must be configured before Lazy is set up + maplocalleader = ",", -- This ensures the localleader key must be configured before Lazy is set up + icons_enabled = true, -- Set to false to disable icons (if no Nerd Font is available) + pin_plugins = nil, -- Default will pin plugins when tracking `version` of AstroNvim, set to true/false to override + update_notifications = true, -- Enable/disable notification about running `:Lazy update` twice to update pinned plugins + }, + }, + { import = "community" }, + { import = "plugins" }, } --[[@as LazySpec]], { - -- Configure any other `lazy.nvim` configuration options here - install = { colorscheme = { "astrotheme", "habamax" } }, - ui = { backdrop = 100 }, - performance = { - rtp = { - -- disable some rtp plugins, add more to your liking - disabled_plugins = { - "gzip", - "netrwPlugin", - "tarPlugin", - "tohtml", - "zipPlugin", - }, - }, - }, + -- Configure any other `lazy.nvim` configuration options here + install = { colorscheme = { "astrotheme", "catppuccin" } }, + ui = { backdrop = 100 }, + performance = { + rtp = { + -- disable some rtp plugins, add more to your liking + disabled_plugins = { + "gzip", + "netrwPlugin", + "tarPlugin", + "tohtml", + "zipPlugin", + }, + }, + }, } --[[@as LazyConfig]]) diff --git a/lua/plugins/astrocore.lua b/lua/plugins/astrocore.lua index ad0f5d6..a9623d9 100644 --- a/lua/plugins/astrocore.lua +++ b/lua/plugins/astrocore.lua @@ -3,66 +3,127 @@ ---@type LazySpec return { - "AstroNvim/astrocore", - ---@type AstroCoreOpts - opts = { - -- Configure core features of AstroNvim - features = { - large_buf = { size = 1024 * 256, lines = 10000 }, -- set global limits for large files for disabling features like treesitter - autopairs = true, -- enable autopairs at start - cmp = true, -- enable completion at start - diagnostics_mode = 3, -- diagnostic mode on start (0 = off, 1 = no signs/virtual text, 2 = no virtual text, 3 = on) - highlighturl = true, -- highlight URLs at start - notifications = true, -- enable notifications at start - }, - -- Diagnostics configuration (for vim.diagnostics.config({...})) when diagnostics are on - diagnostics = { - virtual_text = true, - underline = true, - }, - -- vim options can be configured here - options = { - opt = { -- vim.opt. - relativenumber = true, -- sets vim.opt.relativenumber - number = true, -- sets vim.opt.number - spell = false, -- sets vim.opt.spell - signcolumn = "yes", -- sets vim.opt.signcolumn to yes - wrap = false, -- sets vim.opt.wrap - }, - g = { -- vim.g. - -- configure global vim variables (vim.g) - -- NOTE: `mapleader` and `maplocalleader` must be set in the AstroNvim opts or before `lazy.setup` - -- This can be found in the `lua/lazy_setup.lua` file - }, - }, - -- Mappings can be configured through AstroCore as well. - -- NOTE: keycodes follow the casing in the vimdocs. For example, `` must be capitalized - mappings = { - -- first key is the mode - n = { - -- second key is the lefthand side of the map + "AstroNvim/astrocore", + ---@type AstroCoreOpts + opts = { + autocmds = { + restore_session = { + { + event = "VimEnter", + desc = "Restore previous directory session if neovim opened with no arguments", + nested = true, -- trigger other autocommands as buffers open + callback = function() + -- Only load the session if nvim was started with no args + if vim.fn.argc(-1) == 0 then + -- try to load a directory session using the current working directory + require("resession").load(vim.fn.getcwd(), { dir = "dirsession", silence_errors = true }) + end + end, + }, + }, + }, + -- Configure core features of AstroNvim + features = { + large_buf = { size = 1024 * 256, lines = 10000 }, -- set global limits for large files for disabling features like treesitter + autopairs = true, -- enable autopairs at start + cmp = true, -- enable completion at start + diagnostics_mode = 3, -- diagnostic mode on start (0 = off, 1 = no signs/virtual text, 2 = no virtual text, 3 = on) + highlighturl = true, -- highlight URLs at start + notifications = true, -- enable notifications at start + }, + -- Diagnostics configuration (for vim.diagnostics.config({...})) when diagnostics are on + diagnostics = { + virtual_text = true, + underline = true, + }, + -- vim options can be configured here + options = { + opt = { -- vim.opt. + relativenumber = true, -- sets vim.opt.relativenumber + scrolloff = 8, -- sets vim.opt.scrolloff + number = true, -- sets vim.opt.number + spell = false, -- sets vim.opt.spell + signcolumn = "yes", -- sets vim.opt.signcolumn to yes + wrap = false, -- sets vim.opt.wrap + }, + g = { -- vim.g. + -- configure global vim variables (vim.g) + -- NOTE: `mapleader` and `maplocalleader` must be set in the AstroNvim opts or before `lazy.setup` + -- This can be found in the `lua/lazy_setup.lua` file + }, + }, + sessions = { + -- Configure auto saving + autosave = { + last = true, -- auto save last session + cwd = true, -- auto save session for each working directory + }, + -- Patterns to ignore when saving sessions + ignore = { + dirs = {}, -- working directories to ignore sessions in + filetypes = { "gitcommit", "gitrebase" }, -- filetypes to ignore sessions + buftypes = {}, -- buffer types to ignore sessions + }, + }, + -- Mappings can be configured through AstroCore as well. + -- NOTE: keycodes follow the casing in the vimdocs. For example, `` must be capitalized + mappings = { + -- first key is the mode + n = { + -- second key is the lefthand side of the map - -- navigate buffer tabs - ["]b"] = { function() require("astrocore.buffer").nav(vim.v.count1) end, desc = "Next buffer" }, - ["[b"] = { function() require("astrocore.buffer").nav(-vim.v.count1) end, desc = "Previous buffer" }, + -- navigate buffer tabs + ["]b"] = { function() require("astrocore.buffer").nav(vim.v.count1) end, desc = "Next buffer" }, + ["[b"] = { function() require("astrocore.buffer").nav(-vim.v.count1) end, desc = "Previous buffer" }, - -- mappings seen under group name "Buffer" - ["bd"] = { - function() - require("astroui.status.heirline").buffer_picker( - function(bufnr) require("astrocore.buffer").close(bufnr) end - ) - end, - desc = "Close buffer from tabline", - }, + -- mappings seen under group name "Buffer" + ["bd"] = { + function() + require("astroui.status.heirline").buffer_picker( + function(bufnr) require("astrocore.buffer").close(bufnr) end + ) + end, + desc = "Close buffer from tabline", + }, + -- tables with just a `desc` key will be registered with which-key if it's installed + -- this is useful for naming menus + ["b"] = { desc = "Buffers" }, + -- Harpoon mappings + ["h"] = { desc = "Harpoon" }, + ["ha"] = { function() require("harpoon"):list():add() end, desc = "Add to Harpoon" }, + ["a"] = { function() require("harpoon"):list():add() end, desc = "Add to Harpoon" }, + ["d"] = { function() require("harpoon"):list():remove() end, desc = "Remove from Harpoon" }, + ["hc"] = { function() require("harpoon"):list():clear() end, desc = "Clear Harpoon" }, + ["hf"] = { + function() + -- require("harpoon").ui:toggle_quick_menu(require("harpoon"):list()) + local harpoon = require("harpoon") + -- basic telescope configuration + local conf = require("telescope.config").values + local function toggle_telescope(harpoon_files) + local file_paths = {} + for _, item in ipairs(harpoon_files.items) do + table.insert(file_paths, item.value) + end - -- tables with just a `desc` key will be registered with which-key if it's installed - -- this is useful for naming menus - ["b"] = { desc = "Buffers" }, - - -- setting a mapping to false will disable it - -- [""] = false, - }, - }, - }, + require("telescope.pickers") + .new({}, { + prompt_title = "Harpoon", + finder = require("telescope.finders").new_table({ + results = file_paths, + }), + previewer = conf.file_previewer({}), + sorter = conf.generic_sorter({}), + }) + :find() + end + toggle_telescope(harpoon:list()) + end, + desc = "Harpoon Quick Menu", + }, + [""] = { function() require("harpoon"):list():prev() end, desc = "Harpoon Previous File" }, + [""] = { function() require("harpoon"):list():next() end, desc = "Harpoon Next File" }, + }, + }, + }, } diff --git a/lua/plugins/harpoon.lua b/lua/plugins/harpoon.lua new file mode 100644 index 0000000..a2836e5 --- /dev/null +++ b/lua/plugins/harpoon.lua @@ -0,0 +1,10 @@ +---@type LazySpec +return { + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { "nvim-lua/plenary.nvim", "nvim-telescope/telescope.nvim" }, + config = function() + local harpoon = require("harpoon") + harpoon:setup({}) + end, +} diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua index 4090adb..4b62156 100644 --- a/lua/plugins/mason.lua +++ b/lua/plugins/mason.lua @@ -31,6 +31,7 @@ return { { "jay-babu/mason-nvim-dap.nvim", -- overrides `require("mason-nvim-dap").setup(...)` + enabled = false, opts = { ensure_installed = { "python", diff --git a/lua/plugins/user.lua b/lua/plugins/user.lua index 121089e..4ae3076 100644 --- a/lua/plugins/user.lua +++ b/lua/plugins/user.lua @@ -1,85 +1,79 @@ -if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE - --- You can also add or configure plugins by creating files in this `plugins/` folder --- Here are some examples: - ---@type LazySpec return { - -- == Examples of Adding Plugins == + "andweeb/presence.nvim", + { + "ray-x/lsp_signature.nvim", + event = "BufRead", + config = function() require("lsp_signature").setup() end, + }, - "andweeb/presence.nvim", - { - "ray-x/lsp_signature.nvim", - event = "BufRead", - config = function() require("lsp_signature").setup() end, - }, + -- == Examples of Overriding Plugins == - -- == Examples of Overriding Plugins == + -- customize alpha options + { + "goolord/alpha-nvim", + enabled = false, + opts = function(_, opts) + -- customize the dashboard header + opts.section.header.val = { + " █████ ███████ ████████ ██████ ██████", + "██ ██ ██ ██ ██ ██ ██ ██", + "███████ ███████ ██ ██████ ██ ██", + "██ ██ ██ ██ ██ ██ ██ ██", + "██ ██ ███████ ██ ██ ██ ██████", + " ", + " ███  ██ ██  ██ ██ ███  ███", + " ████  ██ ██  ██ ██ ████  ████", + " ██ ██  ██ ██  ██ ██ ██ ████ ██", + " ██  ██ ██  ██  ██  ██ ██  ██  ██", + " ██   ████   ████   ██ ██      ██", + } + return opts + end, + }, - -- customize alpha options - { - "goolord/alpha-nvim", - opts = function(_, opts) - -- customize the dashboard header - opts.section.header.val = { - " █████ ███████ ████████ ██████ ██████", - "██ ██ ██ ██ ██ ██ ██ ██", - "███████ ███████ ██ ██████ ██ ██", - "██ ██ ██ ██ ██ ██ ██ ██", - "██ ██ ███████ ██ ██ ██ ██████", - " ", - " ███  ██ ██  ██ ██ ███  ███", - " ████  ██ ██  ██ ██ ████  ████", - " ██ ██  ██ ██  ██ ██ ██ ████ ██", - " ██  ██ ██  ██  ██  ██ ██  ██  ██", - " ██   ████   ████   ██ ██      ██", - } - return opts - end, - }, + -- You can disable default plugins as follows: + -- { "max397574/better-escape.nvim", enabled = false }, - -- You can disable default plugins as follows: - { "max397574/better-escape.nvim", enabled = false }, + -- You can also easily customize additional setup of plugins that is outside of the plugin's setup call + { + "L3MON4D3/LuaSnip", + config = function(plugin, opts) + require("astronvim.plugins.configs.luasnip")(plugin, opts) -- include the default astronvim config that calls the setup call + -- add more custom luasnip configuration such as filetype extend or custom snippets + local luasnip = require("luasnip") + luasnip.filetype_extend("javascript", { "javascriptreact" }) + end, + }, - -- You can also easily customize additional setup of plugins that is outside of the plugin's setup call - { - "L3MON4D3/LuaSnip", - config = function(plugin, opts) - require "astronvim.plugins.configs.luasnip"(plugin, opts) -- include the default astronvim config that calls the setup call - -- add more custom luasnip configuration such as filetype extend or custom snippets - local luasnip = require "luasnip" - luasnip.filetype_extend("javascript", { "javascriptreact" }) - end, - }, - - { - "windwp/nvim-autopairs", - config = function(plugin, opts) - require "astronvim.plugins.configs.nvim-autopairs"(plugin, opts) -- include the default astronvim config that calls the setup call - -- add more custom autopairs configuration such as custom rules - local npairs = require "nvim-autopairs" - local Rule = require "nvim-autopairs.rule" - local cond = require "nvim-autopairs.conds" - npairs.add_rules( - { - Rule("$", "$", { "tex", "latex" }) - -- don't add a pair if the next character is % - :with_pair(cond.not_after_regex "%%") - -- don't add a pair if the previous character is xxx - :with_pair( - cond.not_before_regex("xxx", 3) - ) - -- don't move right when repeat character - :with_move(cond.none()) - -- don't delete if the next character is xx - :with_del(cond.not_after_regex "xx") - -- disable adding a newline when you press - :with_cr(cond.none()), - }, - -- disable for .vim files, but it work for another filetypes - Rule("a", "a", "-vim") - ) - end, - }, + { + "windwp/nvim-autopairs", + config = function(plugin, opts) + require("astronvim.plugins.configs.nvim-autopairs")(plugin, opts) -- include the default astronvim config that calls the setup call + -- add more custom autopairs configuration such as custom rules + local npairs = require("nvim-autopairs") + local Rule = require("nvim-autopairs.rule") + local cond = require("nvim-autopairs.conds") + npairs.add_rules( + { + Rule("$", "$", { "tex", "latex" }) + -- don't add a pair if the next character is % + :with_pair(cond.not_after_regex("%%")) + -- don't add a pair if the previous character is xxx + :with_pair( + cond.not_before_regex("xxx", 3) + ) + -- don't move right when repeat character + :with_move(cond.none()) + -- don't delete if the next character is xx + :with_del(cond.not_after_regex("xx")) + -- disable adding a newline when you press + :with_cr(cond.none()), + }, + -- disable for .vim files, but it work for another filetypes + Rule("a", "a", "-vim") + ) + end, + }, } diff --git a/lua/polish.lua b/lua/polish.lua index 64184a3..61587da 100644 --- a/lua/polish.lua +++ b/lua/polish.lua @@ -1,18 +1 @@ if true then return end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE - --- This will run last in the setup process and is a good place to configure --- things like custom filetypes. This just pure lua so anything that doesn't --- fit in the normal config locations above can go here - --- Set up custom filetypes -vim.filetype.add({ - extension = { - foo = "fooscript", - }, - filename = { - ["Foofile"] = "fooscript", - }, - pattern = { - ["~/%.config/foo/.*"] = "fooscript", - }, -})