From 513087b8bd4dde10e77ceb03cec69418e5cb8267 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 2 Apr 2023 20:56:57 +0300 Subject: [PATCH 1/8] feat: add flutter-tools.nvim to available plugins --- flake.lock | 17 +++++++++++++++++ flake.nix | 5 +++++ lib/types/plugins.nix | 1 + 3 files changed, 23 insertions(+) diff --git a/flake.lock b/flake.lock index b7fa1b2..4bd6ec7 100644 --- a/flake.lock +++ b/flake.lock @@ -256,6 +256,22 @@ "type": "github" } }, + "dart-tools": { + "flake": false, + "locked": { + "lastModified": 1680456818, + "narHash": "sha256-VNSrYJZKcQ92+2ko5ZkOOiAM/sXqbJtpkYvxFr1qtWk=", + "owner": "akinsho", + "repo": "flutter-tools.nvim", + "rev": "0a7e6b40aebd874e957ed630420a267e6cac0967", + "type": "github" + }, + "original": { + "owner": "akinsho", + "repo": "flutter-tools.nvim", + "type": "github" + } + }, "dashboard-nvim": { "flake": false, "locked": { @@ -1236,6 +1252,7 @@ "comment-nvim": "comment-nvim", "copilot-lua": "copilot-lua", "crates-nvim": "crates-nvim", + "dart-tools": "dart-tools", "dashboard-nvim": "dashboard-nvim", "diffview-nvim": "diffview-nvim", "dressing-nvim": "dressing-nvim", diff --git a/flake.nix b/flake.nix index e64624d..5876807 100644 --- a/flake.nix +++ b/flake.nix @@ -135,6 +135,11 @@ flake = false; }; + dart-tools = { + url = "github:akinsho/flutter-tools.nvim"; + flake = false; + }; + # Copying/Registers registers = { url = "github:tversteeg/registers.nvim"; diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index edbaff1..71e6a14 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -72,6 +72,7 @@ with lib; let "fidget-nvim" "diffview-nvim" "todo-comments" + "dart-tools" ]; # You can either use the name of the plugin or a package. pluginsType = with types; listOf (nullOr (either (enum availablePlugins) package)); From 4d748c6c1b590a5959e245e40fb140daa3854b83 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 2 Apr 2023 21:00:40 +0300 Subject: [PATCH 2/8] 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"; + }; + }; + }; + }; +} From 7fc5eec2d1e49cf77051b7edfcdd2d251e798aad Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 2 Apr 2023 21:01:07 +0300 Subject: [PATCH 3/8] feat: dart and flutter-tools --- modules/lsp/module.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/lsp/module.nix b/modules/lsp/module.nix index 4cc256c..6c8a67c 100644 --- a/modules/lsp/module.nix +++ b/modules/lsp/module.nix @@ -57,6 +57,9 @@ in { default = ""; }; }; + dart = { + flutter-tools.enable = mkEnableOption ""; + }; sql = mkEnableOption "SQL Language LSP"; go = mkEnableOption "Go language LSP"; ts = mkEnableOption "TS language LSP"; From 887a6f9080ed7dcbdd2298bfffc6b498d114fce5 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 2 Apr 2023 21:01:26 +0300 Subject: [PATCH 4/8] feat: import flutter-tools module --- modules/lsp/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/lsp/default.nix b/modules/lsp/default.nix index 8f093cb..db4f027 100644 --- a/modules/lsp/default.nix +++ b/modules/lsp/default.nix @@ -10,5 +10,8 @@ ./trouble ./lsp-signature ./lightbulb + + # flutter-tools + ./flutter-tools-nvim ]; } From 756a23ebb075d385ed7ae3cdb9b4fc7453dfc4e9 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 2 Apr 2023 21:38:54 +0300 Subject: [PATCH 5/8] fix: incorrect plugin name in the list --- lib/types/plugins.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/types/plugins.nix b/lib/types/plugins.nix index 71e6a14..f9afa32 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -72,7 +72,7 @@ with lib; let "fidget-nvim" "diffview-nvim" "todo-comments" - "dart-tools" + "flutter-tools" ]; # You can either use the name of the plugin or a package. pluginsType = with types; listOf (nullOr (either (enum availablePlugins) package)); From 68e65c63e35fe2b99f0015ce4e583c377715f340 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 2 Apr 2023 21:49:31 +0300 Subject: [PATCH 6/8] fix: mismatching plugin input --- flake.nix | 2 +- modules/lsp/module.nix | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 5876807..8133e14 100644 --- a/flake.nix +++ b/flake.nix @@ -135,7 +135,7 @@ flake = false; }; - dart-tools = { + flutter-tools = { url = "github:akinsho/flutter-tools.nvim"; flake = false; }; diff --git a/modules/lsp/module.nix b/modules/lsp/module.nix index 6c8a67c..5bf99e0 100644 --- a/modules/lsp/module.nix +++ b/modules/lsp/module.nix @@ -57,9 +57,13 @@ in { default = ""; }; }; + dart = { - flutter-tools.enable = mkEnableOption ""; + flutter-tools = { + enable = mkEnableOption ""; + }; }; + sql = mkEnableOption "SQL Language LSP"; go = mkEnableOption "Go language LSP"; ts = mkEnableOption "TS language LSP"; From cecf30652e946b26836cdc6d46ada3e341522e73 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 2 Apr 2023 21:55:23 +0300 Subject: [PATCH 7/8] fix: typo in config reference --- modules/lsp/flutter-tools-nvim/config.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/lsp/flutter-tools-nvim/config.nix b/modules/lsp/flutter-tools-nvim/config.nix index 1baad4a..2c97e90 100644 --- a/modules/lsp/flutter-tools-nvim/config.nix +++ b/modules/lsp/flutter-tools-nvim/config.nix @@ -19,7 +19,7 @@ in { 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 + virtual_text_str = ${ftcfg.color.virtualText.character} -- the virtual text character to highlight }, capabilities = capabilities, From 264372de0923616c4f50ac4f7300d15266df734c Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 2 Apr 2023 22:54:19 +0300 Subject: [PATCH 8/8] fix: incorrect which-key registry --- modules/utility/binds/which-key/config.nix | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/modules/utility/binds/which-key/config.nix b/modules/utility/binds/which-key/config.nix index 967d4f7..e2f5ae1 100644 --- a/modules/utility/binds/which-key/config.nix +++ b/modules/utility/binds/which-key/config.nix @@ -11,19 +11,18 @@ in { vim.startPlugins = ["which-key"]; vim.luaConfigRC.whichkey = nvim.dag.entryAnywhere '' - local wk = require("which-key") - wk.setup {} + local wk = require("which-key") + wk.setup ({ + key_labels = { + [""] = "SPACE", + [""] = "SPACE", + [""] = "RETURN", + [""] = "TAB", + } + }) - - wk.register({ - key_labels = { - [""] = "SPACE", - [""] = "SPACE", - [""] = "RETURN", - [""] = "TAB", - }, - - ${ + wk.register({ + ${ if config.vim.tabline.nvimBufferline.enable then '' -- Buffer @@ -31,12 +30,11 @@ in { ["bm"] = { name = "BufferLineMove" }, ["bs"] = { name = "BufferLineSort" }, ["bsi"] = { name = "BufferLineSortById" }, - '' else "" } - ${ + ${ if config.vim.telescope.enable then '' ["f"] = { name = "+Telescope" }, @@ -49,7 +47,7 @@ in { else "" } - ${ + ${ if config.vim.lsp.trouble.enable then '' -- Trouble @@ -60,7 +58,7 @@ in { else "" } - ${ + ${ if config.vim.lsp.nvimCodeActionMenu.enable then '' -- Parent Groups @@ -69,7 +67,7 @@ in { else "" } - ${ + ${ if config.vim.minimap.codewindow.enable || config.vim.minimap.minimap-vim.enable then '' -- Minimap @@ -78,7 +76,7 @@ in { else "" } - ${ + ${ if config.vim.notes.mind-nvim.enable || config.vim.notes.obsidian.enable || config.vim.notes.orgmode.enable then '' -- Notes @@ -89,7 +87,7 @@ in { else "" } - ${ + ${ if config.vim.filetree.nvimTreeLua.enable then '' -- NvimTree @@ -98,7 +96,7 @@ in { else "" } - ${ + ${ if config.vim.git.gitsigns.enable then '' -- Git @@ -106,7 +104,8 @@ in { '' else "" } - ${ + + ${ if config.vim.markdown.glow.enable then '' -- Markdown @@ -114,6 +113,7 @@ in { '' else "" } + }) ''; };