From 8d716135af6af7d6de4fb345a57541152d298038 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 21 Apr 2024 04:57:42 +0300 Subject: [PATCH] POC: formatted Lua configuration --- modules/plugins/languages/dart/config.nix | 13 ++++++------ modules/plugins/languages/dart/dart.nix | 2 +- modules/wrapper/rc/config.nix | 24 ++++++++++++++++++++++- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/modules/plugins/languages/dart/config.nix b/modules/plugins/languages/dart/config.nix index be7c111..59fea67 100644 --- a/modules/plugins/languages/dart/config.nix +++ b/modules/plugins/languages/dart/config.nix @@ -39,7 +39,6 @@ in { (mkIf cfg.lsp.enable { vim.lsp.lspconfig.enable = true; - vim.lsp.lspconfig.sources.dart-lsp = servers.${cfg.lsp.server}.lspConfig; }) @@ -52,12 +51,12 @@ in { vim.luaConfigRC.flutter-tools = 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 = ${ftcfg.color.virtualText.character} -- the virtual text character to highlight + 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} }, capabilities = capabilities, diff --git a/modules/plugins/languages/dart/dart.nix b/modules/plugins/languages/dart/dart.nix index 13ce3d9..a289489 100644 --- a/modules/plugins/languages/dart/dart.nix +++ b/modules/plugins/languages/dart/dart.nix @@ -105,7 +105,7 @@ in { character = mkOption { type = str; - default = "■"; + default = "..."; description = "Virtual text character to highlight"; }; }; diff --git a/modules/wrapper/rc/config.nix b/modules/wrapper/rc/config.nix index f42f040..83721c5 100644 --- a/modules/wrapper/rc/config.nix +++ b/modules/wrapper/rc/config.nix @@ -1,5 +1,6 @@ { config, + pkgs, lib, ... }: let @@ -128,6 +129,24 @@ in { else abort ("Dependency cycle in ${name}: " + toJSON sortedDag); in result; + + formatLua = { + name, + contents, + ... + }: + pkgs.runCommand name {inherit contents;} '' + touch $out + echo -n "$text" > "$out" + + ${pkgs.stylua}/bin/stylua \ + --column-width 80 \ + --no-editorconfig \ + --indent-type Spaces \ + --indent-width 4 \ + --collapse-simple-statement Never \ + "$out" + ''; in { vim = { configRC = { @@ -138,8 +157,11 @@ in { luaScript = let mapResult = result: (wrapLuaConfig { luaBefore = "${cfg.luaConfigPre}"; - luaConfig = concatStringsSep "\n" (map mkLuarcSection result); luaAfter = "${cfg.luaConfigPost}"; + luaConfig = formatLua { + name = "lua"; + contents = concatStringsSep "\n" (map mkLuarcSection result); + }; }); luaConfig = resolveDag {