move telescope config to a new module

This commit is contained in:
Vladan Popovic 2023-08-03 02:49:25 +02:00
parent f90c49b9e2
commit 9b8c24ca69
3 changed files with 24 additions and 9 deletions

View File

@ -1,3 +1,4 @@
-- nvim-compe
require('config.compe')
require('config.treesitter')
require('config.telescope')

19
lua/config/telescope.lua Normal file
View File

@ -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', '<leader>ff', find_files_workspace, {})
vim.keymap.set('n', '<leader>fg', live_grep_workspace, {})
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
vim.keymap.set('n', '<leader>fl', builtin.git_files, {})

View File

@ -1,20 +1,15 @@
local utils = require('utils')
utils.map('n', '<C-h>', '<cmd>noh<CR>') -- Clear highlights
-- Clear highlights (search + trailing whitespace)
utils.map('n', '<C-h>', '<cmd>noh<CR>')
utils.map("n", "<C-k>", "<cmd>let _s=@/<Bar>:%s/\\s\\+$//e<Bar>:let @/=_s<Bar><CR>")
-- Use tab and shift+tab to cycle buffers
utils.map("n", "<tab>", "<cmd>bn<cr>")
utils.map("n", "<S-tab>", "<cmd>bp<cr>")
-- Find files, buffers, grep in folder using Telescope command-line sugar.
utils.map("n", "<leader>ff", "<cmd>Telescope find_files<cr>")
utils.map("n", "<leader>fg", "<cmd>Telescope live_grep<cr>")
utils.map("n", "<leader>fb", "<cmd>Telescope buffers<cr>")
utils.map("n", "<leader>fh", "<cmd>Telescope help_tags<cr>")
utils.map("n", "<leader>fl", "<cmd>Telescope git_files<cr>")
-- Turn spellchecker on
utils.map("n", "<leader>s", "<cmd>setlocal spell spelllang=en_us<cr>")
utils.map("n", "<C-k>", "<cmd>let _s=@/<Bar>:%s/\\s\\+$//e<Bar>:let @/=_s<Bar><CR>")
-- Toggles on different plugins/modes
-- Toggle line numbers and file tree
utils.map("n", "<F3>", "<cmd>set nonumber!<CR>")
utils.map("n", "<F5>", "<cmd>NvimTreeToggle<CR>")