Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

languages (clang): add ccls.nvim #46

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
result
.config
lang-tests
.ccls-cache
17 changes: 17 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@
plugin-rust-tools.url = "github:simrat39/rust-tools.nvim";
plugin-rust-tools.flake = false;

# Not primary repo, waiting on PR
plugin-ccls-nvim.url = "github:MCGHH/ccls.nvim";
plugin-ccls-nvim.flake = false;

# Debugger
plugin-nvim-dap.url = "github:mfussenegger/nvim-dap";
plugin-nvim-dap.flake = false;
Expand Down
29 changes: 25 additions & 4 deletions modules/languages/clang.nix
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ in
type = with types; nullOr str;
default = null;
};
cclsNvim = {
enable = mkOption {
description = "Enable support for extra ccls extensions through ccls.nvim";
default = cfg.lsp.server == "ccls";
defaultText = nvim.nmd.literalAsciiDoc ''`config.vim.languages.clang.lsp.server == "ccls"`'';
};
};
};
};

Expand All @@ -78,10 +85,24 @@ in
vim.treesitter.grammars = [ cfg.treesitter.cPackage cfg.treesitter.cppPackage ];
})

(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
(mkIf cfg.lsp.enable (mkMerge [
{
vim.lsp.lspconfig.enable = true;
vim.lsp.lspconfig.sources.clang-lsp = servers.${cfg.lsp.server}.lspConfig;
}

vim.lsp.lspconfig.sources.clang-lsp = servers.${cfg.lsp.server}.lspConfig;
})
(mkIf cfg.lsp.cclsNvim.enable {
assertions = [{
assertion = cfg.lsp.server == "ccls";
message = "To enable cclsNvim, lsp must be enabled and set to ccls";
}];

vim.startPlugins = [ "ccls-nvim" ];

vim.luaConfigRC.ccls-nvim = nvim.dag.entryAnywhere ''
require("ccls").setup({})
'';
})
]))
]);
}