diff --git a/modules/lsp/flutter-tools-nvim/config.nix b/modules/lsp/flutter-tools-nvim/config.nix new file mode 100644 index 0000000..1baad4a --- /dev/null +++ b/modules/lsp/flutter-tools-nvim/config.nix @@ -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, + }, + } + + ''; + }; +} diff --git a/modules/lsp/flutter-tools-nvim/default.nix b/modules/lsp/flutter-tools-nvim/default.nix new file mode 100644 index 0000000..4cbe9c0 --- /dev/null +++ b/modules/lsp/flutter-tools-nvim/default.nix @@ -0,0 +1,6 @@ +_: { + imports = [ + ./flutter-tools.nix + ./config.nix + ]; +} diff --git a/modules/lsp/flutter-tools-nvim/flutter-tools.nix b/modules/lsp/flutter-tools-nvim/flutter-tools.nix new file mode 100644 index 0000000..2f87c31 --- /dev/null +++ b/modules/lsp/flutter-tools-nvim/flutter-tools.nix @@ -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"; + }; + }; + }; + }; +}