Compare commits

...

2 commits

Author SHA1 Message Date
c2227b86a2
update keymaps 2025-05-16 21:03:22 +08:00
a6f234cc57
install debugger 2025-05-16 21:01:35 +08:00
12 changed files with 310 additions and 25 deletions

View file

@ -10,6 +10,12 @@
# Completion
./plugins/cmp/cmp.nix
# Debug Adapter Protocol
./plugins/dap/dap.nix
./plugins/dap/dap-ui.nix
./plugins/dap/dap-virtual-text.nix
./plugins/dap/dap-python.nix
# Editor plugins and configurations
./plugins/editor/buffers.nix
./plugins/editor/comment.nix

View file

@ -0,0 +1,53 @@
{ ... }: {
plugins.dap-python = {
enable = true;
};
keymaps = [
{
mode = ["n" "v"];
key = "<leader>dP";
action = "<NOP>";
options = {
silent = true;
desc = "+python";
};
}
{
mode = ["n"];
key = "<leader>dPm";
action = {
__raw = "require('dap-python').test_method";
};
options = {
silent = true;
desc = "Test method";
};
}
{
mode = ["n"];
key = "<leader>dPc";
action = {
__raw = "require('dap-python').test_class";
};
options = {
silent = true;
desc = "Test Class";
};
}
{
mode = ["v"];
key = "<leader>dPs";
action = {
__raw = "require('dap-python').debug_selection";
};
options = {
silent = true;
desc = "Debug selection";
};
}
];
}

View file

@ -0,0 +1,18 @@
{...}: {
plugins.dap-ui = {
enable = true;
};
keymaps = [
{
key = "<leader>du";
action = {
__raw = "require('dapui').toggle";
};
options = {
silent = true;
desc = "Toggle UI";
};
}
];
}

View file

@ -0,0 +1,5 @@
{ ... }: {
plugins.dap-virtual-text = {
enable = true;
};
}

143
config/plugins/dap/dap.nix Normal file
View file

@ -0,0 +1,143 @@
{...}: {
plugins.dap = {
enable = true;
};
keymaps = [
# Prefix: dap
{
mode = ["n" "v"];
key = "<leader>d";
action = "<NOP>";
options = {
silent = true;
desc = "+dap";
};
}
# Session management:
{
mode = ["n" "v"];
key = "<leader>dc";
action = "<cmd>DapContinue<cr>";
options = {
silent = true;
};
}
{
mode = ["n"];
key = "<leader>dd";
action = "<cmd>DapDisconnect<cr>";
options = {
silent = true;
};
}
{
mode = ["n"];
key = "<leader>dn";
action = "<cmd>DapNew<cr>";
options = {
silent = true;
};
}
{
mode = ["n"];
key = "<leader>dt";
action = "<cmd>DapTerminate<cr>";
options = {
silent = true;
};
}
# Stepping:
{
mode = ["n"];
key = "<leader>dr";
action = "<cmd>DapRestartFrame<cr>";
options = {
silent = true;
};
}
{
mode = ["n"];
key = "<leader>di";
action = "<cmd>DapStepInto<cr>";
options = {
silent = true;
};
}
{
mode = ["n"];
key = "<leader>dO";
action = "<cmd>DapStepOut<cr>";
options = {
silent = true;
};
}
{
mode = ["n"];
key = "<leader>do";
action = "<cmd>DapStepOver<cr>";
options = {
silent = true;
};
}
{
mode = ["n"];
key = "<leader>dp";
action = "<cmd>DapPause<cr>";
options = {
silent = true;
};
}
# Repl:
{
mode = ["n"];
key = "<leader>dE";
action = "<cmd>DapEval<cr>";
options = {
silent = true;
};
}
{
mode = ["n"];
key = "<leader>dR";
action = "<cmd>DapToggleRepl<cr>";
options = {
silent = true;
};
}
# Breakpoints:
{
mode = ["n"];
key = "<leader>dB";
action = "<cmd>DapClearBreakpoints<cr>";
options = {
silent = true;
};
}
{
mode = ["n"];
key = "<leader>db";
action = "<cmd>DapToggleBreakpoint<cr>";
options = {
silent = true;
};
}
];
}

