configure LSP, codelens, and trouble
This commit is contained in:
+21
-17
@@ -46,9 +46,10 @@ create_cmd("TextYankPost", {
|
||||
create_cmd("FileType", {
|
||||
desc = "Disable list characters for some filetypes",
|
||||
group = create_group("cmd-disable-listchars", { clear = true }),
|
||||
pattern = { "netrw" },
|
||||
pattern = { "netrw", "trouble" },
|
||||
callback = function(args)
|
||||
vim.opt_local.list = false
|
||||
vim.opt.textwidth = 0
|
||||
end
|
||||
})
|
||||
|
||||
@@ -124,21 +125,24 @@ create_cmd("QuickFixCmdPost", {
|
||||
})
|
||||
|
||||
-- Automatically open diagnostic float when hovering with cursor
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
callback = function()
|
||||
if not vim.api.nvim_get_current_win() then return end
|
||||
vim.diagnostic.open_float(nil, { focus = false, scope = "cursor" })
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||
callback = function()
|
||||
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
||||
local config = vim.api.nvim_win_get_config(win)
|
||||
if config.relative ~= "" then
|
||||
vim.api.nvim_win_close(win, false)
|
||||
end
|
||||
end
|
||||
end,
|
||||
create_cmd("CursorHold", {
|
||||
desc = "Automatically open Diagnostic Float",
|
||||
group = create_group("cmd-auto-open-diagnostic-float", { clear = true }),
|
||||
callback = function()
|
||||
-- If any floating window exists, do nothing
|
||||
for _, win in ipairs(vim.api.nvim_list_wins()) do
|
||||
local cfg = vim.api.nvim_win_get_config(win)
|
||||
if cfg.relative ~= "" then
|
||||
return
|
||||
end
|
||||
end
|
||||
-- Only open if there is a diagnostic under cursor
|
||||
local diags = vim.diagnostic.get(0, { lnum = vim.fn.line('.') - 1 })
|
||||
if #diags == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
vim.diagnostic.open_float(nil, { focus = false, scope = "cursor" })
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
+13
-1
@@ -114,5 +114,17 @@ map("n", "grr", [[<Cmd>Trouble lsp_references toggle<CR>]], { desc = "Show LSP r
|
||||
map("n", "<leader>xq", [[<Cmd>Trouble qflist toggle focus=false<CR>]], { desc = "Show Quickfix List" })
|
||||
map("n", "<leader>xl", [[<Cmd>Trouble loclist toggle focus=false<CR>]], { desc = "Show Location List" })
|
||||
map("n", "grn", vim.lsp.buf.rename, { desc = "Rename", silent = true, noremap = true })
|
||||
map("n", "gra", vim.lsp.buf.code_action, { desc = "Action", silent = true, noremap = true })
|
||||
map({"n", "v"}, "gra", vim.lsp.buf.code_action, { desc = "Action", silent = true, noremap = true })
|
||||
map("n", "gl", vim.diagnostic.open_float, { desc = "Open Diagnostic Float" })
|
||||
map("n", "grx", vim.lsp.codelens.run, { desc = "Run Codelens Operation" })
|
||||
|
||||
-- Toggle Codelense
|
||||
vim.keymap.set("n", "<leader>tc", function()
|
||||
vim.g.codelens_enabled = not vim.g.codelens_enabled
|
||||
vim.lsp.codelens.enable(vim.g.codelens_enabled)
|
||||
end, { desc = "Toggle Code Lens" })
|
||||
|
||||
-- Open Signature Help
|
||||
vim.keymap.set("i", "<C-s>", function()
|
||||
vim.lsp.buf.signature_help()
|
||||
end, { desc = "Show signature help" })
|
||||
|
||||
+2
-2
@@ -50,12 +50,12 @@ vim.g.ui = {
|
||||
linebreak = "↘",
|
||||
windowborder = "single",
|
||||
popupborder = "single",
|
||||
custom_highlights = function(colors, utils)
|
||||
custom_highlights = function(colors, _)
|
||||
return {
|
||||
whitespace = { fg = colors.overlay0 },
|
||||
TrailingWhitespace = { fg = colors.red },
|
||||
LineNr = { fg = colors.overlay0 },
|
||||
CursorLineNR = { fg = colors.peach },
|
||||
CursorLineNr = { fg = colors.peach },
|
||||
}
|
||||
end,
|
||||
symbols = {
|
||||
|
||||
Reference in New Issue
Block a user