From 8437ec67c141b6081b068f20724be67d6cc7dc5e Mon Sep 17 00:00:00 2001 From: Vladan Popovic Date: Wed, 3 Jan 2024 00:15:20 +0100 Subject: [PATCH] a bit of a refactor, new telescope mappings --- lua/lsp.lua | 11 ++-------- lua/plugins/telescope.lua | 44 +++++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/lua/lsp.lua b/lua/lsp.lua index 79e4823..10b45aa 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -4,20 +4,13 @@ local on_attach = function(client, bufnr) utils.opt("o", "omnifunc", "v:lua.vim.lsp.omnifunc") -- Mappings. - utils.map("n", "gD", "lua vim.lsp.buf.declaration()") - utils.map("n", "gd", "lua vim.lsp.buf.definition()") - utils.map("n", "gi", "lua vim.lsp.buf.implementation()") - utils.map("n", "gr", "lua vim.lsp.buf.references()") utils.map("n", "K", "lua vim.lsp.buf.hover()") utils.map("n", "", "lua vim.lsp.buf.signature_help()") - utils.map("n", "[d", "lua vim.diagnostic.goto_prev()") - utils.map("n", "]d", "lua vim.diagnostic.goto_next()") utils.map("n", "[l", "lua vim.diagnostic.show_line_diagnostics()") utils.map("n", "]l", "lua vim.diagnostic.set_loclist()") - utils.map("n", "a", "lua vim.lsp.buf.code_action()") - utils.map("n", "c", "lua vim.lsp.buf.code_action()") + utils.map("n", "ca", "lua vim.lsp.buf.code_action()") + utils.map("n", "", "lua vim.lsp.buf.type_definition()") utils.map("n", "", "lua vim.lsp.buf.rename()()") - utils.map("n", "", "lua vim.lsp.buf.type_definition()") -- list/add/remove workspace folders, not that I use them often utils.map("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))") diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index ada75cc..236f6c4 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,30 +1,34 @@ local telescope = require('telescope') +local actions = require('telescope.actions') local builtin = require('telescope.builtin') telescope.setup { defaults = { - vimgrep_arguments = { 'rg', - '--hidden', '--color=never', '--no-heading', + live_grep_arguments = { 'rg', + '--hidden', '--no-ignore', '--color=never', '--with-filename', '--line-number', - '--column', '--smart-case', + '--column', '--smart-case', '--no-heading', + }, + }, + pickers = { + live_grep = { + mappings = { + i = { [""] = actions.to_fuzzy_refine }, + }, }, }, } -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, {}) +vim.keymap.set('n', 'ff', builtin.find_files, {}) +vim.keymap.set('n', 'fg', builtin.git_files, {}) +vim.keymap.set('n', 'gg', builtin.live_grep, {}) +vim.keymap.set('n', 'bb', builtin.buffers, {}) +vim.keymap.set('n', 'hh', builtin.help_tags, {}) +vim.keymap.set('n', 'ss', builtin.lsp_dynamic_workspace_symbols, {}) +vim.keymap.set('n', 'sd', builtin.lsp_document_symbols, {}) +vim.keymap.set('n', 'dd', builtin.diagnostics, {}) +vim.keymap.set('n', 'gd', builtin.lsp_definitions, {}) +vim.keymap.set('n', 'gr', builtin.lsp_references, {}) +vim.keymap.set('n', 'gi', builtin.lsp_implementations, {}) +vim.keymap.set('n', 'ci', builtin.lsp_incoming_calls, {}) +vim.keymap.set('n', 'co', builtin.lsp_outgoing_calls, {})