From 4d748c6c1b590a5959e245e40fb140daa3854b83 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 2 Apr 2023 21:00:40 +0300 Subject: [PATCH] feat: implement flutter-tools.nvim --- modules/lsp/flutter-tools-nvim/config.nix | 33 +++++++++++++++++ modules/lsp/flutter-tools-nvim/default.nix | 6 ++++ .../lsp/flutter-tools-nvim/flutter-tools.nix | 35 +++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 modules/lsp/flutter-tools-nvim/config.nix create mode 100644 modules/lsp/flutter-tools-nvim/default.nix create mode 100644 modules/lsp/flutter-tools-nvim/flutter-tools.nix 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"; + }; + }; + }; + }; +}