feat: add codelldb

This commit is contained in:
Fabio Lenherr / DashieTM 2022-12-07 08:34:22 +01:00
parent 14c9fc6498
commit 9aba78a4a3
6 changed files with 140 additions and 207 deletions

View file

@ -1,6 +1,6 @@
{ {
"trailingComma": "all", "trailingComma": "all",
"tabWidth": 2, "tabWidth": 4,
"semi": true, "semi": true,
"singleQuote": false "singleQuote": true
} }

View file

@ -1,126 +1,124 @@
local dap = require('dap') local dap = require("dap")
dap.adapters.cppdbg = { dap.adapters.codelldb = {
id = 'cppdbg', type = "server",
type = 'executable', port = "${port}",
command = '/home/dashie/.config/nvim/plugged/cpptools/extension/debugAdapters/bin/OpenDebugAD7', executable = {
-- CHANGE THIS to your path!
command = "/home/dashie/.local/share/nvim/mason/packages/codelldb/extension/adapter/codelldb",
args = { "--port", "${port}" },
},
}
local rust_dap = vim.fn.getcwd()
local filename = ""
for w in rust_dap:gmatch("([^/]+)") do filename = w end
dap.configurations.rust = {
{
type = "codelldb",
request = "launch",
program = function()
return rust_dap .. "/target/debug/" .. filename
end,
--program = '${fileDirname}/${fileBasenameNoExtension}',
cwd = "${workspaceFolder}",
stopOnEntry = true,
terminal = "integrated",
},
} }
dap.configurations.cpp = { dap.configurations.cpp = {
{ {
name = "Launch file", type = "codelldb",
type = "cppdbg", request = "launch",
request = "launch", program = function()
program = function() return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/build/", "file")
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/build/', 'file') end,
end, --program = '${fileDirname}/${fileBasenameNoExtension}',
cwd = '${workspaceFolder}', cwd = "${workspaceFolder}",
stopAtEntry = true, terminal = "integrated",
}, },
{
name = "Launch file --gui",
type = "cppdbg",
request = "launch",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/build/', 'file')
end,
args = {'--gui'},
cwd = '${workspaceFolder}',
stopAtEntry = true,
},
{
name = 'Attach to gdbserver :1234',
type = 'cppdbg',
request = 'launch',
MIMode = 'gdb',
miDebuggerServerAddress = 'localhost:1234',
miDebuggerPath = '/usr/bin/gdb',
cwd = '${workspaceFolder}',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/build/', 'file')
end,
},
} }
dap.configurations.c = dap.configurations.cpp dap.configurations.c = dap.configurations.cpp
dap.configurations.rust = dap.configurations.cpp
require("dapui").setup({ require("dapui").setup({
icons = { expanded = "", collapsed = "", current_frame = "" }, icons = { expanded = "", collapsed = "", current_frame = "" },
mappings = { mappings = {
-- Use a table to apply multiple mappings -- Use a table to apply multiple mappings
expand = { "<CR>", "<2-LeftMouse>" }, expand = { "<CR>", "<2-LeftMouse>" },
open = "o", open = "o",
remove = "d", remove = "d",
edit = "e", edit = "e",
repl = "r", repl = "r",
toggle = "t", toggle = "t",
}, },
-- Expand lines larger than the window -- Expand lines larger than the window
-- Requires >= 0.7 -- Requires >= 0.7
expand_lines = vim.fn.has("nvim-0.7") == 1, expand_lines = vim.fn.has("nvim-0.7") == 1,
-- Layouts define sections of the screen to place windows. -- Layouts define sections of the screen to place windows.
-- The position can be "left", "right", "top" or "bottom". -- The position can be "left", "right", "top" or "bottom".
-- The size specifies the height/width depending on position. It can be an Int -- The size specifies the height/width depending on position. It can be an Int
-- or a Float. Integer specifies height/width directly (i.e. 20 lines/columns) while -- or a Float. Integer specifies height/width directly (i.e. 20 lines/columns) while
-- Float value specifies percentage (i.e. 0.3 - 30% of available lines/columns) -- Float value specifies percentage (i.e. 0.3 - 30% of available lines/columns)
-- Elements are the elements shown in the layout (in order). -- Elements are the elements shown in the layout (in order).
-- Layouts are opened in order so that earlier layouts take priority in window sizing. -- Layouts are opened in order so that earlier layouts take priority in window sizing.
layouts = { layouts = {
{ {
elements = { elements = {
-- Elements can be strings or table with id and size keys. -- Elements can be strings or table with id and size keys.
{ id = "scopes", size = 0.25 }, { id = "scopes", size = 0.25 },
"breakpoints", "breakpoints",
"stacks", "stacks",
"watches", "watches",
}, },
size = 40, -- 40 columns size = 40, -- 40 columns
position = "left", position = "left",
}, },
{ {
elements = { elements = {
"repl", "repl",
"console", "console",
}, },
size = 0.25, -- 25% of total lines size = 0.25, -- 25% of total lines
position = "bottom", position = "bottom",
}, },
}, },
controls = { controls = {
-- Requires Neovim nightly (or 0.8 when released) -- Requires Neovim nightly (or 0.8 when released)
enabled = true, enabled = true,
-- Display controls in this element -- Display controls in this element
element = "repl", element = "repl",
icons = { icons = {
pause = "", pause = "",
play = "", play = "",
step_into = "", step_into = "",
step_over = "", step_over = "",
step_out = "", step_out = "",
step_back = "", step_back = "",
run_last = "", run_last = "",
terminate = "", terminate = "",
}, },
}, },
floating = { floating = {
max_height = nil, -- These can be integers or a float between 0 and 1. max_height = nil, -- These can be integers or a float between 0 and 1.
max_width = nil, -- Floats will be treated as percentage of your screen. max_width = nil, -- Floats will be treated as percentage of your screen.
border = "single", -- Border style. Can be "single", "double" or "rounded" border = "single", -- Border style. Can be "single", "double" or "rounded"
mappings = { mappings = {
close = { "q", "<Esc>" }, close = { "q", "<Esc>" },
}, },
}, },
windows = { indent = 1 }, windows = { indent = 1 },
render = { render = {
max_type_length = nil, -- Can be integer or nil. max_type_length = nil, -- Can be integer or nil.
max_value_lines = 100, -- Can be integer or nil. max_value_lines = 100, -- Can be integer or nil.
} },
}) })
require("mason-nvim-dap").setup({ require("mason-nvim-dap").setup({
ensure_installed = { "cpptools", ensure_installed = {
"bash-debug-adapter", "codelldb",
"firefox-debug-adapter", "bash-debug-adapter",
"js-debug-adapter", "firefox-debug-adapter",
"node-debug2-adapter" "js-debug-adapter",
} "node-debug2-adapter",
},
}) })

