From 7b7fae9b91682991c4a51a6cbce8f3fe336a4f2b Mon Sep 17 00:00:00 2001 From: kyasuda Date: Wed, 3 Dec 2025 14:12:00 -0800 Subject: [PATCH] update --- .config/nvim/lua/core/keymaps.lua | 8 ++++++++ .../utils/functions/mkdir_under_cursor/init.lua | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.config/nvim/lua/core/keymaps.lua b/.config/nvim/lua/core/keymaps.lua index 0ee0c2c..8d05b12 100644 --- a/.config/nvim/lua/core/keymaps.lua +++ b/.config/nvim/lua/core/keymaps.lua @@ -436,6 +436,14 @@ local misc_utilities_mappings = { end, group = "mkdir under cursor", }, + { + mode = "v", + key = "m", + cmd = function() + mkdir_under_cursor() + end, + group = "mkdir selection", + }, } -- }}} diff --git a/.config/nvim/lua/utils/functions/mkdir_under_cursor/init.lua b/.config/nvim/lua/utils/functions/mkdir_under_cursor/init.lua index b2b3486..2bb6321 100644 --- a/.config/nvim/lua/utils/functions/mkdir_under_cursor/init.lua +++ b/.config/nvim/lua/utils/functions/mkdir_under_cursor/init.lua @@ -2,8 +2,20 @@ local M = {} vim.notify = require("notify") function M.mkdir_under_cursor() - -- Get the word under the cursor - local word = vim.fn.expand("") + local word + + -- Check if in visual mode + if vim.fn.mode():match("[vV]") then + -- Get visual selection + local start_pos = vim.fn.getpos("'<") + local end_pos = vim.fn.getpos("'>") + local line = vim.fn.getline(start_pos[2]) + word = line:sub(start_pos[3], end_pos[3]) + else + -- Get word under cursor + word = vim.fn.expand("") + end + -- Remove quotes if present word = word:gsub("^[\"']", ""):gsub("[\"']$", "") -- Check if directory exists