nixos-configs/homeManagerModules/neovim/langs/c-lang/default.nix

65 lines
1.6 KiB
Nix
Raw Normal View History

{
config,
lib,
pkgs,
...
}: let
2024-12-16 17:44:17 -05:00
inherit (lib) attrValues mkIf;
inherit (pkgs.writers) writeYAML;
cfg = config.programs.neovim;
in
mkIf cfg.enableIde {
xdg.configFile."clangd/config.yaml".source = writeYAML "config.yaml" {
CompileFlags.Add = ["-D__cpp_concepts=202002L"];
};
programs = {
neovim = {
2024-12-16 17:44:17 -05:00
extraPackages = attrValues {
inherit
(pkgs)
gcc
clang-tools
cmake-language-server
;
};
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
''
vim.api.nvim_create_autocmd('FileType', {
2024-12-16 17:44:17 -05:00
pattern = { 'cpp', 'c' },
command = 'setlocal ts=4 sw=4 sts=0 expandtab',
});
2024-05-11 15:33:38 -04:00
local lsp = require('lspconfig');
2024-12-16 17:44:17 -05:00
local default_capabilities = require('cmp_nvim_lsp').default_capabilities();
local clangd_extensions = require('clangd_extensions.inlay_hints');
2024-05-11 15:33:38 -04:00
lsp.cmake.setup({
2024-12-16 17:44:17 -05:00
capabilities = default_capabilities,
});
lsp.clangd.setup({
2024-12-16 17:44:17 -05:00
capabilities = default_capabilities,
2024-05-11 15:33:38 -04:00
handlers = require('lsp-status').extensions.clangd.setup(),
2024-12-16 17:44:17 -05:00
2024-05-11 15:33:38 -04:00
on_attach = function(_, bufnr)
2024-12-16 17:44:17 -05:00
clangd_extensions.setup_autocmd();
clangd_extensions.set_inlay_hints();
2024-05-11 15:33:38 -04:00
end,
});
2024-05-11 15:33:38 -04:00
'';
2024-12-16 17:44:17 -05:00
plugins = attrValues {
inherit
(pkgs.vimPlugins)
clangd_extensions-nvim
;
};
};
};
}