View file

@ -7,16 +7,15 @@ local keymap = vim.api.nvim_set_keymap
--vim.lsp.handlers["textDocument/codeAction"] = require'lspactions'.codeaction --vim.lsp.handlers["textDocument/codeAction"] = require'lspactions'.codeaction
--vim.cmd [[ nnoremap <leader>af :lua require'lspactions'.code_action()<CR> ]] --vim.cmd [[ nnoremap <leader>af :lua require'lspactions'.code_action()<CR> ]]
keymap("n", "<M-CR>", ":CodeActionMenu<CR>", opts) -- keymap("n", "<M-CR>", ":CodeActionMenu<CR>", opts)
keymap("n", "<C-f>", "<cmd>TroubleToggle<CR>", term_opts) keymap("n", "<C-f>", "<cmd>TroubleToggle<CR>", term_opts)
keymap("n", "<C-g>", ':lua require("vgit").buffer_hunk_preview()<CR>', opts)
--keymap("n", "<C-b>", ':lua require("vgit").buffer_stage()<CR>', opts) --keymap("n", "<C-b>", ':lua require("vgit").buffer_stage()<CR>', opts)
keymap("n", "<F5>", ':lua require("dap").toggle_breakpoint()<CR>', opts) keymap("n", "<F5>", ':lua require("dap").toggle_breakpoint()<CR>', opts)
keymap("n", "<F6>", ':lua require("dap").step_over()<CR>', opts) keymap("n", "<F6>", ':lua require("dap").step_over()<CR>', opts)
keymap("n", "<F7>", ':lua require("dap").step_into()<CR>', opts) keymap("n", "<F7>", ':lua require("dap").step_into()<CR>', opts)
keymap("n", "<F8>", ':lua require("dap").continue()<CR>', opts) keymap("n", "<F8>", ':lua require("dap").continue()<CR> :lua require("dapui").toggle()<CR>', opts)
keymap("n", "<F9>", ':lua require("dap").close()<CR> :lua require("dapui").toggle()<CR>', opts) keymap("n", "<F9>", ':lua require("dap").continue()<CR>', opts)
keymap("n", "<F10>", ':lua require("dap").continue()<CR> :lua require("dapui").toggle()<CR>', opts) keymap("n", "<F10>", ':lua require("dap").close()<CR> :lua require("dapui").toggle()<CR>', opts)
keymap("n", "t", ':lua require("nvim-tree").toggle()<CR>', opts) keymap("n", "t", ':lua require("nvim-tree").toggle()<CR>', opts)
keymap("n", "f", ':lua require("nvim-tree").focus()<CR>', opts) keymap("n", "f", ':lua require("nvim-tree").focus()<CR>', opts)

