Code Monkey home page Code Monkey logo

omnisharp-extended-lsp.nvim's Introduction

omnisharp-extended-lsp.nvim

Extended textDocument/definition handler that handles assembly/decompilation loading for $metadata$ documents.

How it works

By providing an alternate handler for textDocument/definition the plugin listens to all responses and if it receives URI with $metadata$ it will call custom omnisharp endpoint o#/metadata which returns full document source. This source is then loaded as a scratch buffer with name set to /$metadata$/... This allows then allows jumping to the buffer based on name or from quickfix list, because it's loaded.

Definitions from within $metadata$ documents also work, though require 1 more additional request per definition, since as it is right now, textDocument/definition doesn't properly return results when called from $metadata$ document. Because of that, this plugin additionally on response checks if request was made from $metadata$ and does another request to o#/v2/gotodefinition which works properly. Response from this is handled as as described above.

Usage

Since some functionality is missing in 0.5.1 heres a table with provided functions and for which versions they can be used:

Command Neovim 0.5.1 Neovim Nightly
vim.lsp.buf.definition() with updated global handlers Not working OK
require('omnisharp_extended').lsp_definitions() OK OK (but unnecessary)
require('omnisharp_extended').telescope_lsp_definitions() OK OK

See below for instructions based on version.

OmniSharp settings

For decompilation to work, OmniSharp extension for decompilation support might need to be enabled. See omnisharp wiki for information where omnisharp.json needs to be placed (~/.omnisharp/omnisharp.json).

{
  "RoslynExtensionsOptions": {
    "enableDecompilationSupport": true
  }
}

For Neovim nightly (0.6 or later)

To use this plugin all that needs to be done is for the nvim lsp handler for textDocument/definition be overriden with one provided by this plugin.

If using lspconfig this can be done like this:

First configure omnisharp as per nvim-lspconfig.

Then to that config add handlers with custom handler from this plugin.

local pid = vim.fn.getpid()
-- On linux/darwin if using a release build, otherwise under scripts/OmniSharp(.Core)(.cmd)
local omnisharp_bin = "/path/to/omnisharp-repo/run"
-- on Windows
-- local omnisharp_bin = "/path/to/omnisharp/OmniSharp.exe"

local config = {
  handlers = {
    ["textDocument/definition"] = require('omnisharp_extended').handler,
  },
  cmd = { omnisharp_bin, '--languageserver' , '--hostPID', tostring(pid) },
  -- rest of your settings
}

require'lspconfig'.omnisharp.setup(config)

For Neovim 0.5.1

Due to the fact that in 0.5.1 request params are not available is handler response a function to go to definitions has to be invoked manually. One option is to use telescope method explained in the next section or to use lsp_definitions() function which mimics standard definitions behavior.

nnoremap gd <cmd>lua require('omnisharp_extended').lsp_definitions()<cr>

Telescope

This handler can also be used for nvim-telescope:

nnoremap gd <cmd>lua require('omnisharp_extended').telescope_lsp_definitions()<cr>

Important notes

  • !! Plugin searches for LSP server configured with the name omnisharp, so if your server is configured using a different name, this will not work out of the box.

omnisharp-extended-lsp.nvim's People

Contributors

hoffs avatar dncc89 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.