diff --git a/CHANGELOG.md b/CHANGELOG.md index e0b5b03..53057da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Instead of grouping changes by tag, they are grouped by the date they are releas ### Added * Add `prettier` as a formatter within Neovim. +* Automatically close brackets, parentheses and quotes. ## 17th December 2023 diff --git a/config/neovim/lua/opdavies/init.lua b/config/neovim/lua/opdavies/init.lua index 527f4ce..5cb3e1f 100644 --- a/config/neovim/lua/opdavies/init.lua +++ b/config/neovim/lua/opdavies/init.lua @@ -13,8 +13,26 @@ vim.api.nvim_create_user_command("GoToFile", function() require("opdavies.telescope").git_files() end, {}) -local map = require("opdavies.keymap").map +local imap = require("opdavies.keymap").imap +local nmap = require("opdavies.keymap").nmap +local xmap = require("opdavies.keymap").xmap -- Quicker macro playback. -map { "n", "Q", "@qj" } -map { "x", "Q", ":norm @q" } +nmap { "Q", "@qj" } +xmap { "Q", ":norm @q" } + +-- Automatically close brackets, parentheses and quotes. +imap { "'", "''" } +imap { "(", "()" } +imap { "/*", "/**/" } +imap { "<", "<>" } +imap { "[", "[]" } +imap { "[;", "[];" } +imap { "{", "{}" } +imap { "{;", "{};" } +imap { '\"', '\"\"' } + +-- TODO: only add these in Twig files? +imap { "{#", "{# #}" } +imap { "{%", "{% %}" } +imap { "{{", "{{ }}" }