Compare commits

...

2 Commits

Author SHA1 Message Date
8ad3a834ce
chore(keymaps): Streamline keymaps
- Change `<space>` to `<leader`
- Fix some capitalization
- Fix window resizing directions
2024-09-26 00:01:48 +02:00
db5a3f56b4
feat(dap): Added debugger from cpptools
Added:
  - OpenDebugAD7 from [vscode-cpptools](https://github.com/microsoft/vscode-cpptools)

It works better with `nvim-dap-ui`. With GDB you have to wait for stdout
flush to see program output, the output is in the repl instead of the
console, etc. The VSCode debugger doesn't have such issues.
2024-09-25 23:57:17 +02:00
4 changed files with 89 additions and 21 deletions

71
nix/cpptools.nix Normal file

@ -0,0 +1,71 @@
{ stdenv, lib
, system ? builtins.currentSystem
, fetchurl
, unzip
, libz
, libcxx
, lttng-ust_2_12
, autoPatchelfHook
}:
stdenv.mkDerivation rec {
pname = "cpptools";
version = "1.21.6";
# Get the current system architecture
# arch = builtins.currentSystem;
linux-x64 = "https://github.com/microsoft/vscode-cpptools/releases/download/v${version}/cpptools-linux-x64.vsix";
linux-arm64 = "https://github.com/microsoft/vscode-cpptools/releases/download/v${version}/cpptools-linux-arm64.vsix";
darwin-x64 = "https://github.com/microsoft/vscode-cpptools/releases/download/v${version}/cpptools-macos-x64.vsix";
darwin-arm64 = "https://github.com/microsoft/vscode-cpptools/releases/download/v${version}/cpptools-macos-arm64.vsix";
src = fetchurl {
url = lib.getAttr system {
x86_64-linux = "https://github.com/microsoft/vscode-cpptools/releases/download/v${version}/cpptools-linux-x64.vsix";
aarch64-linux = "https://github.com/microsoft/vscode-cpptools/releases/download/v${version}/cpptools-linux-arm64.vsix";
aarch64-darwin = "https://github.com/microsoft/vscode-cpptools/releases/download/v${version}/cpptools-macos-arm64.vsix";
x86_64-darwin = "https://github.com/microsoft/vscode-cpptools/releases/download/v${version}/cpptools-macos-x64.vsix";
};
hash = lib.getAttr system {
x86_64-linux = "sha256-q6SDImUppICJopOi+HiIUMg7Ue1Qu0A41uewNxRdzeA=";
aarch64-linux = "sha256-/Zci8P5RAK26FASHpQnIYR5fvSF9lgTTrgVAT33Wfwc=";
x86_64-darwin = "sha256-P2LacAaCRXnsGUQOLuIyvfgxweeVHsDFTrAEuN/lBIQ=";
aarch64-darwin = "sha256-P2LacAaCRXnsGUQOLuIyvfgxweeVHsDFTrAEuN/lBIQ=";
};
};
nativeBuildInputs = [
autoPatchelfHook
];
buildInputs = [
unzip
libz
libcxx
lttng-ust_2_12
];
unpackPhase = ''
unzip $src
'';
sourceRoot = ".";
installPhase = ''
runHook preInstall
mkdir -p $out/bin
mkdir -p $out/opt
cp -r extension/debugAdapters/* $out/opt
install -m755 -D extension/debugAdapters/bin/OpenDebugAD7 $out/opt/bin/OpenDebugAD7
ln -s $out/opt/bin/OpenDebugAD7 $out/bin/OpenDebugAD7
runHook postInstall
'';
meta = with lib; {
homepage = "https://github.com/microsoft/vscode-cpptools";
description = "Official repository for the Microsoft C/C++ extension for VS Code. ";
platforms = platforms.linux;
};
}

@ -120,6 +120,7 @@ with final.pkgs.lib; let
# language servers, etc. # language servers, etc.
asm-lsp # Assembly language server asm-lsp # Assembly language server
clang-tools # C/C++ language server clang-tools # C/C++ language server
(callPackage ./cpptools.nix {}) # C/C++ debugger from VSCode | https://github.com/microsoft/vscode-cpptools
nodePackages.bash-language-server # Bash language server nodePackages.bash-language-server # Bash language server
lua-language-server lua-language-server
nil # nix LSP nil # nix LSP

@ -35,20 +35,16 @@ dap.adapters.gdb = {
args = { "-i", "dap" } args = { "-i", "dap" }
} }
dap.adapters.cppdbg = {
id = 'cppdbg',
type = 'executable',
command = 'OpenDebugAD7',
}
dap.configurations.c = { dap.configurations.c = {
-- {
-- name = "Launch",
-- type = "gdb",
-- request = "launch",
-- program = function()
-- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
-- end,
-- cwd = "${workspaceFolder}",
-- stopAtBeginningOfMainSubprogram = false,
-- },
{ {
name = "Launch an executable", name = "Launch an executable",
type = "gdb", type = "cppdbg",
request = "launch", request = "launch",
cwd = "${workspaceFolder}", cwd = "${workspaceFolder}",
program = function() program = function()
@ -70,6 +66,6 @@ dap.configurations.c = {
:find() :find()
end) end)
end, end,
stopAtBeginningOfMainSubprogram = false, stopAtBeginningOfMainSubprogram = true,
}, },
} }

@ -21,20 +21,20 @@ require('which-key').add({
{ ']b', "<Cmd>BufferLineCycleNext<Cr>", desc = 'next [b]uffer' }, { ']b', "<Cmd>BufferLineCycleNext<Cr>", desc = 'next [b]uffer' },
{ '[B', vim.cmd.bfirst, desc = 'first [B]uffer' }, { '[B', vim.cmd.bfirst, desc = 'first [B]uffer' },
{ ']B', vim.cmd.blast, desc = 'last [B]uffer' }, { ']B', vim.cmd.blast, desc = 'last [B]uffer' },
{ '<space>tn', vim.cmd.tabnew, desc = '[t]ab: [n]ew' }, { '<leader>tn', vim.cmd.tabnew, desc = '[t]ab: [n]ew' },
{ '<leader>tq', "<Cmd>bd<Cr>", desc = '[t]ab: [q]uit/close' }, { '<leader>tq', "<Cmd>bd<Cr>", desc = '[t]ab: [q]uit/close' },
{ '<leader>c', "<Cmd>bd<Cr>", desc = '[c]lose tab' }, { '<leader>c', "<Cmd>bd<Cr>", desc = '[c]lose tab' },
-- Window resizing -- Window resizing
{ "<C-Up>", "<Cmd>resize +2<CR>", desc = "resize split up" }, { "<C-Up>", "<Cmd>resize -2<CR>", desc = "resize split up" },
{ "<C-Down>", "<Cmd>resize -2<CR>", desc = "resize split down" }, { "<C-Down>", "<Cmd>resize +2<CR>", desc = "resize split down" },
{ "<C-Left>", "<Cmd>vertical resize -2<CR>", desc = "resize split left" }, { "<C-Left>", "<Cmd>vertical resize +2<CR>", desc = "resize split left" },
{ "<C-Right>", "<Cmd>vertical resize +2<CR>", desc = "resize split right" }, { "<C-Right>", "<Cmd>vertical resize -2<CR>", desc = "resize split right" },
-- ToggleTerm -- ToggleTerm
{ "<Leader>Tf", "<Cmd>ToggleTerm direction=float<CR>", desc = "[T]oggleTerm [f]loat" }, { "<leader>Tf", "<Cmd>ToggleTerm direction=float<CR>", desc = "[T]oggleterm [f]loat" },
{ "<Leader>Th", "<Cmd>ToggleTerm size=10 direction=horizontal<CR>", desc = "[T]oggleTerm [h]orizontal split" }, { "<leader>Th", "<Cmd>ToggleTerm size=10 direction=horizontal<CR>", desc = "[T]oggleterm [h]orizontal split" },
{ "<Leader>Tv", "<Cmd>ToggleTerm size=80 direction=vertical<CR>", desc = "[T]oggleTerm [v]ertical split" }, { "<leader>Tv", "<Cmd>ToggleTerm size=80 direction=vertical<CR>", desc = "[T]oggleterm [v]ertical split" },
{ "<F7>", '<Cmd>execute v:count . "ToggleTerm"<CR>', desc = "Toggle terminal" }, { "<F7>", '<Cmd>execute v:count . "ToggleTerm"<CR>', desc = "Toggle terminal" },
{ mode = "t", "<F7>", "<Cmd>ToggleTerm<CR>", desc = "Toggle terminal" }, { mode = "t", "<F7>", "<Cmd>ToggleTerm<CR>", desc = "Toggle terminal" },
{ mode = "i", "<F7>", "<Esc><Cmd>ToggleTerm<CR>", desc = "Toggle terminal" }, { mode = "i", "<F7>", "<Esc><Cmd>ToggleTerm<CR>", desc = "Toggle terminal" },
@ -159,7 +159,7 @@ end, { expr = true, desc = "expand to current buffer's directory" })
local severity = diagnostic.severity local severity = diagnostic.severity
keymap.set('n', '<space>le', function() keymap.set('n', '<leader>le', function()
local _, winid = diagnostic.open_float(nil, { scope = 'line' }) local _, winid = diagnostic.open_float(nil, { scope = 'line' })
if not winid then if not winid then
vim.notify('no diagnostics found', vim.log.levels.INFO) vim.notify('no diagnostics found', vim.log.levels.INFO)