debug and problems

This commit is contained in:
Ali Can Zeybek
2026-02-08 12:54:03 +03:00
parent 5d208f102a
commit 412040b46d
12 changed files with 619 additions and 17 deletions

View File

@@ -0,0 +1,14 @@
require("cmake-tools").setup({
cmake_build_directory = "build",
cmake_generate_options = { "-DCMAKE_EXPORT_COMPILE_COMMANDS=1" },
cmake_build_options = {},
cmake_soft_link_compile_commands = true,
cmake_compile_commands_from_lsp = false,
cmake_dap_configuration = {
name = "cpp",
type = "codelldb",
request = "launch",
stopOnEntry = false,
runInTerminal = false,
},
})

View File

@@ -0,0 +1,34 @@
local conform = require("conform")
conform.setup({
formatters_by_ft = {
c = { "clang_format" },
cpp = { "clang_format" },
h = { "clang_format" },
hpp = { "clang_format" },
},
format_on_save = function(bufnr)
local ft = vim.bo[bufnr].filetype
local cpp_filetypes = {
c = true,
cpp = true,
h = true,
hpp = true,
}
if cpp_filetypes[ft] then
return {
timeout_ms = 1000,
lsp_format = "fallback",
}
end
end,
})
vim.api.nvim_create_user_command("Format", function()
conform.format({
async = false,
timeout_ms = 1000,
lsp_format = "fallback",
})
end, {})

113
lua/plugins/config/dap.lua Normal file
View File

@@ -0,0 +1,113 @@
local dap = require("dap")
local dapui = require("dapui")
local function resolve_codelldb()
local mason_codelldb = vim.fn.stdpath("data") .. "/mason/bin/codelldb"
if vim.fn.executable(mason_codelldb) == 1 then
return mason_codelldb
end
local system_codelldb = vim.fn.exepath("codelldb")
if system_codelldb ~= "" then
return system_codelldb
end
return "codelldb"
end
require("nvim-dap-virtual-text").setup({
commented = true,
})
dap.adapters.codelldb = {
type = "server",
port = "${port}",
executable = {
command = resolve_codelldb(),
args = { "--port", "${port}" },
},
}
dap.configurations.cpp = {
{
name = "Launch file",
type = "codelldb",
request = "launch",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/build/", "file")
end,
cwd = "${workspaceFolder}",
stopOnEntry = false,
args = function()
local input = vim.fn.input("Program args: ")
if input == "" then
return {}
end
return vim.split(input, " ")
end,
runInTerminal = false,
},
}
dap.configurations.c = dap.configurations.cpp
vim.fn.sign_define("DapBreakpoint", {
text = "",
texthl = "DiagnosticError",
linehl = "",
numhl = "",
})
vim.fn.sign_define("DapBreakpointCondition", {
text = "",
texthl = "DiagnosticWarn",
linehl = "",
numhl = "",
})
vim.fn.sign_define("DapLogPoint", {
text = "",
texthl = "DiagnosticInfo",
linehl = "",
numhl = "",
})
vim.fn.sign_define("DapStopped", {
text = "",
texthl = "DiagnosticOk",
linehl = "Visual",
numhl = "DiagnosticOk",
})
dapui.setup({
layouts = {
{
elements = {
{ id = "scopes", size = 0.30 },
{ id = "breakpoints", size = 0.20 },
{ id = "stacks", size = 0.25 },
{ id = "watches", size = 0.25 },
},
size = 45,
position = "left",
},
{
elements = {
{ id = "repl", size = 0.50 },
{ id = "console", size = 0.50 },
},
size = 12,
position = "bottom",
},
},
})
dap.listeners.after.event_initialized["dapui_config"] = function()
dapui.open()
end
dap.listeners.before.event_terminated["dapui_config"] = function()
dapui.close()
end
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close()
end
pcall(function()
require("telescope").load_extension("dap")
end)

View File

