debug and problems
This commit is contained in:
14
lua/plugins/config/cmake.lua
Normal file
14
lua/plugins/config/cmake.lua
Normal 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,
|
||||
},
|
||||
})
|
||||
34
lua/plugins/config/conform.lua
Normal file
34
lua/plugins/config/conform.lua
Normal 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
113
lua/plugins/config/dap.lua
Normal 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)
|
||||
@@ -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
|
||||
|
||||
14
lua/plugins/config/mason.lua
Normal file
14
lua/plugins/config/mason.lua
Normal 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,
|
||||
})
|
||||
@@ -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 })
|
||||
|
||||
|
||||
11
lua/plugins/config/opencode.lua
Normal file
11
lua/plugins/config/opencode.lua
Normal 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" })
|
||||
3
lua/plugins/config/trouble.lua
Normal file
3
lua/plugins/config/trouble.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
require("trouble").setup({
|
||||
focus = false,
|
||||
})
|
||||
36
lua/plugins/config/whichkey.lua
Normal file
36
lua/plugins/config/whichkey.lua
Normal 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
|
||||
Reference in New Issue
Block a user