neovim-flake/modules/plugins/languages/dart/dart.nix

116 lines
3.3 KiB
Nix
Raw Normal View History

{
config,
lib,
pkgs,
...
}: let
inherit (builtins) attrNames;
inherit (lib.lists) isList;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) enum either listOf package nullOr str bool;
inherit (lib.strings) optionalString;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.dart;
defaultServer = "dart";
servers = {
dart = {
package = pkgs.dart;
lspConfig = ''
lspconfig.dartls.setup{
capabilities = capabilities;
on_attach=default_on_attach;
2023-09-19 01:26:41 +02:00
cmd = ${
if isList cfg.lsp.package
then expToLua cfg.lsp.package
2023-09-19 01:26:41 +02:00
else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}''
};
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"}
}
'';
};
};
in {
options.vim.languages.dart = {
enable = mkEnableOption "Dart language support";
treesitter = {
enable = mkEnableOption "Dart treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "dart";
};
lsp = {
enable = mkEnableOption "Dart LSP support";
server = mkOption {
description = "The Dart LSP server to use";
type = enum (attrNames servers);
default = defaultServer;
};
package = mkOption {
description = "Dart 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 Dart LSP server";
type = nullOr str;
default = null;
};
};
2023-06-27 00:04:48 +02:00
dap = {
enable = mkOption {
description = "Enable Dart DAP support via flutter-tools";
type = bool;
2023-06-27 00:04:48 +02:00
default = config.vim.languages.enableDAP;
};
};
flutter-tools = {
enable = mkOption {
description = "Enable flutter-tools for flutter support";
type = bool;
default = config.vim.languages.enableLSP;
};
enableNoResolvePatch = mkOption {
description = ''
Patch flutter-tools so that it doesn't resolve symlinks when detecting flutter path.
This is required if you want to use a flutter package built with nix.
If you are using a flutter SDK installed from a different source and encounter the error "`dart` missing from PATH", disable this option.
'';
type = bool;
default = true;
};
color = {
enable = mkEnableOption "Whether or mot to highlight color variables at all";
highlightBackground = mkOption {
type = bool;
default = false;
description = "Highlight the background";
};
highlightForeground = mkOption {
type = bool;
default = false;
description = "Highlight the foreground";
};
virtualText = {
enable = mkEnableOption "Show the highlight using virtual text";
character = mkOption {
type = str;
2024-04-21 03:57:42 +02:00
default = "...";
description = "Virtual text character to highlight";
};
};
};
};
};
}