View file

@ -17,9 +17,8 @@ require("mason-lspconfig").setup({
ensure_installed = { ensure_installed = {
"cssls", -- css "cssls", -- css
"html", -- html "html", -- html
"eslint", -- latex
"clangd", -- cpp / c "clangd", -- cpp / c
--"tsserver", -- python "tsserver", -- python
"texlab", -- latex "texlab", -- latex
"sumneko_lua", -- lua "sumneko_lua", -- lua
"pyright", -- python "pyright", -- python
@ -28,86 +27,27 @@ require("mason-lspconfig").setup({
"cmake", -- cmake "cmake", -- cmake
"bashls", -- shell "bashls", -- shell
"ansiblels", -- ansible "ansiblels", -- ansible
"csharp_ls", -- dotnot "omnisharp", -- dotnot
"hls", -- haskel "hls", -- haskel
}, },
automatic_installation = true, automatic_installation = true,
}) })
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
require("lspconfig")["cssls"].setup({ local on_attach = function(client, bufnr)
capabilities = capabilities, -- Enable completion triggered by <c-x><c-o>
--on_attach = on_attach, vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
local opts = { noremap = true, silent = true, buffer=bufnr }
vim.keymap.set("n", "<C-k>", "<Cmd>lua vim.lsp.buf.hover()<CR>", opts)
vim.keymap.set("n", "<M-CR>", "<Cmd>lua vim.lsp.buf.code_action<CR>", opts)
end
require("mason-lspconfig").setup_handlers({
function(server_name) -- default handler (optional)
require("lspconfig")[server_name].setup({
capabilities = capabilities,
on_attach = on_attach,
})
end,
}) })
require("lspconfig")["html"].setup({
capabilities = capabilities,
--on_attach = on_attach,
})
require("lspconfig")["eslint"].setup({
capabilities = capabilities,
--on_attach = on_attach,
})
require("lspconfig")["clangd"].setup({
capabilities = capabilities,
--on_attach = on_attach,
})
--require("lspconfig")["tsserver"].setup({
-- capabilities = capabilities,
--on_attach = on_attach,
--})
require("lspconfig")["texlab"].setup({
capabilities = capabilities,
--on_attach = on_attach,
})
require("lspconfig")["sumneko_lua"].setup({
capabilities = capabilities,
--on_attach = on_attach,
})
require("lspconfig")["pyright"].setup({
capabilities = capabilities,
--on_attach = on_attach,
})
require("lspconfig")["rust_analyzer"].setup({
capabilities = capabilities,
--on_attach = on_attach,
})
require("lspconfig")["jdtls"].setup({
capabilities = capabilities,
--on_attach = on_attach,
})
require("lspconfig")["cmake"].setup({
capabilities = capabilities,
--on_attach = on_attach,
})
require("lspconfig")["bashls"].setup({
capabilities = capabilities,
--on_attach = on_attach,
})
require("lspconfig")["ansiblels"].setup({
capabilities = capabilities,
--on_attach = on_attach,
})
require("lspconfig")["csharp_ls"].setup({
capabilities = capabilities,
--on_attach = on_attach,
})
require("lspconfig")["hls"].setup({
capabilities = capabilities,
--on_attach = on_attach,
})

View file

@ -1,6 +1,6 @@
local options = { local options = {
clipboard = "unnamedplus", clipboard = "unnamedplus",
mouse = "a", mouse = "n",
fileencoding = "utf-8", fileencoding = "utf-8",
relativenumber = true, relativenumber = true,
cursorline = false, cursorline = false,

View file

@ -44,9 +44,5 @@ Plug("nvim-telescope/telescope-ui-select.nvim") -- telescope ui
Plug("nvim-telescope/telescope-file-browser.nvim") -- telescope file browser Plug("nvim-telescope/telescope-file-browser.nvim") -- telescope file browser
Plug("nvim-telescope/telescope-fzy-native.nvim") -- telescope fuzzy search Plug("nvim-telescope/telescope-fzy-native.nvim") -- telescope fuzzy search
Plug 'folke/trouble.nvim' -- provides warning/error explanation tab Plug 'folke/trouble.nvim' -- provides warning/error explanation tab
--Plug("folke/twilight.nvim") --twilight dims code not being edited right now ? useless ?
--Plug("lambdalisue/fern.vim") -- likely not needed?
--Plug("MarcWeber/vim-addon-mw-utils") -- wtf?
--Plug("tomtom/tlib_vim") --wtf2?
vim.call("plug#end") vim.call("plug#end")