NormalNvim / NormalNvim

A normal Neovim distribution
https://normalnvim.github.io/NormalNvim/
GNU General Public License v3.0
439 stars 168 forks source link

Need help installing roslyn.nvim #459

Closed Crashdummyy closed 1 week ago

Crashdummyy commented 1 week ago

Hi there,

I am lost trying to install roslyn.nvim correctly.

I added this to 3-dev-core.lua but on_attach is never called:

{
  "seblj/roslyn.nvim",
  event = "User BaseFile",
  config = function()
    require("roslyn").setup({
      dotnet_cmd = "dotnet", -- this is the default
      roslyn_version = "4.12.0-1.24329.2", -- this is the default
      on_attach = function(client)
        local utils = require("base.utils")
        utils.notify("attached")

-- make sure this happens once per client, not per buffer
if not client.is_hacked then
  client.is_hacked = true

  -- let the runtime know the server can do semanticTokens/full now
  client.server_capabilities = vim.tbl_deep_extend("force", client.server_capabilities, {
    semanticTokensProvider = {
      full = true,
    },
  })

  -- monkey patch the request proxy
  local request_inner = client.request
  client.request = function(method, params, handler)
    if method ~= vim.lsp.protocol.Methods.textDocument_semanticTokens_full then
      return request_inner(method, params, handler)
    end

    local function find_buf_by_uri(search_uri)
      local bufs = vim.api.nvim_list_bufs()
      for _, buf in ipairs(bufs) do
        local name = vim.api.nvim_buf_get_name(buf)
        local uri = "file://" .. name
        if uri == search_uri then
          return buf
        end
      end
    end

    local doc_uri = params.textDocument.uri

    local target_bufnr = find_buf_by_uri(doc_uri)
    local line_count = vim.api.nvim_buf_line_count(target_bufnr)
    local last_line = vim.api.nvim_buf_get_lines(target_bufnr, line_count - 1, line_count, true)[1]

    return request_inner("textDocument/semanticTokens/range", {
      textDocument = params.textDocument,
      range = {
        ["start"] = {
          line = 0,
          character = 0,
        },
        ["end"] = {
          line = line_count - 1,
          character = string.len(last_line) - 1,
        },
      },
    }, handler)
  end
end
end
    })
  end
},

The LSP however is loaded. I need that on_attach for semantic tokens to work.

That being said the lsp works as intended it's just that I cant use the on_attach.

And roslyn does not appear in server_name in this function as well.

function M.apply_user_lsp_settings(server_name)
  local server = require("lspconfig")[server_name]
Crashdummyy commented 1 week ago

Okay I got it "solved" but I really dont know if this is the correct way.

How would I add a new lsp when I can't obtain it from mason ?