From f603d40156edbec977c8d29e3a8abf248ede5339 Mon Sep 17 00:00:00 2001
From: Oliver Davies <oliver@oliverdavies.uk>
Date: Fri, 24 Feb 2023 09:40:43 +0000
Subject: [PATCH] feat(nvim): automatically find files

Run "nvim +GoToFile" to open Neovim and automatically open Telescope to
find the file that I need.

The idea was taken from @joshmedeski when he mentioned it in a podcast
with @nicknisi.

https://youtu.be/17o9QrCcF_o
https://github.com/joshmedeski/dotfiles/search?q=GoToFile
---
 config/neovim/lua/opdavies/telescope/mappings.lua | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/config/neovim/lua/opdavies/telescope/mappings.lua b/config/neovim/lua/opdavies/telescope/mappings.lua
index 44a5c7a0..865618c4 100644
--- a/config/neovim/lua/opdavies/telescope/mappings.lua
+++ b/config/neovim/lua/opdavies/telescope/mappings.lua
@@ -41,4 +41,12 @@ local nmap = require("opdavies.keymap").nmap
 nmap { "<leader>gm", telescope.extensions.git_worktree.create_git_worktree }
 nmap { "<leader>gw", telescope.extensions.git_worktree.git_worktrees }
 
+-- Create a command to open Telescope, can be used when starting nvim -
+-- "e.g. nvim +GoToFile".
+vim.api.nvim_create_user_command(
+  "GoToFile",
+  telescope.fd,
+  {}
+)
+
 return telescope_mapper