@@ -17,7 +17,7 @@ local on_attach = function(client, bufnr)
bufmap("n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>")
bufmap("n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>")
bufmap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>")
bufmap("n", "<leader>f", "<cmd>lua vim.lsp.buf.formatting()<CR>")
bufmap("n", "<leader>f", "<cmd>lua vim.lsp.buf.format()<CR>")
end
-- List of servers to setup
@@ -31,11 +31,17 @@ local servers = {
"texlab",
}
local server_overrides = {
clangd = {
cmd = { "clangd", "--clang-tidy" },
},
}
for _, server in ipairs(servers) do
vim.lsp.config(server, {
vim.lsp.config(server, vim.tbl_deep_extend("force", {
on_attach = on_attach,
capabilities = capabilities,
})
}, server_overrides[server] or {}))
-- Enable the server configuration
vim.lsp.enable(server)
end

View File

@@ -0,0 +1,14 @@
require("mason").setup()
require("mason-lspconfig").setup({
ensure_installed = {
"pyright",
"clangd",
"zls",
"lua_ls",
"vimls",
"marksman",
"texlab",
},
automatic_installation = true,
})

View File

@@ -1,9 +1,8 @@
require("nvim-tree").setup({
sort = { sorter = "case_sensitive" },
sort_by = "case_sensitive",
view = { width = 30 },
renderer = { group_empty = true },
filters = { dotfiles = true },
})
vim.keymap.set("n", "<C-n>", ":NvimTreeToggle<CR>", { noremap = true, silent = true })

View File

@@ -0,0 +1,11 @@
---@type opencode.Opts
vim.g.opencode_opts = {
-- Your configuration, if any.
}
-- Required for `opts.events.reload`.
vim.o.autoread = true
vim.keymap.set({ "n", "x" }, "<leader>oa", function()
require("opencode").ask("@this: ", { submit = true })
end, { desc = "Ask opencode with selection" })

View File

@@ -0,0 +1,3 @@
require("trouble").setup({
focus = false,
})

View File

@@ -0,0 +1,36 @@
local wk = require("which-key")
wk.setup({
plugins = {
presets = {
operators = false,
motions = false,
text_objects = false,
windows = false,
nav = false,
z = false,
g = false,
},
},
triggers = {
{ "<leader>", mode = { "n", "v" } },
},
})
if wk.add then
wk.add({
{ "<leader>c", group = "CMake" },
{ "<leader>d", group = "Debug" },
{ "<leader>f", group = "Find" },
{ "<leader>o", group = "OpenCode" },
{ "<leader>x", group = "Problems" },
})
else
wk.register({
c = { name = "+CMake" },
d = { name = "+Debug" },
f = { name = "+Find" },
o = { name = "+OpenCode" },
x = { name = "+Problems" },
}, { prefix = "<leader>" })
end

View File

@@ -40,8 +40,13 @@ return {
},
},
{
"williamboman/nvim-lsp-installer",
"williamboman/mason.nvim",
config = function()
require("plugins.config.mason")
end,
},
{
"williamboman/mason-lspconfig.nvim",
},
},
config = function()
@@ -63,10 +68,47 @@ return {
require("plugins.config.cmp")
end,
},
{
"stevearc/conform.nvim",
config = function()
require("plugins.config.conform")
end,
},
{
'nvim-telescope/telescope.nvim', tag = '0.1.8',
dependencies = { 'nvim-lua/plenary.nvim' }
},
{
"folke/trouble.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
require("plugins.config.trouble")
end,
},
{
"folke/which-key.nvim",
config = function()
require("plugins.config.whichkey")
end,
},
{
"mfussenegger/nvim-dap",
dependencies = {
"rcarriga/nvim-dap-ui",
"nvim-neotest/nvim-nio",
"theHamsta/nvim-dap-virtual-text",
"nvim-telescope/telescope-dap.nvim",
},
config = function()
require("plugins.config.dap")
end,
},
{
"Civitasv/cmake-tools.nvim",
config = function()
require("plugins.config.cmake")
end,
},
{
'nvimdev/indentmini.nvim',
config = function()
@@ -121,5 +163,16 @@ return {
}
end,
},
{
"nickjvandyke/opencode.nvim",
dependencies = {
-- Recommended for `ask()` and `select()`.
-- Required for `snacks` provider.
---@module 'snacks' <- Loads `snacks.nvim` types for configuration intellisense.
{ "folke/snacks.nvim", opts = { input = {}, picker = {}, terminal = {} } },
},
config = function()
require("plugins.config.opencode")
end,
}
}