feat: implement flutter-tools.nvim

This commit is contained in:
NotAShelf 2023-04-02 21:00:40 +03:00
parent 513087b8bd
commit 4d748c6c1b
No known key found for this signature in database
GPG key ID: F0D14CCB5ED5AA22
3 changed files with 74 additions and 0 deletions

View file

@ -0,0 +1,33 @@
{
config,
lib,
...
}:
with lib;
with builtins; let
cfg = config.vim.lsp;
ftcfg = cfg.dart.flutter-tools;
in {
config = mkIf (cfg.enable && ftcfg.enable) {
vim.startPlugins = ["flutter-tools"];
vim.luaConfigRC.flutter-tools = nvim.dag.entryAnywhere ''
require('flutter-tools').setup {
lsp = {
color = { -- show the derived colours for dart variables
enabled = ${boolToString ftcfg.color.enable}, -- whether or not to highlight color variables at all, only supported on flutter >= 2.10
background = ${boolToString ftcfg.color.highlightBackground}, -- highlight the background
foreground = ${boolToString ftcfg.color.highlightForeground}, -- highlight the foreground
virtual_text = ${boolToString ftcfg.color.virtualText.enable}, -- show the highlight using virtual text
virtual_text_str = ${ctcfg.color.virtualText.character} -- the virtual text character to highlight
},
capabilities = capabilities,
on_attach = default_on_attach;
flags = lsp_flags,
},
}
'';
};
}

View file

@ -0,0 +1,6 @@
_: {
imports = [
./flutter-tools.nix
./config.nix
];
}

View file

@ -0,0 +1,35 @@
{
config,
lib,
...
}:
with lib;
with builtins; {
options.vim.lsp.dart.flutter-tools = {
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";
};
};
};
};
}