diff --git a/lua/CopilotChat/init.lua b/lua/CopilotChat/init.lua index b6f2d0c..b04a9a3 100644 --- a/lua/CopilotChat/init.lua +++ b/lua/CopilotChat/init.lua @@ -1,15 +1,13 @@ --- Define a module table +local utils = require('CopilotChat.utils') + local M = {} -- Set up the plugin M.setup = function() - vim.notify( - "Please run ':UpdateRemotePlugins' and restart Neovim to use CopilotChat.nvim", - vim.log.levels.INFO, - { - title = 'CopilotChat.nvim', - } - ) + -- Add new command to explain the selected text with CopilotChat + utils.create_cmd('CChatExplain', function(opts) + vim.cmd('CChat Explain how it works') + end, { nargs = '*', range = true }) end return M diff --git a/lua/CopilotChat/utils.lua b/lua/CopilotChat/utils.lua new file mode 100644 index 0000000..bcae76e --- /dev/null +++ b/lua/CopilotChat/utils.lua @@ -0,0 +1,12 @@ +local M = {} + +--- Create custom command +---@param cmd string The command name +---@param func function The function to execute +---@param opt table The options +M.create_cmd = function(cmd, func, opt) + opt = vim.tbl_extend('force', { desc = 'CopilotChat.nvim ' .. cmd }, opt or {}) + vim.api.nvim_create_user_command(cmd, func, opt) +end + +return M