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",
"tabWidth": 2,
"tabWidth": 4,
"semi": true,
"singleQuote": false
"singleQuote": true
}

View file

@ -1,126 +1,124 @@
local dap = require('dap')
dap.adapters.cppdbg = {
id = 'cppdbg',
type = 'executable',
command = '/home/dashie/.config/nvim/plugged/cpptools/extension/debugAdapters/bin/OpenDebugAD7',
local dap = require("dap")
dap.adapters.codelldb = {
type = "server",
port = "${port}",
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 = {
{
name = "Launch file",
type = "cppdbg",
request = "launch",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/build/', 'file')
end,
cwd = '${workspaceFolder}',
stopAtEntry = true,
},
{
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,
},
{
type = "codelldb",
request = "launch",
program = function()
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/build/", "file")
end,
--program = '${fileDirname}/${fileBasenameNoExtension}',
cwd = "${workspaceFolder}",
terminal = "integrated",
},
}
dap.configurations.c = dap.configurations.cpp
dap.configurations.rust = dap.configurations.cpp
require("dapui").setup({
icons = { expanded = "", collapsed = "", current_frame = "" },
mappings = {
-- Use a table to apply multiple mappings
expand = { "<CR>", "<2-LeftMouse>" },
open = "o",
remove = "d",
edit = "e",
repl = "r",
toggle = "t",
},
-- Expand lines larger than the window
-- Requires >= 0.7
expand_lines = vim.fn.has("nvim-0.7") == 1,
-- Layouts define sections of the screen to place windows.
-- The position can be "left", "right", "top" or "bottom".
-- 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
-- Float value specifies percentage (i.e. 0.3 - 30% of available lines/columns)
-- 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 = {
{
elements = {
-- Elements can be strings or table with id and size keys.
{ id = "scopes", size = 0.25 },
"breakpoints",
"stacks",
"watches",
},
size = 40, -- 40 columns
position = "left",
},
{
elements = {
"repl",
"console",
},
size = 0.25, -- 25% of total lines
position = "bottom",
},
},
controls = {
-- Requires Neovim nightly (or 0.8 when released)
enabled = true,
-- Display controls in this element
element = "repl",
icons = {
pause = "",
play = "",
step_into = "",
step_over = "",
step_out = "",
step_back = "",
run_last = "",
terminate = "",
},
},
floating = {
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.
border = "single", -- Border style. Can be "single", "double" or "rounded"
mappings = {
close = { "q", "<Esc>" },
},
},
windows = { indent = 1 },
render = {
max_type_length = nil, -- Can be integer or nil.
max_value_lines = 100, -- Can be integer or nil.
}
icons = { expanded = "", collapsed = "", current_frame = "" },
mappings = {
-- Use a table to apply multiple mappings
expand = { "<CR>", "<2-LeftMouse>" },
open = "o",
remove = "d",
edit = "e",
repl = "r",
toggle = "t",
},
-- Expand lines larger than the window
-- Requires >= 0.7
expand_lines = vim.fn.has("nvim-0.7") == 1,
-- Layouts define sections of the screen to place windows.
-- The position can be "left", "right", "top" or "bottom".
-- 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
-- Float value specifies percentage (i.e. 0.3 - 30% of available lines/columns)
-- 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 = {
{
elements = {
-- Elements can be strings or table with id and size keys.
{ id = "scopes", size = 0.25 },
"breakpoints",
"stacks",
"watches",
},
size = 40, -- 40 columns
position = "left",
},
{
elements = {
"repl",
"console",
},
size = 0.25, -- 25% of total lines
position = "bottom",
},
},
controls = {
-- Requires Neovim nightly (or 0.8 when released)
enabled = true,
-- Display controls in this element
element = "repl",
icons = {
pause = "",
play = "",
step_into = "",
step_over = "",
step_out = "",
step_back = "",
run_last = "",
terminate = "",
},
},
floating = {
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.
border = "single", -- Border style. Can be "single", "double" or "rounded"
mappings = {
close = { "q", "<Esc>" },
},
},
windows = { indent = 1 },
render = {
max_type_length = nil, -- Can be integer or nil.
max_value_lines = 100, -- Can be integer or nil.
},
})
require("mason-nvim-dap").setup({
ensure_installed = { "cpptools",
"bash-debug-adapter",
"firefox-debug-adapter",
"js-debug-adapter",
"node-debug2-adapter"
}
ensure_installed = {
"codelldb",
"bash-debug-adapter",
"firefox-debug-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.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-g>", ':lua require("vgit").buffer_hunk_preview()<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", "<F6>", ':lua require("dap").step_over()<CR>', opts)
keymap("n", "<F7>", ':lua require("dap").step_into()<CR>', opts)
keymap("n", "<F8>", ':lua require("dap").continue()<CR>', opts)
keymap("n", "<F9>", ':lua require("dap").close()<CR> :lua require("dapui").toggle()<CR>', opts)
keymap("n", "<F10>", ':lua require("dap").continue()<CR> :lua require("dapui").toggle()<CR>', opts)
keymap("n", "<F8>", ':lua require("dap").continue()<CR> :lua require("dapui").toggle()<CR>', opts)
keymap("n", "<F9>", ':lua require("dap").continue()<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", "f", ':lua require("nvim-tree").focus()<CR>', opts)

View file

@ -17,9 +17,8 @@ require("mason-lspconfig").setup({
ensure_installed = {
"cssls", -- css
"html", -- html
"eslint", -- latex
"clangd", -- cpp / c
--"tsserver", -- python
"tsserver", -- python
"texlab", -- latex
"sumneko_lua", -- lua
"pyright", -- python
@ -28,86 +27,27 @@ require("mason-lspconfig").setup({
"cmake", -- cmake
"bashls", -- shell
"ansiblels", -- ansible
"csharp_ls", -- dotnot
"omnisharp", -- dotnot
"hls", -- haskel
},
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({
capabilities = capabilities,
--on_attach = on_attach,
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
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 = {
clipboard = "unnamedplus",
mouse = "a",
mouse = "n",
fileencoding = "utf-8",
relativenumber = true,
cursorline = false,

View file

@ -17,7 +17,7 @@ Plug("mfussenegger/nvim-dap") -- debugging capabilities
Plug("rcarriga/nvim-dap-ui") -- debug ui
Plug("theHamsta/nvim-dap-virtual-text") -- more debug ui
Plug("jayp0521/mason-nvim-dap.nvim") -- debug mason bridge
Plug("nvim-treesitter/nvim-treesitter",
Plug("nvim-treesitter/nvim-treesitter",
{ ["do"] = vim.fn[":TSUpdate"] }) -- syntax colors
Plug("hrsh7th/nvim-cmp") -- completions
Plug("hrsh7th/cmp-nvim-lsp") -- lsp integration with completions
@ -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-fzy-native.nvim") -- telescope fuzzy search
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")