Skip to content

fschaal/azfunc.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ azfunc.nvim

Debug .NET isolated Azure Functions in Neovim with automatic process attachment and smart project detection.

🎬 Demo

Demo

Neovim License


✨ Features

  • 🔍 Smart Project Detection - Automatically finds Azure Functions projects in your workspace
  • 🎯 Intelligent Attachment - Finds and attaches to .NET worker processes with configurable retry logic
  • 🔌 DAP Integration - Works seamlessly with your existing nvim-dap setup
  • 🎨 Interactive Picker - Choose from multiple projects with a beautiful selection UI
  • 📟 Terminal Management - Dedicated terminal for Azure Functions logs
  • 💫 Visual Feedback - Spinner notifications to track the attachment process
  • ⌨️ Configurable Mappings - Customize or disable key mappings
  • 🧹 Auto Cleanup - Automatically stops processes and closes terminals

📋 Requirements

Neovim

  • Neovim >= 0.8.0

Plugins

  • nvim-dap (required)
  • Any notification plugin that integrates with vim.notify (optional)

External Tools


📦 Installation

lazy.nvim

{
    "fschaal/azfunc.nvim",
    dependencies = { "mfussenegger/nvim-dap" },
    config = function()
        require("azfunc").setup({
            mappings = {
                start = "<leader>fs",
                stop = "<leader>fS",
            },
        })
    end,
}

packer.nvim

use {
    "fschaal/azfunc.nvim",
    requires = { "mfussenegger/nvim-dap" },
    config = function()
        require("azfunc").setup()
    end
}

vim-plug

Plug 'mfussenegger/nvim-dap'
Plug 'fschaal/azfunc.nvim'

Then in your init.lua:

require("azfunc").setup()

🔧 Configuration

DAP Adapter Setup

First, configure your .NET debugger with nvim-dap:

local dap = require("dap")

dap.adapters.coreclr = {
    type = "executable",
    command = "/path/to/netcoredbg",
    args = { "--interpreter=vscode" },
}

Plugin Configuration

require("azfunc").setup({
    -- ⌨️ Key mappings
    mappings = {
        start = "<leader>fs",  -- Start Azure Function
        stop = "<leader>fS",   -- Stop Azure Function
    },

    -- 🐛 Debug settings
    debug = {
        adapter_type = "coreclr",       -- DAP adapter type
        attach_retry_count = 20,        -- Retry attempts
        retry_interval = 2000,          -- ms between retries
        attach_timeout = 1000,          -- Initial delay
    },

    -- 📟 Terminal settings
    terminal = {
        split = "vsplit",               -- "vsplit", "split", or "tabnew"
        size = nil,                     -- nil = default size
    },

    -- 🎨 UI settings
    ui = {
        notifications = true,           -- Show notifications
        spinner_preset = "default",     -- "default", "dots", "arrows", "lines"
    },

    -- ⚙️ Azure Functions CLI
    func_cli = {
        command = "func",
        args = "host start --dotnet-isolated-debug",
    },
})

Quick Examples

📝 Minimal Setup
require("azfunc").setup()
🎹 Custom Key Mappings
require("azfunc").setup({
    mappings = {
        start = "<leader>af",
        stop = "<leader>as",
    },
})
🚫 Disable Auto-Mappings
require("azfunc").setup({
    mappings = false,
})

-- Define your own
vim.keymap.set("n", "<F5>", require("azfunc").start)
vim.keymap.set("n", "<F6>", require("azfunc").stop)
🔁 Increase Retry Attempts
require("azfunc").setup({
    debug = {
        attach_retry_count = 30,
        retry_interval = 1500,
    },
})

🚀 Usage

Commands

Command Description
:AzFuncStart Start debugging (opens picker for multiple projects)
:AzFuncStop Stop the current debug session
:AzFuncList List all Azure Functions projects

Default Key Mappings

Mapping Action
<leader>fs Start debugging
<leader>fS Stop debugging

Lua API

-- Start with project picker
require("azfunc").start()

-- Start specific project
require("azfunc").start_from_path("/path/to/project")

-- Stop current session
require("azfunc").stop()

-- List all projects
local projects = require("azfunc").list_projects()

🔄 How It Works

1. 🔍 Scan workspace for Azure Functions projects
2. 📋 Show project picker (if multiple found)
3. 📟 Open terminal for logs
4. ▶️  Start Azure Functions in debug mode
5. 🔎 Poll for .NET worker process
6. 🔌 Attach nvim-dap to the process
7. ✅ Ready to debug!

Typical Workflow

  1. Open your Azure Functions project in Neovim
  2. Set breakpoints with :lua require('dap').toggle_breakpoint()
  3. Press <leader>fs to start debugging
  4. Select your project (if multiple exist)
  5. Wait for the spinner to confirm attachment
  6. Trigger your function (HTTP request, timer, etc.)
  7. Debug with DAP commands (step, inspect, etc.)
  8. Stop with <leader>fS when done

Alternative ways to stop:

  • Press <F5> (DAP continue) and then terminate the DAP session
  • Use :lua require('dap').terminate() to stop the DAP session directly

🔧 Troubleshooting

❌ "nvim-dap is not installed"

Make sure you have nvim-dap installed and in your Neovim runtime path.

❌ "No Azure Functions projects found"

The plugin looks for .csproj files with <AzureFunctionsVersion>. Ensure:

  • You're in your workspace root
  • Your .csproj has <AzureFunctionsVersion>v4</AzureFunctionsVersion>
  • The project isn't in bin/ or obj/
❌ "Failed to attach to Azure Function"

Common causes:

  • Azure Functions Core Tools not installed (func --version)
  • Function app failed to start (check terminal output)
  • Process exited before attachment
  • Try increasing attach_retry_count in config
❌ "A debug session is already active"

Stop the current session first with :AzFuncStop or <leader>fS.

❌ Debugger doesn't attach

Verify your DAP adapter configuration:

local dap = require("dap")
dap.adapters.coreclr = {
    type = "executable",
    command = "/path/to/netcoredbg",
    args = { "--interpreter=vscode" },
}

Test with a simple .NET console app first.


🤝 Contributing

Contributions are welcome! Here's how you can help:

  • 🐛 Report bugs or request features via GitHub Issues
  • 🔧 Submit pull requests with bug fixes or features
  • 📚 Improve documentation
  • 💬 Share your configuration and workflows

Development Setup

  1. Clone the repository
  2. Make your changes
  3. Test with real Azure Functions projects
  4. Submit a pull request

🗺️ Roadmap

  • 🔀 Multiple function apps running simultaneously
  • ☁️ Azure portal integration for fetching app settings

📄 License

MIT License - See LICENSE file for details


🙏 Acknowledgments


🔗 Related Projects


💖 Support

⭐ If you find this plugin useful, please star the repository!

☕ Like this plugin? Buy me a coffee!

💬 Questions or issues? Open an issue on GitHub!


Made with ❤️ for the Neovim community

About

⚡ Seamlessly debug Azure Functions in Neovim with automatic DAP integration

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages