diff --git a/flake.lock b/flake.lock index b7fa1b27..4bd6ec73 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 e64624db..8133e142 100644 --- a/flake.nix +++ b/flake.nix @@ -135,6 +135,11 @@ flake = false; }; + flutter-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 edbaff11..f9afa32c 100644 --- a/lib/types/plugins.nix +++ b/lib/types/plugins.nix @@ -72,6 +72,7 @@ with lib; let "fidget-nvim" "diffview-nvim" "todo-comments" + "flutter-tools" ]; # You can either use the name of the plugin or a package. pluginsType = with types; listOf (nullOr (either (enum availablePlugins) package)); diff --git a/modules/lsp/default.nix b/modules/lsp/default.nix index 8f093cb0..db4f0272 100644 --- a/modules/lsp/default.nix +++ b/modules/lsp/default.nix @@ -10,5 +10,8 @@ ./trouble ./lsp-signature ./lightbulb + + # flutter-tools + ./flutter-tools-nvim ]; } diff --git a/modules/lsp/flutter-tools-nvim/config.nix b/modules/lsp/flutter-tools-nvim/config.nix new file mode 100644 index 00000000..2c97e90b --- /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 = ${ftcfg.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 00000000..4cbe9c02 --- /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 00000000..2f87c310 --- /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"; + }; + }; + }; + }; +} diff --git a/modules/lsp/module.nix b/modules/lsp/module.nix index 4cc256c8..5bf99e0f 100644 --- a/modules/lsp/module.nix +++ b/modules/lsp/module.nix @@ -57,6 +57,13 @@ in { default = ""; }; }; + + dart = { + flutter-tools = { + enable = mkEnableOption ""; + }; + }; + sql = mkEnableOption "SQL Language LSP"; go = mkEnableOption "Go language LSP"; ts = mkEnableOption "TS language LSP"; diff --git a/modules/utility/binds/which-key/config.nix b/modules/utility/binds/which-key/config.nix index 967d4f72..e2f5ae12 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 "" } + }) ''; };