2023-04-18 02:18:02 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
2023-11-08 03:16:46 +01:00
|
|
|
}: let
|
2024-02-26 06:05:23 +01:00
|
|
|
inherit (lib.lists) isList;
|
|
|
|
inherit (lib.modules) mkIf mkMerge;
|
|
|
|
inherit (lib.strings) optionalString;
|
|
|
|
inherit (lib.trivial) boolToString;
|
|
|
|
inherit (lib.nvim.lua) expToLua;
|
|
|
|
inherit (lib.nvim.dag) entryAnywhere;
|
2023-11-08 03:16:46 +01:00
|
|
|
|
2023-04-18 02:18:02 +02:00
|
|
|
cfg = config.vim.languages.dart;
|
|
|
|
ftcfg = cfg.flutter-tools;
|
|
|
|
servers = {
|
|
|
|
dart = {
|
|
|
|
package = pkgs.dart;
|
|
|
|
lspConfig = ''
|
2023-04-18 13:57:11 +02:00
|
|
|
lspconfig.dartls.setup{
|
2023-04-18 02:18:02 +02:00
|
|
|
capabilities = capabilities;
|
|
|
|
on_attach=default_on_attach;
|
2023-09-19 01:26:41 +02:00
|
|
|
cmd = ${
|
|
|
|
if isList cfg.lsp.package
|
2024-02-26 06:05:23 +01:00
|
|
|
then expToLua cfg.lsp.package
|
2023-09-19 01:26:41 +02:00
|
|
|
else ''{"${cfg.lsp.package}/bin/dart", "language-server", "--protocol=lsp"}''
|
|
|
|
};
|
2023-04-18 02:18:02 +02:00
|
|
|
${optionalString (cfg.lsp.opts != null) "init_options = ${cfg.lsp.dartOpts}"}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
in {
|
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
|
|
(mkIf cfg.treesitter.enable {
|
|
|
|
vim.treesitter.enable = true;
|
|
|
|
vim.treesitter.grammars = [cfg.treesitter.package];
|
|
|
|
})
|
|
|
|
|
|
|
|
(mkIf cfg.lsp.enable {
|
|
|
|
vim.lsp.lspconfig.enable = true;
|
|
|
|
vim.lsp.lspconfig.sources.dart-lsp = servers.${cfg.lsp.server}.lspConfig;
|
|
|
|
})
|
|
|
|
|
2024-02-26 06:05:23 +01:00
|
|
|
(mkIf ftcfg.enable {
|
2023-06-25 14:09:12 +02:00
|
|
|
vim.startPlugins =
|
|
|
|
if ftcfg.enableNoResolvePatch
|
|
|
|
then ["flutter-tools-patched"]
|
|
|
|
else ["flutter-tools"];
|
2023-04-18 02:18:02 +02:00
|
|
|
|
2024-02-26 06:05:23 +01:00
|
|
|
vim.luaConfigRC.flutter-tools = entryAnywhere ''
|
2023-04-18 02:18:02 +02:00
|
|
|
require('flutter-tools').setup {
|
|
|
|
lsp = {
|
2024-04-21 03:57:42 +02:00
|
|
|
color = {
|
|
|
|
enabled = ${boolToString ftcfg.color.enable},
|
|
|
|
background = ${boolToString ftcfg.color.highlightBackground},
|
|
|
|
foreground = ${boolToString ftcfg.color.highlightForeground},
|
|
|
|
virtual_text = ${boolToString ftcfg.color.virtualText.enable},
|
|
|
|
virtual_text_str = ${toString ftcfg.color.virtualText.character}
|
2023-04-18 02:18:02 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
capabilities = capabilities,
|
|
|
|
on_attach = default_on_attach;
|
|
|
|
flags = lsp_flags,
|
|
|
|
},
|
2023-06-27 00:04:48 +02:00
|
|
|
${optionalString cfg.dap.enable ''
|
|
|
|
debugger = {
|
|
|
|
enabled = true,
|
|
|
|
},
|
|
|
|
''}
|
2023-04-18 02:18:02 +02:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
})
|
|
|
|
]);
|
|
|
|
}
|