2024-05-07 22:49:00 -04:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
2024-11-22 02:48:41 -05:00
|
|
|
pkgs,
|
2024-05-07 22:49:00 -04:00
|
|
|
...
|
|
|
|
}: let
|
2024-12-21 22:30:38 -05:00
|
|
|
inherit (lib) mkIf;
|
2024-12-08 00:19:59 -05:00
|
|
|
inherit (pkgs.writers) writeYAML;
|
2024-11-22 02:48:41 -05:00
|
|
|
|
|
|
|
cfg = config.programs.neovim;
|
2024-12-22 03:12:45 -05:00
|
|
|
flakeEnv = config.programs.bash.sessionVariables.FLAKE;
|
2024-12-21 22:30:38 -05:00
|
|
|
in {
|
2024-12-21 23:34:10 -05:00
|
|
|
config = mkIf cfg.enable {
|
2024-12-08 00:19:59 -05:00
|
|
|
xdg.configFile."clangd/config.yaml".source = writeYAML "config.yaml" {
|
|
|
|
CompileFlags.Add = ["-D__cpp_concepts=202002L"];
|
|
|
|
};
|
|
|
|
|
2024-05-07 22:49:00 -04:00
|
|
|
programs = {
|
|
|
|
neovim = {
|
2024-05-11 15:33:38 -04:00
|
|
|
extraLuaConfig =
|
2024-06-09 22:49:30 -04:00
|
|
|
# lua
|
2024-05-11 15:33:38 -04:00
|
|
|
''
|
2024-06-24 11:33:02 -04:00
|
|
|
vim.api.nvim_create_autocmd('FileType', {
|
2024-12-16 17:44:17 -05:00
|
|
|
pattern = { 'cpp', 'c' },
|
2024-12-22 03:12:45 -05:00
|
|
|
|
|
|
|
callback = function()
|
|
|
|
vim.cmd[[setlocal ts=4 sw=4 sts=0 expandtab]];
|
|
|
|
|
|
|
|
if (devShells['c-lang'] == nil) then
|
|
|
|
devShells['c-lang'] = 1;
|
|
|
|
|
2024-12-22 12:53:27 -05:00
|
|
|
require('nix-develop').nix_develop({'${flakeEnv}#c-lang'}, function()
|
2024-12-22 12:42:29 -05:00
|
|
|
vim.cmd[[LspStart]];
|
2024-12-22 12:53:27 -05:00
|
|
|
end);
|
2024-12-22 03:12:45 -05:00
|
|
|
end
|
|
|
|
end,
|
2024-06-24 11:33:02 -04:00
|
|
|
});
|
2024-05-11 15:33:38 -04:00
|
|
|
'';
|
|
|
|
|
2024-12-21 22:30:38 -05:00
|
|
|
plugins = [
|
|
|
|
{
|
|
|
|
plugin = pkgs.vimPlugins.clangd_extensions-nvim;
|
|
|
|
type = "lua";
|
|
|
|
config =
|
|
|
|
# lua
|
|
|
|
''
|
|
|
|
local lsp = require('lspconfig');
|
|
|
|
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
|
|
|
|
|
|
|
|
local clangd_extensions = require('clangd_extensions.inlay_hints');
|
|
|
|
|
|
|
|
lsp.cmake.setup({
|
|
|
|
capabilities = default_capabilities,
|
2024-12-22 03:12:45 -05:00
|
|
|
autostart = false,
|
2024-12-21 22:30:38 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
lsp.clangd.setup({
|
|
|
|
capabilities = default_capabilities,
|
2024-12-22 03:12:45 -05:00
|
|
|
autostart = false,
|
2024-12-21 22:30:38 -05:00
|
|
|
|
|
|
|
handlers = require('lsp-status').extensions.clangd.setup(),
|
|
|
|
|
|
|
|
on_attach = function(_, bufnr)
|
|
|
|
clangd_extensions.setup_autocmd();
|
|
|
|
clangd_extensions.set_inlay_hints();
|
|
|
|
end,
|
|
|
|
});
|
|
|
|
'';
|
|
|
|
}
|
|
|
|
];
|
2024-05-07 22:49:00 -04:00
|
|
|
};
|
|
|
|
};
|
2024-12-21 22:30:38 -05:00
|
|
|
};
|
2024-12-21 23:34:10 -05:00
|
|
|
|
|
|
|
# For accurate stack trace
|
|
|
|
_file = ./default.nix;
|
2024-12-21 22:30:38 -05:00
|
|
|
}
|