mirror of
https://github.com/fred-drake/neovim.git
synced 2026-06-05 14:59:28 -05:00
Added DAP and created dedicated configuration for Rust
This commit is contained in:
@@ -16,9 +16,15 @@ nix run .#
|
|||||||
Option 2: Run directly
|
Option 2: Run directly
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
nix run github:fred-drake/neovim#.
|
nix run github:fred-drake/neovim#
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Configurations
|
||||||
|
|
||||||
|
The default configuration performs editing without settings for any particular language or technology. The following configurations allow for CMP, LSP, Tree-Sitter and DAP in their respective language or technology stack:
|
||||||
|
|
||||||
|
- Rust `nix run github:fred-drake/neovim#rust`
|
||||||
|
|
||||||
## Things To Do
|
## Things To Do
|
||||||
|
|
||||||
- TODO: Implement DAP for debugging
|
- TODO: Implement DAP for debugging
|
||||||
|
|||||||
+200
-3
@@ -4,10 +4,207 @@
|
|||||||
dap = {
|
dap = {
|
||||||
enable = true;
|
enable = true;
|
||||||
extensions = {
|
extensions = {
|
||||||
dap-go.enable = true;
|
dap-ui = {
|
||||||
dap-python.enable = true;
|
enable = true;
|
||||||
dap-ui.enable = true;
|
floating.mappings = { close = [ "<ESC>" "q" ]; };
|
||||||
|
};
|
||||||
|
dap-virtual-text = { enable = true; };
|
||||||
|
};
|
||||||
|
signs = {
|
||||||
|
dapBreakpoint = {
|
||||||
|
text = "●";
|
||||||
|
texthl = "DapBreakpoint";
|
||||||
|
};
|
||||||
|
dapBreakpointCondition = {
|
||||||
|
text = "●";
|
||||||
|
texthl = "DapBreakpointCondition";
|
||||||
|
};
|
||||||
|
dapLogPoint = {
|
||||||
|
text = "◆";
|
||||||
|
texthl = "DapLogPoint";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
keymaps = [
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = "<leader>dB";
|
||||||
|
action =
|
||||||
|
"\n <cmd>lua require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: '))<cr>\n ";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Breakpoint Condition";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = "<leader>db";
|
||||||
|
action = ":DapToggleBreakpoint<cr>";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Toggle Breakpoint";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = "<leader>dc";
|
||||||
|
action = ":DapContinue<cr>";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Continue";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = "<leader>da";
|
||||||
|
action = "<cmd>lua require('dap').continue({ before = get_args })<cr>";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Run with Args";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = "<leader>dC";
|
||||||
|
action = "<cmd>lua require('dap').run_to_cursor()<cr>";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Run to cursor";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = "<leader>dg";
|
||||||
|
action = "<cmd>lua require('dap').goto_()<cr>";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Go to line (no execute)";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = "<leader>di";
|
||||||
|
action = ":DapStepInto<cr>";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Step into";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = "<leader>dj";
|
||||||
|
action = "\n <cmd>lua require('dap').down()<cr>\n ";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Down";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = "<leader>dk";
|
||||||
|
action = "<cmd>lua require('dap').up()<cr>";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Up";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = "<leader>dl";
|
||||||
|
action = "<cmd>lua require('dap').run_last()<cr>";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Run Last";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = "<leader>do";
|
||||||
|
action = ":DapStepOut<cr>";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Step Out";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = "<leader>dO";
|
||||||
|
action = ":DapStepOver<cr>";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Step Over";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = "<leader>dp";
|
||||||
|
action = "<cmd>lua require('dap').pause()<cr>";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Pause";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = "<leader>dr";
|
||||||
|
action = ":DapToggleRepl<cr>";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Toggle REPL";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = "<leader>ds";
|
||||||
|
action = "<cmd>lua require('dap').session()<cr>";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Session";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = "<leader>dt";
|
||||||
|
action = ":DapTerminate<cr>";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Terminate";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = "<leader>du";
|
||||||
|
action = "<cmd>lua require('dapui').toggle()<cr>";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Dap UI";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
key = "<leader>dw";
|
||||||
|
action = "<cmd>lua require('dap.ui.widgets').hover()<cr>";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Widgets";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
{
|
||||||
|
mode = [ "n" "v" ];
|
||||||
|
key = "<leader>de";
|
||||||
|
action = "<cmd>lua require('dapui').eval()<cr>";
|
||||||
|
options = {
|
||||||
|
silent = true;
|
||||||
|
desc = "Eval";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
extraConfigLua = ''
|
||||||
|
require('dap').listeners.after.event_initialized['dapui_config'] = require('dapui').open
|
||||||
|
require('dap').listeners.before.event_terminated['dapui_config'] = require('dapui').close
|
||||||
|
require('dap').listeners.before.event_exited['dapui_config'] = require('dapui').close
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,11 @@
|
|||||||
group = "SOPS";
|
group = "SOPS";
|
||||||
icon = "";
|
icon = "";
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
__unkeyed-1 = "<leader>d";
|
||||||
|
group = "Debug";
|
||||||
|
icon = "";
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -176,7 +176,6 @@ in { pkgs, ... }: {
|
|||||||
nix = [ "nixfmt" ];
|
nix = [ "nixfmt" ];
|
||||||
python = [ "black" ];
|
python = [ "black" ];
|
||||||
ruby = [ "rubyfmt" ];
|
ruby = [ "rubyfmt" ];
|
||||||
rust = [ "rustfmt" ];
|
|
||||||
terraform = [ "tofu_fmt" ];
|
terraform = [ "tofu_fmt" ];
|
||||||
tf = [ "tofu_fmt" ];
|
tf = [ "tofu_fmt" ];
|
||||||
typescript = [ "prettier" ];
|
typescript = [ "prettier" ];
|
||||||
@@ -243,11 +242,5 @@ in { pkgs, ... }: {
|
|||||||
omnisharp.enable = true;
|
omnisharp.enable = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
rustaceanvim = {
|
|
||||||
enable = true;
|
|
||||||
settings = { tools.enable_clippy = true; };
|
|
||||||
};
|
|
||||||
# rust-tools.enable = true;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
{ pkgs, ... }: {
|
||||||
|
plugins.dap = {
|
||||||
|
enable = true;
|
||||||
|
extensions = {
|
||||||
|
dap-ui.enable = true;
|
||||||
|
dap-virtual-text.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
adapters = {
|
||||||
|
executables = { lldb = { command = "${pkgs.lldb_19}/bin/lldb-dap"; }; };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
let
|
||||||
|
# Read all files in the current directory
|
||||||
|
files = builtins.readDir ./.;
|
||||||
|
|
||||||
|
# Filter out default.nix and non-.nix files
|
||||||
|
nixFiles = builtins.filter
|
||||||
|
(name: name != "default.nix" && builtins.match ".*\\.nix" name != null)
|
||||||
|
(builtins.attrNames files);
|
||||||
|
|
||||||
|
# Create a list of import statements
|
||||||
|
imports = map (name: ./. + "/${name}") nixFiles;
|
||||||
|
in {
|
||||||
|
# Import all configuration modules automatically
|
||||||
|
imports = imports;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
{ pkgs, ... }: {
|
||||||
|
plugins = {
|
||||||
|
conform-nvim = {
|
||||||
|
enable = true;
|
||||||
|
settings = { formatters_by_ft.rust = [ "rustfmt" ]; };
|
||||||
|
};
|
||||||
|
rustaceanvim = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
dap.adapter = {
|
||||||
|
command = "${pkgs.lldb_19}/bin/lldb-dap";
|
||||||
|
type = "executable";
|
||||||
|
};
|
||||||
|
tools.enable_clippy = true;
|
||||||
|
server = {
|
||||||
|
default_settings = {
|
||||||
|
inlayHints = { lifetimeElisionHints = { enable = "always"; }; };
|
||||||
|
rust-analyzer = {
|
||||||
|
cargo = { allFeatures = true; };
|
||||||
|
check = { command = "clippy"; };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,52 +1,56 @@
|
|||||||
{
|
{
|
||||||
description = "A nixvim configuration";
|
description = "A nixvim configuration";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
nixvim.url = "github:nix-community/nixvim";
|
nixvim.url = "github:nix-community/nixvim";
|
||||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { nixvim, flake-parts, rust-overlay, ... }@inputs:
|
outputs = { nixvim, flake-parts, rust-overlay, ... }@inputs:
|
||||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
systems =
|
systems =
|
||||||
[ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
[ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
||||||
|
|
||||||
perSystem = { system, ... }:
|
perSystem = { system, ... }:
|
||||||
let
|
let
|
||||||
overlays = [ (import rust-overlay) ];
|
overlays = [ (import rust-overlay) ];
|
||||||
nixvimLib = nixvim.lib.${system};
|
nixvimLib = nixvim.lib.${system};
|
||||||
nixvim' = nixvim.legacyPackages.${system};
|
nixvim' = nixvim.legacyPackages.${system};
|
||||||
nixvimModule = {
|
baseNixvimModule = {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
module = { pkgs, ... }: {
|
module = { pkgs, ... }: {
|
||||||
imports = [ ./config ];
|
imports = [ ./config ];
|
||||||
|
extraPackages = with pkgs; [ sops ];
|
||||||
|
};
|
||||||
|
extraSpecialArgs = { };
|
||||||
|
};
|
||||||
|
rustNixvimModule = {
|
||||||
|
inherit pkgs;
|
||||||
|
module = { pkgs, ... }: {
|
||||||
|
imports = [ ./config ./config/rust ];
|
||||||
extraPackages = with pkgs; [
|
extraPackages = with pkgs; [
|
||||||
sops
|
sops
|
||||||
rust-bin.stable.latest.default
|
rust-bin.stable.latest.default
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
# You can use `extraSpecialArgs` to pass additional arguments to your module files
|
extraSpecialArgs = { };
|
||||||
extraSpecialArgs = {
|
|
||||||
# inherit (inputs) foo;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
pkgs = import inputs.nixpkgs {
|
pkgs = import inputs.nixpkgs {
|
||||||
inherit system overlays;
|
inherit system overlays;
|
||||||
config.allowUnfree = true;
|
config.allowUnfree = true;
|
||||||
};
|
};
|
||||||
nvim = nixvim'.makeNixvimWithModule nixvimModule;
|
baseNvim = nixvim'.makeNixvimWithModule baseNixvimModule;
|
||||||
|
rustNvim = nixvim'.makeNixvimWithModule rustNixvimModule;
|
||||||
in {
|
in {
|
||||||
checks = {
|
checks = {
|
||||||
# Run `nix flake check .` to verify that your config is not broken
|
# Run `nix flake check .` to verify that your config is not broken
|
||||||
default =
|
default =
|
||||||
nixvimLib.check.mkTestDerivationFromNixvimModule nixvimModule;
|
nixvimLib.check.mkTestDerivationFromNixvimModule baseNixvimModule;
|
||||||
};
|
};
|
||||||
|
|
||||||
packages = {
|
packages = {
|
||||||
# Lets you run `nix run .` to start nixvim
|
# Lets you run `nix run .` to start nixvim
|
||||||
default = nvim;
|
default = baseNvim;
|
||||||
|
# Lets you run `nix run .#rust` to start nixvim with Rust configuration
|
||||||
|
rust = rustNvim;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user