summaryrefslogtreecommitdiff
path: root/lua/maps/find.lua
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-11-10 20:42:28 +0100
committerHampusM <hampus@hampusmat.com>2024-11-10 20:42:28 +0100
commitad4fd93993f7f5fc5d6298e517716bc2bd280fe7 (patch)
treed3269ab40e3138b56b185715191c036dc35f14bb /lua/maps/find.lua
parentbb05c664d78796b7d26969ccfd3bea6cc9131b03 (diff)
add window checks in telescope keymap functionsHEADmaster
Diffstat (limited to 'lua/maps/find.lua')
-rw-r--r--lua/maps/find.lua29
1 files changed, 28 insertions, 1 deletions
diff --git a/lua/maps/find.lua b/lua/maps/find.lua
index 9d10a51..27a7fec 100644
--- a/lua/maps/find.lua
+++ b/lua/maps/find.lua
@@ -1,10 +1,20 @@
local utility_misc = require("utility.misc")
vim.keymap.set("n", "<leader>p", function()
+ if vim.fn.win_gettype() ~= "" or vim.fn.win_getid() == vim.g.term_win then
+ -- Window is not a normal window or is a terminal window
+ return
+ end
+
require("telescope.builtin").find_files()
end)
vim.keymap.set("n", "<leader>b", function ()
+ if vim.fn.win_gettype() ~= "" or vim.fn.win_getid() == vim.g.term_win then
+ -- Window is not a normal window or is a terminal window
+ return
+ end
+
require("telescope.builtin").buffers()
end)
@@ -21,15 +31,32 @@ vim.keymap.set("n", "<leader>gcl", function()
end)
vim.keymap.set("n", "<leader>f", function()
+ if vim.fn.win_gettype() ~= "" or vim.fn.win_getid() == vim.g.term_win then
+ -- Window is not a normal window or is a terminal window
+ return
+ end
+
require("telescope.builtin").live_grep()
end)
vim.keymap.set("n", "<leader>e", function()
+ if vim.fn.win_gettype() ~= "" or vim.fn.win_getid() == vim.g.term_win then
+ -- Window is not a normal window or is a terminal window
+ return
+ end
+
require("telescope").extensions.file_browser.file_browser()
end)
vim.keymap.set("n", "<leader>E", function()
+ if vim.fn.win_gettype() ~= "" or vim.fn.win_getid() == vim.g.term_win then
+ -- Window is not a normal window or is a terminal window
+ return
+ end
+
local curr_buf_dir = utility_misc.dir_name(vim.api.nvim_buf_get_name(0))
- require("telescope").extensions.file_browser.file_browser({ path = curr_buf_dir })
+ require("telescope").extensions.file_browser.file_browser({
+ path = curr_buf_dir
+ })
end)