2023-04-18 00:18:02 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib;
|
|
|
|
with builtins; let
|
|
|
|
cfg = config.vim.languages.dart;
|
|
|
|
defaultServer = "dart";
|
|
|
|
servers = {
|
|
|
|
dart = {
|
|
|
|
package = pkgs.dart;
|
|
|
|
lspConfig = ''
|
2023-04-18 11:57:11 +00:00
|
|
|
lspconfig.dartls.setup{
|
2023-04-18 00:18:02 +00:00
|
|
|
capabilities = capabilities;
|
|
|
|
on_attach=default_on_attach;
|
2023-09-18 23:26:41 +00:00
|
|
|
cmd = ${
|
|
|
|
if isList cfg.lsp.package
|
|
|
|
then nvim.lua.expToLua cfg.lsp.package
|
|
|
|
else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}''
|
|
|
|
};
|
2023-04-18 00:18:02 +00:00
|
|
|
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in {
|
|
|
|
options.vim.languages.dart = {
|
|
|
|
enable = mkEnableOption "Dart language support";
|
|
|
|
|
|
|
|
treesitter = {
|
2023-10-21 17:15:36 +00:00
|
|
|
enable = mkEnableOption "Dart treesitter" // {default = config.vim.languages.enableTreesitter;};
|
2023-04-18 00:18:02 +00:00
|
|
|
package = nvim.types.mkGrammarOption pkgs "dart";
|
|
|
|
};
|
|
|
|
|
|
|
|
lsp = {
|
2023-06-05 20:10:25 +00:00
|
|
|
enable = mkEnableOption "Dart LSP support";
|
2023-04-18 00:18:02 +00:00
|
|
|
server = mkOption {
|
|
|
|
description = "The Dart LSP server to use";
|
|
|
|
type = with types; enum (attrNames servers);
|
|
|
|
default = defaultServer;
|
|
|
|
};
|
|
|
|
package = mkOption {
|
2023-09-22 22:28:39 +00:00
|
|
|
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"]'';
|
2023-09-18 23:26:41 +00:00
|
|
|
type = with types; either package (listOf str);
|
2023-04-18 00:18:02 +00:00
|
|
|
default = servers.${cfg.lsp.server}.package;
|
|
|
|
};
|
|
|
|
opts = mkOption {
|
|
|
|
description = "Options to pass to Dart LSP server";
|
|
|
|
type = with types; nullOr str;
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-06-26 22:04:48 +00:00
|
|
|
dap = {
|
|
|
|
enable = mkOption {
|
|
|
|
description = "Enable Dart DAP support via flutter-tools";
|
|
|
|
type = types.bool;
|
|
|
|
default = config.vim.languages.enableDAP;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-04-18 00:18:02 +00:00
|
|
|
flutter-tools = {
|
2023-04-18 12:00:46 +00:00
|
|
|
enable = mkOption {
|
|
|
|
description = "Enable flutter-tools for flutter support";
|
|
|
|
type = types.bool;
|
|
|
|
default = config.vim.languages.enableLSP;
|
|
|
|
};
|
2023-04-18 00:18:02 +00:00
|
|
|
|
2023-06-25 12:09:12 +00:00
|
|
|
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 = types.bool;
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
|
2023-04-18 00:18:02 +00:00
|
|
|
color = {
|
|
|
|
enable = mkEnableOption "Whether or mot to highlight color variables at all";
|
|
|
|
|
|
|
|
highlightBackground = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Highlight the background";
|
|
|
|
};
|
|
|
|
|
|
|
|
highlightForeground = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Highlight the foreground";
|
|
|
|
};
|
|
|
|
|
|
|
|
virtualText = {
|
|
|
|
enable = mkEnableOption "Show the highlight using virtual text";
|
|
|
|
|
|
|
|
character = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "■";
|
|
|
|
description = "Virtual text character to highlight";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|