View file

@ -17,7 +17,7 @@
{
# goto next buffer
mode = ["n"];
key = "<leader>bn";
key = "]b";
action = ":bnext<cr>";
options = {
silent = true;
@ -27,7 +27,7 @@
{
# goto previous buffer
mode = ["n"];
key = "<leader>bp";
key = "[b";
action = ":bprevious<cr>";
options = {
silent = true;

View file

@ -19,25 +19,23 @@
grammarPackages = pkgs.vimPlugins.nvim-treesitter.allGrammars;
};
# Refactor modules for nvim-treesitter
plugins.treesitter-refactor = {
enable = true;
# Highlights definitions and usages.
highlightDefinitions = {
enable = true;
};
# Provides "go to usage"
navigation = {
enable = true;
keymaps = {
gotoNextUsage = "<leader>n";
gotoPreviousUsage = "<leader>N";
};
};
smartRename = {
enable = true;
# Go to the next / previous usage.
keymaps = {
smartRename = "<leader>r";
gotoNextUsage = "]u";
gotoPreviousUsage = "[u";
};
};
};

View file

@ -6,7 +6,7 @@
keymaps = [
{
mode = "n";
key = "<leader>g<cr>";
key = "<leader>gL";
action = "<cmd>LazyGit<cr>";
options = {
desc = "Open LazyGit";
@ -16,7 +16,9 @@
{
mode = "n";
key = "<leader>glr";
action = "<cmd>lua require(\"telescope\").extensions.lazygit.lazygit()<cr>";
action = {
__raw = "require('telescope').extensions.lazygit.lazygit";
};
options = {
desc = "List repositories";
};

View file

@ -55,7 +55,7 @@
# Keymaps for conform.nvim
keymaps = [
{
mode = "";
mode = ["n"];
key = "<leader>F";
action.__raw = ''
function()

View file

@ -1,6 +1,7 @@
{...}: {
plugins.lsp = {
enable = true; # Enable neovim's built-in LSP.
inlayHints = true;
# Configure our language servers
servers = {
@ -53,7 +54,66 @@
gi = "implementation"; # Lists all the implementations¹
gt = "type_definition"; # Jumps to the definition of the type¹
# ¹ for the symbol under the cursor
# Renames all references to the symbol under the cursor.
"<leader>r" = {
action = "rename";
desc = "Rename";
};
};
# Extra keymaps to register when an LSP is attached
extra = [
{
mode = ["n"];
key = "<leader>l";
action = "<NOP>";
options = {
silent = true;
desc = "+lsp";
};
}
{
mode = ["n"];
key = "<leader>lc";
action = "<cmd>LspStop<cr>";
options = {
silent = true;
desc = "Stop server";
};
}
{
mode = ["n"];
key = "<leader>ls";
action = "<cmd>LspStart<cr>";
options = {
silent = true;
desc = "Start server";
};
}
{
mode = ["n"];
key = "<leader>lr";
action = "<cmd>LspRestart<cr>";
options = {
desc = "Restart server";
};
}
{
mode = ["n"];
key = "<leader>fd";
action = {
__raw = "require('telescope.builtin').lsp_definitions";
};
options = {
desc = "Find definitions";
};
}
];
};
};
}

View file

@ -26,6 +26,15 @@
};
keymaps = [
{
mode = ["n"];
key = "<leader>n";
action = "<cmd>NvimTreeToggle<cr>";
options = {
desc = "Toggle NvimTree";
};
}
{
mode = ["n"];
key = "<leader>e";

View file

@ -9,16 +9,7 @@
# Prefixes, No operation.
keymaps = [
{
mode = "n";
key = "<leader>s";
action = "<Nop>";
options = {
desc = "+search";
};
}
{
mode = "n";
mode = ["n" "v"];
key = "<leader>g";
action = "<Nop>";
options = {
@ -27,7 +18,7 @@
}
{
mode = "n";
mode = ["n"];
key = "<leader>gl";
action = "<Nop>";
options = {
@ -36,7 +27,7 @@
}
{
mode = "n";
mode = ["n"];
key = "<leader>gt";
action = "<Nop>";
options = {