Skip to content

Commit 78b6f8e

Browse files
committed
plugins/easy-dotnet: init
1 parent 13341a4 commit 78b6f8e

File tree

2 files changed

+240
-0
lines changed

2 files changed

+240
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{ lib, config, ... }:
2+
lib.nixvim.plugins.mkNeovimPlugin {
3+
name = "easy-dotnet";
4+
packPathName = "easy-dotnet.nvim";
5+
package = "easy-dotnet-nvim";
6+
7+
maintainers = [ lib.maintainers.GaetanLepage ];
8+
9+
settingsExample = lib.literalExpression ''
10+
{
11+
test_runner = {
12+
enable_buffer_test_execution = true;
13+
viewmode = "float";
14+
};
15+
auto_bootstrap_namespace = true;
16+
terminal.__raw = '''
17+
function(path, action, args)
18+
local commands = {
19+
run = function()
20+
return string.format("dotnet run --project %s %s", path, args)
21+
end,
22+
test = function()
23+
return string.format("dotnet test %s %s", path, args)
24+
end,
25+
restore = function()
26+
return string.format("dotnet restore %s %s", path, args)
27+
end,
28+
build = function()
29+
return string.format("dotnet build %s %s", path, args)
30+
end,
31+
}
32+
33+
local command = commands[action]() .. "\r"
34+
require("toggleterm").exec(command, nil, nil, nil, "float")
35+
end
36+
''';
37+
picker = "fzf";
38+
}
39+
'';
40+
41+
extraConfig = cfg: {
42+
warnings = lib.nixvim.mkWarnings "plugins.easy-dotnet" (
43+
lib.mapAttrsToList
44+
(pickerName: pluginName: {
45+
when = (cfg.settings.picker or null == pickerName) && (!config.plugins.${pluginName}.enable);
46+
message = "You have chosen to use '${pickerName}' as a picker but 'plugins.${pluginName}' is not enabled.";
47+
})
48+
{
49+
fzf = "fzf-lua";
50+
telescope = "telescope";
51+
}
52+
);
53+
};
54+
}
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
{
2+
empty = {
3+
plugins.easy-dotnet.enable = true;
4+
};
5+
6+
defaults = {
7+
plugins = {
8+
telescope.enable = true;
9+
web-devicons.enable = true;
10+
easy-dotnet = {
11+
enable = true;
12+
13+
settings = {
14+
get_sdk_path.__raw = ''
15+
function()
16+
local sdk_version = vim.trim(vim.fn.system("dotnet --version"))
17+
local sdk_list = vim.trim(vim.fn.system("dotnet --list-sdks"))
18+
local base = nil
19+
for line in sdk_list:gmatch("[^\n]+") do
20+
if line:find(sdk_version, 1, true) then
21+
base = vim.fs.normalize(line:match("%[(.-)%]"))
22+
break
23+
end
24+
end
25+
local sdk_path = polyfills.fs.joinpath(base, sdk_version):gsub("Program Files", '"Program Files"')
26+
return sdk_path
27+
end
28+
'';
29+
terminal.__raw = ''
30+
function(path, action, args)
31+
local commands = {
32+
run = function() return string.format("dotnet run --project %s %s", path, args) end,
33+
test = function() return string.format("dotnet test %s %s", path, args) end,
34+
restore = function() return string.format("dotnet restore %s %s", path, args) end,
35+
build = function() return string.format("dotnet build %s %s", path, args) end,
36+
}
37+
local command = commands[action]()
38+
if require("easy-dotnet.extensions").isWindows() == true then command = command .. "\r" end
39+
vim.cmd("vsplit")
40+
vim.cmd("term " .. command)
41+
end
42+
'';
43+
secrets = {
44+
path.__raw = ''
45+
function()
46+
local path = ""
47+
local home_dir = vim.fn.expand("~")
48+
if require("easy-dotnet.extensions").isWindows() then
49+
local secret_path = home_dir .. "\\AppData\\Roaming\\Microsoft\\UserSecrets\\" .. secret_guid .. "\\secrets.json"
50+
path = secret_path
51+
else
52+
local secret_path = home_dir .. "/.microsoft/usersecrets/" .. secret_guid .. "/secrets.json"
53+
path = secret_path
54+
end
55+
return path
56+
end
57+
'';
58+
};
59+
test_runner = {
60+
viewmode = "split";
61+
enable_buffer_test_execution = true;
62+
noBuild = true;
63+
noRestore = true;
64+
icons = {
65+
passed = "";
66+
skipped = "";
67+
failed = "";
68+
success = "";
69+
reload = "";
70+
test = "";
71+
sln = "󰘐";
72+
project = "󰘐";
73+
dir = "";
74+
package = "";
75+
};
76+
mappings = {
77+
run_test_from_buffer = {
78+
lhs = "<leader>r";
79+
desc = "run test from buffer";
80+
};
81+
debug_test_from_buffer = {
82+
lhs = "<leader>d";
83+
desc = "run test from buffer";
84+
};
85+
filter_failed_tests = {
86+
lhs = "<leader>fe";
87+
desc = "filter failed tests";
88+
};
89+
debug_test = {
90+
lhs = "<leader>d";
91+
desc = "debug test";
92+
};
93+
go_to_file = {
94+
lhs = "g";
95+
desc = "go to file";
96+
};
97+
run_all = {
98+
lhs = "<leader>R";
99+
desc = "run all tests";
100+
};
101+
run = {
102+
lhs = "<leader>r";
103+
desc = "run test";
104+
};
105+
peek_stacktrace = {
106+
lhs = "<leader>p";
107+
desc = "peek stacktrace of failed test";
108+
};
109+
expand = {
110+
lhs = "o";
111+
desc = "expand";
112+
};
113+
expand_node = {
114+
lhs = "E";
115+
desc = "expand node";
116+
};
117+
expand_all = {
118+
lhs = "-";
119+
desc = "expand all";
120+
};
121+
collapse_all = {
122+
lhs = "W";
123+
desc = "collapse all";
124+
};
125+
close = {
126+
lhs = "q";
127+
desc = "close testrunner";
128+
};
129+
refresh_testrunner = {
130+
lhs = "<C-r>";
131+
desc = "refresh testrunner";
132+
};
133+
};
134+
additional_args = [ ];
135+
};
136+
csproj_mappings = true;
137+
fsproj_mappings = true;
138+
auto_bootstrap_namespace = {
139+
type = "block_scoped";
140+
enabled = true;
141+
};
142+
picker = "telescope";
143+
};
144+
};
145+
};
146+
};
147+
148+
example = {
149+
plugins = {
150+
fzf-lua.enable = true;
151+
easy-dotnet = {
152+
enable = true;
153+
154+
settings = {
155+
test_runner = {
156+
enable_buffer_test_execution = true;
157+
viewmode = "float";
158+
};
159+
auto_bootstrap_namespace = true;
160+
terminal.__raw = ''
161+
function(path, action, args)
162+
local commands = {
163+
run = function()
164+
return string.format("dotnet run --project %s %s", path, args)
165+
end,
166+
test = function()
167+
return string.format("dotnet test %s %s", path, args)
168+
end,
169+
restore = function()
170+
return string.format("dotnet restore %s %s", path, args)
171+
end,
172+
build = function()
173+
return string.format("dotnet build %s %s", path, args)
174+
end,
175+
}
176+
177+
local command = commands[action]() .. "\r"
178+
require("toggleterm").exec(command, nil, nil, nil, "float")
179+
end
180+
'';
181+
picker = "fzf";
182+
};
183+
};
184+
};
185+
};
186+
}

0 commit comments

Comments
 (0)