lsp and dap fixes

This commit is contained in:
Christian Nieves
2024-03-20 20:57:57 +00:00
parent 14a4da6b6c
commit 7af5f17c9b
10 changed files with 101 additions and 89 deletions

View File

@ -82,17 +82,12 @@ function M.setup(capabilities)
end
local cider_lsp_handlers = {
["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
underline = true,
}),
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
focusable = false,
}),
}
cider_lsp_handlers["$/syncResponse"] = function(_, result, ctx)
-- is_cider_lsp_attached has been setup via on_init, but hasn't received
-- sync response yet.
local first_fire = vim.b["is_cider_lsp_attached"] == "no"
vim.b["is_cider_lsp_attached"] = "yes"
if first_fire then
@ -100,23 +95,9 @@ function M.setup(capabilities)
require("lualine").refresh()
end
end
cider_lsp_handlers["window/showMessage"] = function(_, result, ctx)
local client = vim.lsp.get_client_by_id(ctx.client_id)
local lvl = ({ "ERROR", "WARN", "INFO", "DEBUG" })[result.type]
vim.notify({ result.message }, lvl, {
title = "LSP | " .. client.name,
keep = function()
return lvl == "ERROR" or lvl == "WARN"
end,
})
end
capabilities = require("cmp_nvim_ciderlsp").update_capabilities(capabilities)
capabilities.workspace.codeLens = { refreshSupport = true }
capabilities.workspace.diagnostics = { refreshSupport = true }
lspconfig.ciderlsp.setup({
capabilities = capabilities,
capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()),
on_attach = cider_on_attach,
handlers = cider_lsp_handlers,
})

View File

@ -101,13 +101,11 @@ return {
sorting = {
comparators = {
-- compare.score_offset, -- not good at all
compare.priority,
compare.score, -- based on : score = score + ((#sources - (source_index - 1)) * sorting.priority_weight)
compare.locality,
compare.recently_used,
compare.offset,
compare.order,
-- compare.scopes, -- what?
-- compare.sort_text,
-- compare.exact,
compare.kind,
-- compare.length, -- useless
@ -126,7 +124,7 @@ return {
nerdfont = "󰊪 nerdfont",
nvim_ciderlsp = "󰚩 Cider",
analysislsp = "󰟌 analysislsp",
-- nvim_lsp_signature_help = "󰊕",
nvim_lsp_signature_help = "󰊕",
nvim_lsp = " LSP",
nvim_lua = " lua",
treesitter = "󰙅 ts",

View File

@ -3,6 +3,12 @@ return {
"mfussenegger/nvim-jdtls",
config = function() end,
},
{
"theHamsta/nvim-dap-virtual-text",
config = function()
require("nvim-dap-virtual-text").setup()
end,
},
{
"mfussenegger/nvim-dap",
dependencies = {
@ -28,8 +34,12 @@ return {
vim.fn.sign_define("DapBreakpointCondition", { text = "", texthl = "DiagnosticSignError" })
vim.fn.sign_define("DapBreakpointRejected", { text = "", texthl = "DiagnosticSignError" })
dap.adapters.java = {}
dap.adapters.cpp = {}
dap.adapters.cppdbg = {
id = "cppdbg",
type = "executable",
command = vim.fn.exepath("OpenDebugAD7"),
}
if use_google then
dap.adapters.lldb = {
type = "executable",
@ -51,6 +61,21 @@ return {
port = 6006,
}
dap.configurations.cppdbg = {
{
name = "Attach to gdbserver :5555",
type = "cppdbg",
request = "launch",
MIMode = "gdb",
miDebuggerServerAddress = "localhost:5555",
miDebuggerPath = vim.fn.exepath("gdb"),
cwd = "${workspaceFolder}",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
end,
},
}
dap.configurations.cpp = {
{
-- If you get an "Operation not permitted" error using this, try disabling YAMA:
@ -76,11 +101,9 @@ return {
mode = "remote",
name = "Attach Remote",
attachCommands = { "gdb-remote localhost:5555" },
-- hostName = "127.0.0.1",
-- port = 5555,
},
}
dap.configurations.c = dap.configurations.cpp
-- dap.configurations.c = dap.configurations.cpp
dap.configurations.java = {
{
@ -150,15 +173,17 @@ return {
})
local dapui = require("dapui")
vim.cmd("set mouse=n")
dapui.setup()
dap.listeners.after.event_initialized["dapui_config"] = function()
vim.cmd("set mouse=a")
dapui.open()
end
dap.listeners.before.event_terminated["dapui_config"] = function()
vim.cmd("set mouse=")
dapui.close()
end
dap.listeners.before.event_exited["dapui_config"] = function()
vim.cmd("set mouse=")
dapui.close()
end
end,

View File

@ -289,6 +289,7 @@ return {
{
name = "critique-nvim",
dir = "~/critique-nvim/",
lazy = false,
dependencies = {
"rktjmp/time-ago.vim",
"nvim-lua/plenary.nvim",

View File

@ -2,7 +2,7 @@ return {
{
"rcarriga/nvim-notify",
event = "VimEnter",
cond = false,
cond = true,
lazy = true,
config = function()
-- local colors = require("catppuccin.palettes").get_palette()
@ -19,7 +19,7 @@ return {
{
"j-hui/fidget.nvim",
event = "VimEnter",
cond = true,
cond = false,
opts = {
progress = {
display = {

View File

@ -9,8 +9,8 @@ _G.find_files = function()
end
-- Helper functions to fetch the current scope and set `search_dirs`
_G.find_dotfiles = function()
require("telescope.builtin").find_files({
search_dirs = { vim.fn.expand("$HOME/dotfiles") },
require("telescope.builtin").git_files({
cwd = vim.fn.expand("$HOME/dotfiles"),
})
end
@ -39,6 +39,9 @@ local keys = {
{ "<C-P>", ":lua find_files()<CR>", desc = "Find Files in CWD" },
{ "<leader>e", ":lua search_cwd()<CR>", desc = "Find Files in Buffer Directory" },
{ "<leader>tc", ":Telescope textcase<CR>", desc = "Text case" },
{ "<leader>t.", ":lua find_dotfiles()<CR>", desc = "Find Dotfiles" },
{ "<leader>tdc", ":Telescope dap commands" },
{ "<leader>tdc", ":Telescope dap configurations" },
{ "<leader>td", ":lua find_dotfiles()<CR>", desc = "Find Dotfiles" },
{ "<leader>tf", ":lua find_files()<CR>", desc = "Find Files in CWD" },
{ "<leader>tf.", ":lua vim.error('use <leader>e')<CR>", desc = "Find Files in Buffer Directory" },
@ -104,7 +107,10 @@ return {
},
{
"nvim-telescope/telescope.nvim",
dependencies = {},
dependencies = {
"mfussenegger/nvim-dap",
"rcarriga/nvim-dap-ui",
},
config = function()
require("telescope").setup({
defaults = {