mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
plugins/easy-dotnet: init
This commit is contained in:
parent
13341a4c12
commit
78b6f8e1e5
2 changed files with 240 additions and 0 deletions
54
plugins/by-name/easy-dotnet/default.nix
Normal file
54
plugins/by-name/easy-dotnet/default.nix
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
{ lib, config, ... }:
|
||||||
|
lib.nixvim.plugins.mkNeovimPlugin {
|
||||||
|
name = "easy-dotnet";
|
||||||
|
packPathName = "easy-dotnet.nvim";
|
||||||
|
package = "easy-dotnet-nvim";
|
||||||
|
|
||||||
|
maintainers = [ lib.maintainers.GaetanLepage ];
|
||||||
|
|
||||||
|
settingsExample = lib.literalExpression ''
|
||||||
|
{
|
||||||
|
test_runner = {
|
||||||
|
enable_buffer_test_execution = true;
|
||||||
|
viewmode = "float";
|
||||||
|
};
|
||||||
|
auto_bootstrap_namespace = true;
|
||||||
|
terminal.__raw = '''
|
||||||
|
function(path, action, args)
|
||||||
|
local commands = {
|
||||||
|
run = function()
|
||||||
|
return string.format("dotnet run --project %s %s", path, args)
|
||||||
|
end,
|
||||||
|
test = function()
|
||||||
|
return string.format("dotnet test %s %s", path, args)
|
||||||
|
end,
|
||||||
|
restore = function()
|
||||||
|
return string.format("dotnet restore %s %s", path, args)
|
||||||
|
end,
|
||||||
|
build = function()
|
||||||
|
return string.format("dotnet build %s %s", path, args)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
local command = commands[action]() .. "\r"
|
||||||
|
require("toggleterm").exec(command, nil, nil, nil, "float")
|
||||||
|
end
|
||||||
|
''';
|
||||||
|
picker = "fzf";
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
|
||||||
|
extraConfig = cfg: {
|
||||||
|
warnings = lib.nixvim.mkWarnings "plugins.easy-dotnet" (
|
||||||
|
lib.mapAttrsToList
|
||||||
|
(pickerName: pluginName: {
|
||||||
|
when = (cfg.settings.picker or null == pickerName) && (!config.plugins.${pluginName}.enable);
|
||||||
|
message = "You have chosen to use '${pickerName}' as a picker but 'plugins.${pluginName}' is not enabled.";
|
||||||
|
})
|
||||||
|
{
|
||||||
|
fzf = "fzf-lua";
|
||||||
|
telescope = "telescope";
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
186
tests/test-sources/plugins/by-name/easy-dotnet/default.nix
Normal file
186
tests/test-sources/plugins/by-name/easy-dotnet/default.nix
Normal file
|
@ -0,0 +1,186 @@
|
||||||
|
{
|
||||||
|
empty = {
|
||||||
|
plugins.easy-dotnet.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
defaults = {
|
||||||
|
plugins = {
|
||||||
|
telescope.enable = true;
|
||||||
|
web-devicons.enable = true;
|
||||||
|
easy-dotnet = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
get_sdk_path.__raw = ''
|
||||||
|
function()
|
||||||
|
local sdk_version = vim.trim(vim.fn.system("dotnet --version"))
|
||||||
|
local sdk_list = vim.trim(vim.fn.system("dotnet --list-sdks"))
|
||||||
|
local base = nil
|
||||||
|
for line in sdk_list:gmatch("[^\n]+") do
|
||||||
|
if line:find(sdk_version, 1, true) then
|
||||||
|
base = vim.fs.normalize(line:match("%[(.-)%]"))
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local sdk_path = polyfills.fs.joinpath(base, sdk_version):gsub("Program Files", '"Program Files"')
|
||||||
|
return sdk_path
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
terminal.__raw = ''
|
||||||
|
function(path, action, args)
|
||||||
|
local commands = {
|
||||||
|
run = function() return string.format("dotnet run --project %s %s", path, args) end,
|
||||||
|
test = function() return string.format("dotnet test %s %s", path, args) end,
|
||||||
|
restore = function() return string.format("dotnet restore %s %s", path, args) end,
|
||||||
|
build = function() return string.format("dotnet build %s %s", path, args) end,
|
||||||
|
}
|
||||||
|
local command = commands[action]()
|
||||||
|
if require("easy-dotnet.extensions").isWindows() == true then command = command .. "\r" end
|
||||||
|
vim.cmd("vsplit")
|
||||||
|
vim.cmd("term " .. command)
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
secrets = {
|
||||||
|
path.__raw = ''
|
||||||
|
function()
|
||||||
|
local path = ""
|
||||||
|
local home_dir = vim.fn.expand("~")
|
||||||
|
if require("easy-dotnet.extensions").isWindows() then
|
||||||
|
local secret_path = home_dir .. "\\AppData\\Roaming\\Microsoft\\UserSecrets\\" .. secret_guid .. "\\secrets.json"
|
||||||
|
path = secret_path
|
||||||
|
else
|
||||||
|
local secret_path = home_dir .. "/.microsoft/usersecrets/" .. secret_guid .. "/secrets.json"
|
||||||
|
path = secret_path
|
||||||
|
end
|
||||||
|
return path
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
test_runner = {
|
||||||
|
viewmode = "split";
|
||||||
|
enable_buffer_test_execution = true;
|
||||||
|
noBuild = true;
|
||||||
|
noRestore = true;
|
||||||
|
icons = {
|
||||||
|
passed = "";
|
||||||
|
skipped = "";
|
||||||
|
failed = "";
|
||||||
|
success = "";
|
||||||
|
reload = "";
|
||||||
|
test = "";
|
||||||
|
sln = "";
|
||||||
|
project = "";
|
||||||
|
dir = "";
|
||||||
|
package = "";
|
||||||
|
};
|
||||||
|
mappings = {
|
||||||
|
run_test_from_buffer = {
|
||||||
|
lhs = "<leader>r";
|
||||||
|
desc = "run test from buffer";
|
||||||
|
};
|
||||||
|
debug_test_from_buffer = {
|
||||||
|
lhs = "<leader>d";
|
||||||
|
desc = "run test from buffer";
|
||||||
|
};
|
||||||
|
filter_failed_tests = {
|
||||||
|
lhs = "<leader>fe";
|
||||||
|
desc = "filter failed tests";
|
||||||
|
};
|
||||||
|
debug_test = {
|
||||||
|
lhs = "<leader>d";
|
||||||
|
desc = "debug test";
|
||||||
|
};
|
||||||
|
go_to_file = {
|
||||||
|
lhs = "g";
|
||||||
|
desc = "go to file";
|
||||||
|
};
|
||||||
|
run_all = {
|
||||||
|
lhs = "<leader>R";
|
||||||
|
desc = "run all tests";
|
||||||
|
};
|
||||||
|
run = {
|
||||||
|
lhs = "<leader>r";
|
||||||
|
desc = "run test";
|
||||||
|
};
|
||||||
|
peek_stacktrace = {
|
||||||
|
lhs = "<leader>p";
|
||||||
|
desc = "peek stacktrace of failed test";
|
||||||
|
};
|
||||||
|
expand = {
|
||||||
|
lhs = "o";
|
||||||
|
desc = "expand";
|
||||||
|
};
|
||||||
|
expand_node = {
|
||||||
|
lhs = "E";
|
||||||
|
desc = "expand node";
|
||||||
|
};
|
||||||
|
expand_all = {
|
||||||
|
lhs = "-";
|
||||||
|
desc = "expand all";
|
||||||
|
};
|
||||||
|
collapse_all = {
|
||||||
|
lhs = "W";
|
||||||
|
desc = "collapse all";
|
||||||
|
};
|
||||||
|
close = {
|
||||||
|
lhs = "q";
|
||||||
|
desc = "close testrunner";
|
||||||
|
};
|
||||||
|
refresh_testrunner = {
|
||||||
|
lhs = "<C-r>";
|
||||||
|
desc = "refresh testrunner";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
additional_args = [ ];
|
||||||
|
};
|
||||||
|
csproj_mappings = true;
|
||||||
|
fsproj_mappings = true;
|
||||||
|
auto_bootstrap_namespace = {
|
||||||
|
type = "block_scoped";
|
||||||
|
enabled = true;
|
||||||
|
};
|
||||||
|
picker = "telescope";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
example = {
|
||||||
|
plugins = {
|
||||||
|
fzf-lua.enable = true;
|
||||||
|
easy-dotnet = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
settings = {
|
||||||
|
test_runner = {
|
||||||
|
enable_buffer_test_execution = true;
|
||||||
|
viewmode = "float";
|
||||||
|
};
|
||||||
|
auto_bootstrap_namespace = true;
|
||||||
|
terminal.__raw = ''
|
||||||
|
function(path, action, args)
|
||||||
|
local commands = {
|
||||||
|
run = function()
|
||||||
|
return string.format("dotnet run --project %s %s", path, args)
|
||||||
|
end,
|
||||||
|
test = function()
|
||||||
|
return string.format("dotnet test %s %s", path, args)
|
||||||
|
end,
|
||||||
|
restore = function()
|
||||||
|
return string.format("dotnet restore %s %s", path, args)
|
||||||
|
end,
|
||||||
|
build = function()
|
||||||
|
return string.format("dotnet build %s %s", path, args)
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
||||||
|
local command = commands[action]() .. "\r"
|
||||||
|
require("toggleterm").exec(command, nil, nil, nil, "float")
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
picker = "fzf";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue