mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-30 08:36:46 +00:00
f9789432f9
* modules: switch to gerg's neovim-wrapper * modules: use initViml instead of writing the file * treewide: make the entire generated config lua based * docs: remove mentions of configRC * plugins/treesitter: remove vim.cmd hack * treewide: move resolveDag to lib * modules/wrapper(rc): fix typo * treewide: migrate to pluginRC for correct DAG order The "new" DAG order is as follows: - (luaConfigPre) - globalsScript - basic - theme - pluginConfigs - extraPluginConfigs - mappings - (luaConfigPost) * plugins/theme: fix theme DAG place * plugins/theme: fix fixed theme DAG place * modules/wrapper(rc): add removed option module for configRC * docs: add dag-entries chapter, add release note entry * fix: formatting CI * languages/nix: add missing `local` * docs: fix page link * docs: add mention of breaking changes at the start of the release notes * plugins/neo-tree: convert to pluginRC * modules/wrapper(rc): add back entryAnywhere * modules/wrapper(rc): expose pluginRC * apply raf patch --------- Co-authored-by: NotAShelf <raf@notashelf.dev>
164 lines
4.6 KiB
Nix
164 lines
4.6 KiB
Nix
{
|
|
config,
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}: let
|
|
inherit (builtins) attrNames;
|
|
inherit (lib.lists) isList;
|
|
inherit (lib.strings) optionalString;
|
|
inherit (lib.options) mkEnableOption mkOption;
|
|
inherit (lib.types) bool enum package either listOf str nullOr;
|
|
inherit (lib.modules) mkIf mkMerge;
|
|
inherit (lib.nvim.lua) expToLua;
|
|
inherit (lib.nvim.types) mkGrammarOption;
|
|
inherit (lib.nvim.dag) entryAfter;
|
|
|
|
packageToCmd = package: defaultCmd:
|
|
if isList cfg.lsp.package
|
|
then expToLua cfg.lsp.package
|
|
else ''{ "${cfg.lsp.package}/bin/${defaultCmd}" }'';
|
|
|
|
cfg = config.vim.languages.clang;
|
|
|
|
defaultServer = "clangd";
|
|
servers = {
|
|
ccls = {
|
|
package = pkgs.ccls;
|
|
lspConfig = ''
|
|
lspconfig.ccls.setup{
|
|
capabilities = capabilities;
|
|
on_attach=default_on_attach;
|
|
cmd = ${packageToCmd cfg.lsp.package "ccls"};
|
|
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.opts}"}
|
|
}
|
|
'';
|
|
};
|
|
clangd = {
|
|
package = pkgs.clang-tools;
|
|
lspConfig = ''
|
|
local clangd_cap = capabilities
|
|
-- use same offsetEncoding as null-ls
|
|
clangd_cap.offsetEncoding = {"utf-16"}
|
|
lspconfig.clangd.setup{
|
|
capabilities = clangd_cap;
|
|
on_attach=default_on_attach;
|
|
cmd = ${packageToCmd cfg.lsp.package "clangd"};
|
|
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.opts}"}
|
|
}
|
|
'';
|
|
};
|
|
};
|
|
|
|
defaultDebugger = "lldb-vscode";
|
|
debuggers = {
|
|
lldb-vscode = {
|
|
package = pkgs.lldb;
|
|
dapConfig = ''
|
|
dap.adapters.lldb = {
|
|
type = 'executable',
|
|
command = '${cfg.dap.package}/bin/lldb-vscode',
|
|
name = 'lldb'
|
|
}
|
|
dap.configurations.cpp = {
|
|
{
|
|
name = 'Launch',
|
|
type = 'lldb',
|
|
request = 'launch',
|
|
program = function()
|
|
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
|
end,
|
|
cwd = "''${workspaceFolder}",
|
|
stopOnEntry = false,
|
|
args = {},
|
|
},
|
|
}
|
|
|
|
dap.configurations.c = dap.configurations.cpp
|
|
'';
|
|
};
|
|
};
|
|
in {
|
|
options.vim.languages.clang = {
|
|
enable = mkEnableOption "C/C++ language support";
|
|
|
|
cHeader = mkOption {
|
|
description = ''
|
|
C syntax for headers. Can fix treesitter errors, see:
|
|
https://www.reddit.com/r/neovim/comments/orfpcd/question_does_the_c_parser_from_nvimtreesitter/
|
|
'';
|
|
type = bool;
|
|
default = false;
|
|
};
|
|
|
|
treesitter = {
|
|
enable = mkEnableOption "C/C++ treesitter" // {default = config.vim.languages.enableTreesitter;};
|
|
cPackage = mkGrammarOption pkgs "c";
|
|
cppPackage = mkGrammarOption pkgs "cpp";
|
|
};
|
|
|
|
lsp = {
|
|
enable = mkEnableOption "clang LSP support" // {default = config.vim.languages.enableLSP;};
|
|
|
|
server = mkOption {
|
|
description = "The clang LSP server to use";
|
|
type = enum (attrNames servers);
|
|
default = defaultServer;
|
|
};
|
|
|
|
package = mkOption {
|
|
description = "clang LSP server package, or the command to run as a list of strings";
|
|
example = ''[lib.getExe pkgs.jdt-language-server " - data " " ~/.cache/jdtls/workspace "]'';
|
|
type = either package (listOf str);
|
|
default = servers.${cfg.lsp.server}.package;
|
|
};
|
|
|
|
opts = mkOption {
|
|
description = "Options to pass to clang LSP server";
|
|
type = nullOr str;
|
|
default = null;
|
|
};
|
|
};
|
|
|
|
dap = {
|
|
enable = mkOption {
|
|
description = "Enable clang Debug Adapter";
|
|
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;
|
|
default = debuggers.${cfg.dap.debugger}.package;
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
(mkIf cfg.cHeader {
|
|
vim.pluginRC.c-header = entryAfter ["basic"] "vim.g.c_syntax_for_h = 1";
|
|
})
|
|
|
|
(mkIf cfg.treesitter.enable {
|
|
vim.treesitter.enable = true;
|
|
vim.treesitter.grammars = [cfg.treesitter.cPackage cfg.treesitter.cppPackage];
|
|
})
|
|
|
|
(mkIf cfg.lsp.enable {
|
|
vim.lsp.lspconfig.enable = true;
|
|
|
|
vim.lsp.lspconfig.sources.clang-lsp = servers.${cfg.lsp.server}.lspConfig;
|
|
})
|
|
|
|
(mkIf cfg.dap.enable {
|
|
vim.debugger.nvim-dap.enable = true;
|
|
vim.debugger.nvim-dap.sources.clang-debugger = debuggers.${cfg.dap.debugger}.dapConfig;
|
|
})
|
|
]);
|
|
}
|