0

I have installed the fomlowing plugins:

  • mason.nvim
  • mason-lspconfig.nvim
  • nvim-lspconfig
  • nvim-cmp
  • cmp-nvim-lsp

(I may have forgeotten to include something, but in any way I can use LSP with this setup with lua_ls for lua)

The problem is the following: I have installed omnisharp with mason.nvim, and loaded it. Its :h lspconfig-all says next:

https://github.com/omnisharp/omnisharp-roslyn OmniSharp server based on Roslyn workspaces omnisharp-roslyn can be installed by downloading and extracting a release from here. OmniSharp can also be built from source by following the instructions here. OmniSharp requires the dotnet-sdk to be installed. By default, omnisharp-roslyn doesn’t have a cmd set. This is because nvim-lspconfig does not make assumptions about your path. You must add the following to your init.vim or init.lua to set cmd to the absolute path ($HOME and ~ are not expanded) of the unzipped run script or binary. For go_to_definition to work fully, extended textDocument/definition handler is needed, for example see omnisharp-extended-lsp.nvim

I have the following omnisharp import:

lspconfig.omnisharp.setup {
    capabilities = capabilities,
    cmd = { "dotnet", "/Users/vladyslav/.local/share/nvim/mason/packages/omnisharp/libexec/OmniSharp.dll"},
}

When I open the .cs file, I get no completion. The :LspInfo says:

enter image description here

Project structure:

➜  Lab3.6_v1.0 tree -L 1
.
├── LaTeX
├── assemblyinfo.cs
├── delivery.txt
├── part.txt
├── program.cs
├── project.txt
├── report.pdf
├── supplier.txt
└── wnd.cs

2 directories, 8 files

Why I get no omnisharp completion? I managed the lua_ls and clangd to work for easy, so I am sure this is not a config issue, it have to be related to the way lspconfig.omnisharp.setup is called. Am I using the omnisharp wrong here?

My entire config in this state can be found here: https://github.com/Dolfost/dotfiles/tree/neovim/omnisharp-issue/nvim

13/01/23 Update

I found out that the problem is in the rood_dir detection. Next setup for omnisharp LSP is working but is too basic. It just takes current working directory as project root:

            lspconfig.omnisharp.setup {
                capabilities = capabilities,
                cmd = { "dotnet", vim.fn.stdpath "data" .. "/mason/packages/omnisharp/libexec/OmniSharp.dll" },
                enable_import_completion = true,
                organize_imports_on_format = true,
                enable_roslyn_analyzers = true,
                root_dir = function ()
                    return vim.loop.cwd() -- current working directory
                end,
            }

Any suggestions to improve this function are welcome.

1
  • 1
    I'm personally using vim-rooter to ensure the Vim current working directory is the project root (vim-rooter can be configured to search for special file like .gitignore or special subfolder like .git to find the root) Jan 13 at 8:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.