|
| 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