From 9b8c24ca6963bba06f54e84b11e80b7294732b91 Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Thu, 3 Aug 2023 02:49:25 +0200 Subject: [PATCH] move telescope config to a new module --- lua/config/init.lua | 1 + lua/config/telescope.lua | 19 +++++++++++++++++++ lua/keymappings.lua | 13 ++++--------- 3 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 lua/config/telescope.lua diff --git a/lua/config/init.lua b/lua/config/init.lua index 53a8971..960b7cc 100644 --- a/lua/config/init.lua +++ b/lua/config/init.lua @@ -1,3 +1,4 @@ -- nvim-compe require('config.compe') require('config.treesitter') +require('config.telescope') diff --git a/lua/config/telescope.lua b/lua/config/telescope.lua new file mode 100644 index 0000000..8cde6b1 --- /dev/null +++ b/lua/config/telescope.lua @@ -0,0 +1,19 @@ +local builtin = require('telescope.builtin') + +local find_files_workspace = function() + builtin.find_files({ + search_dirs = vim.lsp.buf.list_workspace_folders(), + prompt_prefix = "🔍", + }) +end +local live_grep_workspace = function() + builtin.live_grep({ + search_dirs = vim.lsp.buf.list_workspace_folders(), + }) +end + +vim.keymap.set('n', 'ff', find_files_workspace, {}) +vim.keymap.set('n', 'fg', live_grep_workspace, {}) +vim.keymap.set('n', 'fb', builtin.buffers, {}) +vim.keymap.set('n', 'fh', builtin.help_tags, {}) +vim.keymap.set('n', 'fl', builtin.git_files, {}) diff --git a/lua/keymappings.lua b/lua/keymappings.lua index e94a803..e6df730 100644 --- a/lua/keymappings.lua +++ b/lua/keymappings.lua @@ -1,20 +1,15 @@ local utils = require('utils') -utils.map('n', '', 'noh') -- Clear highlights +-- Clear highlights (search + trailing whitespace) +utils.map('n', '', 'noh') +utils.map("n", "", "let _s=@/:%s/\\s\\+$//e:let @/=_s") -- Use tab and shift+tab to cycle buffers utils.map("n", "", "bn") utils.map("n", "", "bp") --- Find files, buffers, grep in folder using Telescope command-line sugar. -utils.map("n", "ff", "Telescope find_files") -utils.map("n", "fg", "Telescope live_grep") -utils.map("n", "fb", "Telescope buffers") -utils.map("n", "fh", "Telescope help_tags") -utils.map("n", "fl", "Telescope git_files") -- Turn spellchecker on utils.map("n", "s", "setlocal spell spelllang=en_us") -utils.map("n", "", "let _s=@/:%s/\\s\\+$//e:let @/=_s") --- Toggles on different plugins/modes +-- Toggle line numbers and file tree utils.map("n", "", "set nonumber!") utils.map("n", "", "NvimTreeToggle")