GithubHelp home page GithubHelp logo

anton-petrov-main / mason-nvim-dap.nvim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jay-babu/mason-nvim-dap.nvim

0.0 0.0 0.0 80 KB

License: GNU Affero General Public License v3.0

Lua 100.00%

mason-nvim-dap.nvim's Introduction

mason-nvim-dap bridges mason.nvim with the nvim-dap plugin - making it easier to use both plugins together.

Introduction

mason-nvim-dap.nvim closes some gaps that exist between mason.nvim and nvim-dap. Its main responsibilities are:

  • provide extra convenience APIs such as the :DapInstall command
  • allow you to (i) automatically install, and (ii) automatically set up a predefined list of adapters
  • translate between dap adapter names and mason.nvim package names (e.g. python <-> debugpy)

It is recommended to use this extension if you use mason.nvim and nvim-dap. (This plugin won't really work without them)

**Note: this plugin uses the dap adapter names in the APIs it exposes - not mason.nvim package names.

Star History

Star History Chart

Requirements

Installation

{
    "williamboman/mason.nvim",
    "mfussenegger/nvim-dap",
    "jay-babu/mason-nvim-dap.nvim",
}
use {
    "williamboman/mason.nvim",
    "mfussenegger/nvim-dap",
    "jay-babu/mason-nvim-dap.nvim",
}

Setup

It's important that you set up the plugins in the following order:

  1. mason.nvim
  2. mason-nvim-dap.nvim

Pay extra attention to this if you're using a plugin manager to load plugins for you, as there are no guarantees it'll load plugins in the correct order unless explicitly instructed to.

require("mason").setup()
require("mason-nvim-dap").setup()

Refer to the Configuration section for information about which settings are available.

Commands

  • :DapInstall [<adapter>...] - installs the provided adapter
  • :DapUninstall <adapter> ... - uninstalls the provided adapter

Configuration

You may optionally configure certain behavior of mason-nvim-dap.nvim when calling the .setup() function. Refer to the default configuration for a list of all available settings.

Example:

require("mason-nvim-dap").setup({
    ensure_installed = { "python", "delve" }
})

Default configuration

local DEFAULT_SETTINGS = {
    -- A list of adapters to install if they're not already installed.
    -- This setting has no relation with the `automatic_installation` setting.
    ensure_installed = {},

	-- NOTE: this is left here for future porting in case needed
	-- Whether adapters that are set up (via dap) should be automatically installed if they're not already installed.
	-- This setting has no relation with the `ensure_installed` setting.
	-- Can either be:
	--   - false: Daps are not automatically installed.
	--   - true: All adapters set up via dap are automatically installed.
	--   - { exclude: string[] }: All adapters set up via mason-nvim-dap, except the ones provided in the list, are automatically installed.
	--       Example: automatic_installation = { exclude = { "python", "delve" } }
    automatic_installation = false,

    -- See below on usage
    handlers = nil,
}

Handlers usage (Automatic Setup)

The handlers table provides a dynamic way of setting up sources and any other logic needed; it can also do that during runtime. To override the fallback handler put your custom one as first list element in the table. To override any other handler pass your custom function to the respective key. Handler functions take one argument - the default config table, which you customize to your liking:

local config = {
	name -- adapter name

	-- All the items below are looked up by the adapter name.
	adapters -- https://github.com/jay-babu/mason-nvim-dap.nvim/blob/main/lua/mason-nvim-dap/mappings/adapters.lua
	configurations -- https://github.com/jay-babu/mason-nvim-dap.nvim/blob/main/lua/mason-nvim-dap/mappings/configurations.lua
	filetypes -- https://github.com/jay-babu/mason-nvim-dap.nvim/blob/main/lua/mason-nvim-dap/mappings/filetypes.lua
}

Note, especially if you are migrating from setup_handlers(), that you have to call require('mason-nvim-dap').default_setup(config) with your customized config table in all your handler overrides!

Basic Customization

require ('mason-nvim-dap').setup({
    ensure_installed = {'stylua', 'jq'},
    handlers = {}, -- sets up dap in the predefined manner
})

Advanced Customization

require ('mason-nvim-dap').setup({
    ensure_installed = {'stylua', 'jq'},
    handlers = {
        function(config)
          -- all sources with no handler get passed here

          -- Keep original functionality
          require('mason-nvim-dap').default_setup(config)
        end,
        python = function(config)
            config.adapters = {
	            type = "executable",
	            command = "/usr/bin/python3",
	            args = {
		            "-m",
		            "debugpy.adapter",
	            },
            }
            require('mason-nvim-dap').default_setup(config) -- don't forget this!
        end,
    },
})

Available Dap Adapters

See https://github.com/jay-babu/mason-nvim-dap.nvim/blob/main/lua/mason-nvim-dap/mappings/source.lua

mason-nvim-dap.nvim's People

Contributors

jay-babu avatar github-actions[bot] avatar mehalter avatar aosterhage avatar chomosuke avatar haris-ak avatar binaryfly avatar jiriks74 avatar natr1x avatar nsi-inco avatar bugsbugsbux avatar nikitalocalhost avatar jinzhongjia avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.