/one-small-step-for-vimkind

Debug adapter for Neovim plugins

Primary LanguageLuaMIT LicenseMIT

one-small-step-for-vimkind

one-small-step-for-vimkind is an adapter for the Neovim lua language. See the DAP protocol to know more about adapters. It allows you to debug any lua code running in a Neovim instance.

Install

Install using your prefered method for example using vim-plug

Plug 'jbyuki/one-small-step-for-vimkind'

" You will also need a comptabile DAP client

Plug 'mfussenegger/nvim-dap'

After installing one-small-step-for-vimkind, you will also need a DAP plugin which will allow you to interact with the adapter. There are mainly two available:

Configuration

Add these lines to work with nvim-dap.

local dap = require"dap"
dap.configurations.lua = { 
  { 
    type = 'nlua', 
    request = 'attach',
    name = "Attach to running Neovim instance",
    host = function()
      local value = vim.fn.input('Host [127.0.0.1]: ')
      if value ~= "" then
        return value
      end
      return '127.0.0.1'
    end,
    port = function()
      local val = tonumber(vim.fn.input('Port: '))
      assert(val, "Please provide a port number")
      return val
    end,
  }
}

dap.adapters.nlua = function(callback, config)
  callback({ type = 'server', host = config.host, port = config.port })
end

If you have a init.vim in Vimscript, include the nvim-dap configurations inside lua delimiters.

lua << END
  ...
END

Quickstart

  • Launch the server in the debuggee using require"osv".launch()
  • Open another Neovim instance with the source file
  • Place breakpoint
  • Connect using the DAP client
  • Run your script/plugin in the debuggee

Alternaltively you can:

  • Open a lua file
  • Place breakpoint
  • Invoke require"osv".run_this()

See osv.txt for more detailed instructions.

Status

Handlers:

  • attach
  • scope
  • setBreakpoints
  • stackTrace
  • threads
  • variables
  • stepIn
  • next
  • stepOut
  • continue
  • evaluate
  • pause
  • terminate
  • disconnect
  • setVariable
  • setFunctionBreakpoints
  • setExceptionBreakpoints
  • breakpointLocations

Events:

  • initialized
  • stopped
  • terminated
  • exited
  • output

Capabilities:

  • variableReferences
  • condition
  • hit condition
  • watch
  • hover

Name

it's a debugger for the moon language. - @tjdevries

Credits