From 1271a2558b97b588f4509162064fe97e230cf17f Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Tue, 6 Aug 2024 03:03:57 +0200 Subject: [PATCH 1/2] Moving autocmd into autocmd.lua --- lua/autocmd.lua | 18 ++++++++++++++++-- lua/keymaps.lua | 14 -------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lua/autocmd.lua b/lua/autocmd.lua index 897febb..d7dd70d 100644 --- a/lua/autocmd.lua +++ b/lua/autocmd.lua @@ -1,5 +1,6 @@ --- [[ Setting autocmd's ]] --- See `:help autocmd` +-- [[ Autocommands ]] +-- See `:help autocmd` +-- See `:help lua-guide-autocommands` -- Instantly move help window to the right -- This is almost certainly a hacky way to do this) @@ -7,3 +8,16 @@ vim.api.nvim_create_autocmd('FileType', { pattern = { 'help' }, command = 'wincmd L', }) + +-- Highlight when yanking (copying) text +-- Try it with `yap` in normal mode +-- See `:help vim.highlight.on_yank()` +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) + +-- vim: ts=2 sts=2 sw=2 et diff --git a/lua/keymaps.lua b/lua/keymaps.lua index adfa3c7..bcfc338 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -57,18 +57,4 @@ vim.keymap.set('v', '', 'MoveBlock(-1)') vim.keymap.set('v', '', 'MoveHBlock(-1)') vim.keymap.set('v', '', 'MoveHBlock(1)') --- [[ Basic Autocommands ]] --- See `:help lua-guide-autocommands` - --- Highlight when yanking (copying) text --- Try it with `yap` in normal mode --- See `:help vim.highlight.on_yank()` -vim.api.nvim_create_autocmd('TextYankPost', { - desc = 'Highlight when yanking (copying) text', - group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), - callback = function() - vim.highlight.on_yank() - end, -}) - -- vim: ts=2 sts=2 sw=2 et From 2f1c1aa3c15a23737b7fa32995f218f8b434ae32 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Tue, 6 Aug 2024 03:04:33 +0200 Subject: [PATCH 2/2] User command for cd %:h (:Cd) and python % (:Py) --- lua/autocmd.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/autocmd.lua b/lua/autocmd.lua index d7dd70d..322cfce 100644 --- a/lua/autocmd.lua +++ b/lua/autocmd.lua @@ -2,6 +2,10 @@ -- See `:help autocmd` -- See `:help lua-guide-autocommands` +-- These should be self-explanatory +vim.api.nvim_create_user_command('Cd', 'cd %:h', { desc = 'Change directory to the current file' }) +vim.api.nvim_create_user_command('Py', 'python %', { desc = 'Execute python file' }) + -- Instantly move help window to the right -- This is almost certainly a hacky way to do this) vim.api.nvim_create_autocmd('FileType', {