adamkali / dotnvim

A plugin for dotnet development because i really dislike the tooling in neovim for dotnet
MIT License
30 stars 2 forks source link
dotnet dotnet-framework neovim-plugin web-development

dotnvim (Unstable)

Introduction

dotnvim is the .NET tooling for Neovim that you've always wanted. .NET development in Neovim can be challenging due to the lack of robust tooling, especially compared to the support available for other languages like Rust with rustaceanvim, and of course the ide that shall not be named. This plugin aims to fill that gap, providing a seamless development experience for .NET developers who prefer Neovim. Enjoy!

If you like what dotnvim is doing here, want to see more, or just not ready to add it to your config: please leave a star, it means the world.

If you would like to try out the plugin in a containerized way, go ahead and check out dotnvim-config to try out the plugin. And while you are there, give it a star as well ;)

Table of Contents

Sample Config

local function dotnet_bootstrap()
    local dotnet = require 'dotnvim'
    dotnet.bootstrap()
end

local function dotnet_build_last()
    local dotnet = require 'dotnvim'
    dotnet.build(true)
end

local function dotnet_watch_last()
    local dotnet = require('dotnvim')
    dotnet.watch(true)
end

local function dotnet_restart_watch()
    local dotnet = require('dotnvim')
    dotnet.restart_watch()
end

local function dotnet_shutdown_watch()
    local dotnet = require('dotnvim')
    dotnet.shutdown_watch()
end

local function dotnet_nuget_auth()
    local dotnet = require('dotnvim')
    dotnet.nuget_auth()
end

return {
    {
        dir = 'adamkali/dotnvim',
        ft = { 'cs', 'vb', 'csproj', 'sln', 'slnx', 'props', 'csx', 'targets' },
        keys = {
            { '<leader>ds', dotnet_bootstrap, desc = 'Bootstrap Class' },
            { '<leader>db', dotnet_build_last, desc = 'Build Last Project' },
            { '<leader>dw', dotnet_watch_last, desc = 'Watch Last Project' },
            { '<F10>', dotnet_restart_watch, desc = 'Restart Watch Job'},
            { '<F34>', dotnet_shutdown_watch, desc = 'Shutdown Watch Job'},
            { '<leader>dna', dotnet_nuget_auth, desc = 'Authenticate Nuget Sources' }
        },
        config = function()
            require('dotnvim').setup {
                nuget = {
                    sources = {
                        "efilemadeeasy"
                    },
                    authenticators = {
                        {
                            cmd = "aws",
                            args = { "codeartifact", "login", "--tool", "dotnet", "--domain", "YOUR_LIB", "--domain-owner", "AWSID", "--repository", "YOUR_REPO" }
                        },
                        {
                            cmd = "foo",
                            args = { "--username", "fat", "--password", "B4s+4rd"}
                        },
                    },
                },
            }
        end
    },
}

Features

require('dotnvim').bootstrap()

bootstraps in the current namespace and directory, when given a class name.

C# Model

Bootstraps a Model with a default getter and setter.

ASP.NET API Controller

Bootstraps a MVC controller similar to the VS.

ASP.NET API Controller With Read Write

Bootstraps a MVC controller with the CRUD methods

require('dotnvim').build(last)

Builds a project based on the Solution root. (i.e. where the .sln). The last parameter refers to if you have already built a project, and you pass in true, dotnvim will build the last used project as its solution.

require('dotnvim').watch(last)

starts a watch process on the Solution root. (i.e. where the .sln).

require('dotnvim').nuget_auth()

Authenticates users to any configured dotnet nuget source. In the sample config, there is an example with aws codeartifact. but realistically if you know how to authenticate with the cli, then pass those params into one of the authenticators.

[!Note] Whatever the cmd = "..." passed in is must be callable and in path. This will file otherwise

Dap support

dotnvim has support for debugging based on .vscode/launch.json and the ability to add configurations in `require().setup({ dap.configuraitons = { }}). Here is a good example of one:

{
    "$schema": "https://raw.githubusercontent.com/mfussenegger/dapconfig-schema/master/dapconfig-schema.json",
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Launch (web)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/eFileMadeEasy.Client.API/bin/Debug/net6.0/eFileMadeEasy.Client.API.dll",
            "env": {
                "ASPNETCORE_ENVIRONMENT": "Development",
                "ASPNETCORE_URLS": "https://localhost:44392;http://localhost:44391"
            }
        }
    ]
}

Then use your own dap configuration as usual!.

Required Executables

Required for Debugging

Neovim Plugin Dependencies

Required for Debugging

Neovim Plugin Optional Dependencies

Contributing

Thank you! please see CONTRIBUTING and check out the Issues

Credits