mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-04-15 00:58:37 +00:00
languages/clang: fix options; improve option docs
Some checks failed
Check for typos in the source tree / check-typos (push) Has been cancelled
Some checks failed
Check for typos in the source tree / check-typos (push) Has been cancelled
This commit is contained in:
parent
355d517293
commit
c670c27350
1 changed files with 17 additions and 18 deletions
|
@ -7,12 +7,13 @@
|
|||
inherit (builtins) attrNames;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.types) bool enum package either listOf str nullOr;
|
||||
inherit (lib.types) bool enum package either listOf str;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.nvim.lua) expToLua toLuaObject;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
inherit (lib.nvim.languages) lspOptions;
|
||||
|
||||
inherit (lib.nvim.dag) entryAfter;
|
||||
|
||||
cfg = config.vim.languages.clang;
|
||||
|
@ -26,14 +27,6 @@
|
|||
servers = {
|
||||
ccls = {
|
||||
package = pkgs.ccls;
|
||||
lspConfig = ''
|
||||
lspconfig.ccls.setup{
|
||||
capabilities = capabilities;
|
||||
on_attach=default_on_attach;
|
||||
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.opts}"}
|
||||
}
|
||||
'';
|
||||
|
||||
options = {
|
||||
capabilities = mkLuaInline "capabilities";
|
||||
on_attach = mkLuaInline "default_on_attach";
|
||||
|
@ -66,7 +59,6 @@
|
|||
if isList cfg.lsp.package
|
||||
then expToLua cfg.lsp.package
|
||||
else ["${packageToCmd cfg.lsp.package "clangd"}"];
|
||||
init_options = mkIf (cfg.lsp.opts != null) "${cfg.lsp.opts}";
|
||||
single_file_support = false; # upstream default
|
||||
};
|
||||
};
|
||||
|
@ -82,6 +74,7 @@
|
|||
command = '${cfg.dap.package}/bin/lldb-dap',
|
||||
name = 'lldb'
|
||||
}
|
||||
|
||||
dap.configurations.cpp = {
|
||||
{
|
||||
name = 'Launch',
|
||||
|
@ -120,10 +113,10 @@ in {
|
|||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "clang LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
enable = mkEnableOption "C/C++ LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
description = "The clang LSP server to use";
|
||||
description = "The C/C++ LSP server to use";
|
||||
type = enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
};
|
||||
|
@ -135,10 +128,15 @@ in {
|
|||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
|
||||
opts = mkOption {
|
||||
description = "Options to pass to clang LSP server";
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
options = mkOption {
|
||||
type = lspOptions;
|
||||
default = servers.${cfg.lsp.server}.options;
|
||||
description = ''
|
||||
LSP options for C/C++ language support.
|
||||
|
||||
This option is freeform, you may add options that are not set by default
|
||||
and they will be merged into the final table passed to lspconfig.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -148,11 +146,13 @@ in {
|
|||
type = bool;
|
||||
default = config.vim.languages.enableDAP;
|
||||
};
|
||||
|
||||
debugger = mkOption {
|
||||
description = "clang debugger to use";
|
||||
type = enum (attrNames debuggers);
|
||||
default = defaultDebugger;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "clang debugger package.";
|
||||
type = package;
|
||||
|
@ -173,7 +173,6 @@ in {
|
|||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
|
||||
vim.lsp.lspconfig.sources.clang-lsp = ''
|
||||
lspconfig.("${cfg.lsp.server}").setup (${toLuaObject cfg.lsp.options})
|
||||
'';
|
||||
|
|
Loading…
Add table
Reference in a new issue