Merge pull request #38 from NotAShelf/flutter-tools.nvim

Feature/flutter-tools.nvim
This commit is contained in:
NotAShelf 2023-04-02 22:59:34 +03:00 committed by GitHub
commit 7590bdf0ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 128 additions and 21 deletions

View file

@ -256,6 +256,22 @@
"type": "github" "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": { "dashboard-nvim": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -1236,6 +1252,7 @@
"comment-nvim": "comment-nvim", "comment-nvim": "comment-nvim",
"copilot-lua": "copilot-lua", "copilot-lua": "copilot-lua",
"crates-nvim": "crates-nvim", "crates-nvim": "crates-nvim",
"dart-tools": "dart-tools",
"dashboard-nvim": "dashboard-nvim", "dashboard-nvim": "dashboard-nvim",
"diffview-nvim": "diffview-nvim", "diffview-nvim": "diffview-nvim",
"dressing-nvim": "dressing-nvim", "dressing-nvim": "dressing-nvim",

View file

@ -135,6 +135,11 @@
flake = false; flake = false;
}; };
flutter-tools = {
url = "github:akinsho/flutter-tools.nvim";
flake = false;
};
# Copying/Registers # Copying/Registers
registers = { registers = {
url = "github:tversteeg/registers.nvim"; url = "github:tversteeg/registers.nvim";

View file

@ -72,6 +72,7 @@ with lib; let
"fidget-nvim" "fidget-nvim"
"diffview-nvim" "diffview-nvim"
"todo-comments" "todo-comments"
"flutter-tools"
]; ];
# You can either use the name of the plugin or a package. # You can either use the name of the plugin or a package.
pluginsType = with types; listOf (nullOr (either (enum availablePlugins) package)); pluginsType = with types; listOf (nullOr (either (enum availablePlugins) package));

View file

@ -10,5 +10,8 @@
./trouble ./trouble
./lsp-signature ./lsp-signature
./lightbulb ./lightbulb
# flutter-tools
./flutter-tools-nvim
]; ];
} }

View file

@ -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,
},
}
'';
};
}

View file

@ -0,0 +1,6 @@
_: {
imports = [
./flutter-tools.nix
./config.nix
];
}

View file

@ -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";
};
};
};
};
}

View file

@ -57,6 +57,13 @@ in {
default = ""; default = "";
}; };
}; };
dart = {
flutter-tools = {
enable = mkEnableOption "";
};
};
sql = mkEnableOption "SQL Language LSP"; sql = mkEnableOption "SQL Language LSP";
go = mkEnableOption "Go language LSP"; go = mkEnableOption "Go language LSP";
ts = mkEnableOption "TS language LSP"; ts = mkEnableOption "TS language LSP";

View file

@ -11,19 +11,18 @@ in {
vim.startPlugins = ["which-key"]; vim.startPlugins = ["which-key"];
vim.luaConfigRC.whichkey = nvim.dag.entryAnywhere '' vim.luaConfigRC.whichkey = nvim.dag.entryAnywhere ''
local wk = require("which-key") local wk = require("which-key")
wk.setup {} wk.setup ({
key_labels = {
["<space>"] = "SPACE",
["<leader>"] = "SPACE",
["<cr>"] = "RETURN",
["<tab>"] = "TAB",
}
})
wk.register({
wk.register({ ${
key_labels = {
["<space>"] = "SPACE",
["<leader>"] = "SPACE",
["<cr>"] = "RETURN",
["<tab>"] = "TAB",
},
${
if config.vim.tabline.nvimBufferline.enable if config.vim.tabline.nvimBufferline.enable
then '' then ''
-- Buffer -- Buffer
@ -31,12 +30,11 @@ in {
["<leader>bm"] = { name = "BufferLineMove" }, ["<leader>bm"] = { name = "BufferLineMove" },
["<leader>bs"] = { name = "BufferLineSort" }, ["<leader>bs"] = { name = "BufferLineSort" },
["<leader>bsi"] = { name = "BufferLineSortById" }, ["<leader>bsi"] = { name = "BufferLineSortById" },
'' ''
else "" else ""
} }
${ ${
if config.vim.telescope.enable if config.vim.telescope.enable
then '' then ''
["<leader>f"] = { name = "+Telescope" }, ["<leader>f"] = { name = "+Telescope" },
@ -49,7 +47,7 @@ in {
else "" else ""
} }
${ ${
if config.vim.lsp.trouble.enable if config.vim.lsp.trouble.enable
then '' then ''
-- Trouble -- Trouble
@ -60,7 +58,7 @@ in {
else "" else ""
} }
${ ${
if config.vim.lsp.nvimCodeActionMenu.enable if config.vim.lsp.nvimCodeActionMenu.enable
then '' then ''
-- Parent Groups -- Parent Groups
@ -69,7 +67,7 @@ in {
else "" else ""
} }
${ ${
if config.vim.minimap.codewindow.enable || config.vim.minimap.minimap-vim.enable if config.vim.minimap.codewindow.enable || config.vim.minimap.minimap-vim.enable
then '' then ''
-- Minimap -- Minimap
@ -78,7 +76,7 @@ in {
else "" else ""
} }
${ ${
if config.vim.notes.mind-nvim.enable || config.vim.notes.obsidian.enable || config.vim.notes.orgmode.enable if config.vim.notes.mind-nvim.enable || config.vim.notes.obsidian.enable || config.vim.notes.orgmode.enable
then '' then ''
-- Notes -- Notes
@ -89,7 +87,7 @@ in {
else "" else ""
} }
${ ${
if config.vim.filetree.nvimTreeLua.enable if config.vim.filetree.nvimTreeLua.enable
then '' then ''
-- NvimTree -- NvimTree
@ -98,7 +96,7 @@ in {
else "" else ""
} }
${ ${
if config.vim.git.gitsigns.enable if config.vim.git.gitsigns.enable
then '' then ''
-- Git -- Git
@ -106,7 +104,8 @@ in {
'' ''
else "" else ""
} }
${
${
if config.vim.markdown.glow.enable if config.vim.markdown.glow.enable
then '' then ''
-- Markdown -- Markdown
@ -114,6 +113,7 @@ in {
'' ''
else "" else ""
} }
}) })
''; '';
}; };