From be7a52c6885048ed618f312070e55ab25bafb60d Mon Sep 17 00:00:00 2001 From: Jean-Pierre Appel Date: Mon, 15 Jan 2024 16:10:24 -0500 Subject: feat: bindings for quick fix, location list, and lsp diagnostics --- nvim/lua/keymap.lua | 11 ++++++++++- nvim/lua/plugins/telescope.lua | 18 +++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) (limited to 'nvim/lua') diff --git a/nvim/lua/keymap.lua b/nvim/lua/keymap.lua index 1e285c2..fbd4898 100644 --- a/nvim/lua/keymap.lua +++ b/nvim/lua/keymap.lua @@ -20,7 +20,16 @@ M.xnoremap = bind("x") M.inoremap = bind("i") M.nnoremap("gf", function() vim.cmd([[:e ]]) end) -M.nnoremap("qf", function() vim.cmd(':cope') end) +M.nnoremap("q", function() vim.cmd(':botright cope') end) +M.nnoremap("l", function() + local success, err_msg = pcall(function() + vim.cmd(':aboveleft lope') + end) + if not success then + err_msg = string.match(tostring(err_msg), "E%d+.*") + vim.api.nvim_err_writeln(err_msg) + end +end) M.nnoremap("ef", function() vim.cmd('Vexplore') end) diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua index 360994a..5d3cabc 100644 --- a/nvim/lua/plugins/telescope.lua +++ b/nvim/lua/plugins/telescope.lua @@ -10,15 +10,27 @@ return { end, desc = "Search for files (respcting .gitignore)" }, - {"fb", function() + {"fb", function() require("telescope.builtin").buffers() end }, - {"gf", function() + {"gf", function() require("telescope.builtin").live_grep() end }, - {"fr", function() + {"fq", function() + require("telescope.builtin").quickfix() + end + }, + {"fl", function() + require("telescope.builtin").loclist() + end + }, + {"fd", function() + require("telescope.builtin").diagnostics() + end + }, + {"fr", function() -- TODO: if lsp supports reference provider and lsp is attached -- [telescope.builtin.lsp_*]: server does not support referencesProvider if #vim.lsp.get_active_clients({bufnr = 0}) > 0 then -- cgit v1.2.3