Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I pass on_attach and capabilities to omnisharp? #2

Closed
bartoszluka opened this issue Feb 13, 2024 · 4 comments
Closed

How do I pass on_attach and capabilities to omnisharp? #2

bartoszluka opened this issue Feb 13, 2024 · 4 comments

Comments

@bartoszluka
Copy link

I have custom LSP mappings that work for all language servers and I would like to pass them to omnisharp using this plugin. Is this possible now?

@iabdelkareem
Copy link
Owner

Thank you for your input, @bartoszluka I'll extend the configuration to allow passing capabilities and on_attach. There's another way to add the custom mapping that I personally prefer, which is to use LspAttach autocmd instead of passing the on_attach function.

e.g.,

	vim.api.nvim_create_autocmd("LspAttach", {
		callback = function(args)
			local bufnr = args.buf
			local client = vim.lsp.get_client_by_id(args.data.client_id)

			if client.name ~= "omnisharp" then
				return
			end

			vim.keymap.set("n", "gd", require("csharp").go_to_definition, { silent = true, nowait = true, noremap = true, desc = "Go to Definition", buffer = bufnr })
		end,
	})

@bartoszluka
Copy link
Author

That is exactly what I ended up doing, funny we figured out the same solution to this.

@iabdelkareem
Copy link
Owner

Yes @bartoszluka 😄 I pushed a commit which adds capabilities and on_attach to the configuration. Thank you for the suggestion ^^

@bartoszluka
Copy link
Author

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants