a bit of a refactor, new telescope mappings

This commit is contained in:
Vladan Popovic 2024-01-03 00:15:20 +01:00
parent 4496f44c49
commit 8437ec67c1
2 changed files with 26 additions and 29 deletions

View file

@ -4,20 +4,13 @@ local on_attach = function(client, bufnr)
utils.opt("o", "omnifunc", "v:lua.vim.lsp.omnifunc")
-- Mappings.
utils.map("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>")
utils.map("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>")
utils.map("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>")
utils.map("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>")
utils.map("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>")
utils.map("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>")
utils.map("n", "[d", "<cmd>lua vim.diagnostic.goto_prev()<CR>")
utils.map("n", "]d", "<cmd>lua vim.diagnostic.goto_next()<CR>")
utils.map("n", "[l", "<cmd>lua vim.diagnostic.show_line_diagnostics()<CR>")
utils.map("n", "]l", "<cmd>lua vim.diagnostic.set_loclist()<CR>")
utils.map("n", "<leader>a", "<cmd>lua vim.lsp.buf.code_action()<CR>")
utils.map("n", "<leader>c", "<cmd>lua vim.lsp.buf.code_action()<CR>")
utils.map("n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>")
utils.map("n", "<M-k>", "<cmd>lua vim.lsp.buf.type_definition()<CR>")
utils.map("n", "<M-r>", "<cmd>lua vim.lsp.buf.rename()()<CR>")
utils.map("n", "<M-t>", "<cmd>lua vim.lsp.buf.type_definition()<CR>")
-- list/add/remove workspace folders, not that I use them often
utils.map("n", "<leader>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>")

View file

@ -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 = { ["<c-f>"] = 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', '<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, {})
vim.keymap.set('n', '<leader>ff', builtin.find_files, {})
vim.keymap.set('n', '<leader>fg', builtin.git_files, {})
vim.keymap.set('n', '<leader>gg', builtin.live_grep, {})
vim.keymap.set('n', '<leader>bb', builtin.buffers, {})
vim.keymap.set('n', '<leader>hh', builtin.help_tags, {})
vim.keymap.set('n', '<leader>ss', builtin.lsp_dynamic_workspace_symbols, {})
vim.keymap.set('n', '<leader>sd', builtin.lsp_document_symbols, {})
vim.keymap.set('n', '<leader>dd', builtin.diagnostics, {})
vim.keymap.set('n', '<leader>gd', builtin.lsp_definitions, {})
vim.keymap.set('n', '<leader>gr', builtin.lsp_references, {})
vim.keymap.set('n', '<leader>gi', builtin.lsp_implementations, {})
vim.keymap.set('n', '<leader>ci', builtin.lsp_incoming_calls, {})
vim.keymap.set('n', '<leader>co', builtin.lsp_outgoing_calls, {})