Have DAPs work in way that allows being shadowed by nix-shell/direnv.

main
Joshua Potter 2023-11-22 06:11:41 -07:00
parent 85b82055d3
commit af9f2f6b10
11 changed files with 158 additions and 77 deletions

View File

@ -1,44 +1,59 @@
{ pkgs, ... }:
{ config, pkgs, lib, ... }:
{
options.home.extraPythonPackages = lib.mkOption {
type = lib.types.listOf lib.types.string;
example = ''
[ debugpy mccabe ]
'';
description = lib.mdDoc ''
Extra Python packages that should be linked to the topmost Python
interpreter.
'';
};
imports = [
./git.nix
./neovim
./wezterm
];
home = {
username = "jrpotter";
homeDirectory = "/home/jrpotter";
config = {
home = {
username = "jrpotter";
homeDirectory = "/home/jrpotter";
packages = with pkgs; [
anki-bin
bitwarden
elan
firefox
gnumake
mullvad-vpn
python3
unzip
wezterm
zotero
];
packages = with pkgs; [
anki-bin
bitwarden
clang
elan
firefox
gnumake
mullvad-vpn
(python3.withPackages
(ps: builtins.map (s: ps.${s}) config.home.extraPythonPackages))
unzip
wezterm
zotero
];
};
programs = {
bash.enable = true;
direnv.enable = true;
git.enable = true;
home-manager.enable = true;
neovim.enable = true;
};
# This value determines the Home Manager release that
# your configuration is compatible with. This helps avoid
# breakage when a new Home Manager release introduces
# backwards-incompatible changes.
#
# You can update Home Manager without changing this value.
# See the Home Manager release notes for a list of state
# version changes in each release.
home.stateVersion = "23.05";
};
programs = {
bash.enable = true;
direnv.enable = true;
git.enable = true;
home-manager.enable = true;
neovim.enable = true;
};
# This value determines the Home Manager release that
# your configuration is compatible with. This helps avoid
# breakage when a new Home Manager release introduces
# backwards-incompatible changes.
#
# You can update Home Manager without changing this value.
# See the Home Manager release notes for a list of state
# version changes in each release.
home.stateVersion = "23.05";
}

View File

@ -32,6 +32,7 @@ let
plugin = (pkgs.vimPlugins.nvim-treesitter.withPlugins (
ps: with ps; [
bash
c
elixir
lua
nix
@ -67,8 +68,19 @@ in
};
};
# Notice that within our imports we use `home.packages` instead of
# `extraPackages`. The latter is preferable but comes with `$PATH`-related
# problems.
#
# Specifically, Home Manager appends paths specifed in `extraPackages` to the
# end of `$PATH` meaning any already defined instance of some package will be
# used instead. Prepending is not an option either since that would break
# environments like those produced by `direnv` or `nix-shell`.
#
# https://github.com/nix-community/home-manager/pull/1756
imports = [
./lang/bash.nix
./lang/c.nix
./lang/elixir.nix
./lang/lean.nix
./lang/lua.nix

View File

@ -1,13 +1,13 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [
nodePackages.bash-language-server
shellcheck
];
programs.neovim = {
nvim-lspconfig = ''
require('init.lsp').setup(require('lspconfig').bashls) {}
'';
extraPackages = with pkgs; [
nodePackages.bash-language-server
shellcheck
];
};
}

View File

@ -0,0 +1,23 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [
clang-tools
vscode-extensions.vadimcn.vscode-lldb
];
programs.neovim = {
nvim-dap = ''
require('init.c').nvim_dap({
command = '${pkgs.vscode-extensions.vadimcn.vscode-lldb}/share/vscode/extensions/vadimcn.vscode-lldb/adapter/codelldb'
})
'';
nvim-lspconfig = ''
require('init.c').nvim_lspconfig()
'';
};
xdg.configFile."nvim/after/ftplugin/c.lua".text = ''
require('init.dap').buffer_map()
'';
}

View File

@ -1,14 +1,14 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [
elixir-ls
];
programs.neovim = {
nvim-lspconfig = ''
require('init.lsp').setup(require('lspconfig').elixirls) {
cmd = { 'elixir-ls' },
}
'';
extraPackages = with pkgs; [
elixir-ls
];
};
}

View File

@ -1,10 +1,12 @@
{ pkgs, ... }:
{
home.packages = with pkgs;[
lua-language-server
];
programs.neovim = {
nvim-lspconfig = ''
require('init.lua').nvim_lspconfig()
'';
extraPackages = [ pkgs.lua-language-server ];
};
}

View File

@ -1,10 +1,12 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [
nil
];
programs.neovim = {
nvim-lspconfig = ''
require('init.lsp').setup(require('lspconfig').nil_ls) {}
'';
extraPackages = [ pkgs.nil ];
};
}

View File

@ -1,15 +1,14 @@
{ pkgs, ... }:
let
venv = pkgs.python3.withPackages (ps: with ps; [
debugpy
mccabe
pycodestyle
pyflakes
python-lsp-server
python-lsp-black
]);
in
{ ... }:
{
home.extraPythonPackages = [
"debugpy"
"mccabe"
"pycodestyle"
"pyflakes"
"python-lsp-server"
"python-lsp-black"
];
programs.neovim = {
nvim-dap = ''
require('init.python').nvim_dap()
@ -18,8 +17,6 @@ in
nvim-lspconfig = ''
require('init.python').nvim_lspconfig()
'';
extraPackages = [ venv ];
};
xdg.configFile."nvim/after/ftplugin/python.lua".text = ''

View File

@ -1,13 +1,13 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [
nodePackages.typescript-language-server
];
programs.neovim = {
nvim-lspconfig = ''
require('init.lsp').setup(require('lspconfig').tsserver) {}
'';
extraPackages = with pkgs; [
nodePackages.typescript-language-server
];
};
}

View File

@ -0,0 +1,32 @@
local M = {}
function M.nvim_dap(options)
local dap = require('dap')
local key = 'codelldb'
dap.adapters[key] = {
type = 'server',
port = '${port}',
executable = {
command = options.command,
args = {'--port', '${port}'},
},
}
dap.configurations.c = dap.configurations.c or {}
table.insert(dap.configurations.c, {
name = 'Launch Executable',
type = key,
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}',
})
end
function M.nvim_lspconfig()
require('init.lsp').setup(require('lspconfig').clangd) {}
end
return M

View File

@ -2,23 +2,21 @@ local M = {}
function M.nvim_dap()
local dap = require('dap')
local key = 'debugpy'
dap.adapters.python = function(callback, config)
callback({
name = 'debugpy',
type = 'executable',
command = 'python3',
args = { '-m', 'debugpy.adapter' },
options = {
source_filetype = 'python',
},
})
end
dap.adapters[key] = {
type = 'executable',
command = 'python3',
args = { '-m', 'debugpy.adapter' },
options = {
source_filetype = 'python',
},
}
dap.configurations.python = dap.configurations.python or {}
table.insert(dap.configurations.python, {
name = 'Launch',
type = 'python',
name = 'Launch File',
type = key,
request = 'launch',
program = '${file}',
cwd = '${workspaceFolder}',