Skip to content

Commit

Permalink
feat: add capabailities and on_attach config
Browse files Browse the repository at this point in the history
Adds the ability to pass capabilities and on_attach to the LSP client

resolves #2
  • Loading branch information
iabdelkareem committed Feb 14, 2024
1 parent 4d23e97 commit c0b6c0d
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 8 deletions.
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Added

- Automatic debugger installation
- Enhanced experience to select and launch debugging target
- Commands to build and run dotnet projects

## [0.1.0] - 2024-02-14

### Added

- Configuration option to enable/disable automatic installation and launch of omnisharp.
- Option to launch omnisharp server in debug mode.
- Allow passing capabilities and on_attach to the LSP client.

### Changed

- Replaces custom logic that merges user configuration and default configuration with simple table merge.

### Fixed

- Configuration option `lsp.cmd_path` doesn't work as intended.

## [0.0.1] - 2024-02-05

### Added

- Initial plugin release [csharp.nvim](https://github.com/iabdelkareem/csharp.nvim)
- Automatic installation and launch of omnisharp
- Remove unused using statements
- Fix All
- Enhanced Go-To-Definition (Decompilation Support)
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

`csharp.nvim` is a Neovim plugin written in Lua, powered by [omnisharp-roslyn](https://github.com/OmniSharp/omnisharp-roslyn), that aims to enhance the development experience for .NET developers.

##### NOTE

_This plugin is in early development stage._
**🚧 NOTE: This plugin is in early development stage.**

## Prerequisites

- Install [fd](https://github.com/sharkdp/fd#installation) locally.

## Installation
## 🚀 Installation

Using lazy.nvim:

Expand All @@ -27,14 +25,17 @@ Using lazy.nvim:
}
```

## Configuration
:warning: This plugin removes the usage of lspconfig to configure and run Omnisharp, and it shouldn't be used alongside lspconfig. Please remove the configuration of omnisharp in lspconfig. If you want to use lspconfig to configure Omnisharp, you can still use the other functionality provided by the plugin (e.g., remove unused using statements, etc.). However, you should set `config.lsp.enable` to `false`.

## ⚙ Configuration

```lua
-- These are the default values
{
lsp = {
-- When set to true, csharp.nvim won't install omnisharp automatically and use it via mason.
-- Instead, the omnisharp instance in the cmd_path will be used.
-- When set to false, csharp.nvim won't launch omnisharp automatically.
enable = true,
-- When set, csharp.nvim won't install omnisharp automatically. Instead, the omnisharp instance in the cmd_path will be used.
cmd_path = nil,
-- The default timeout when communicating with omnisharp
default_timeout = 1000,
Expand All @@ -47,6 +48,12 @@ Using lazy.nvim:
include_prerelease_sdks = true,
analyze_open_documents_only = false,
enable_package_auto_restore = true,
-- Launches omnisharp in debug mode
debug = false,
-- The capabilities to pass to the omnisharp server
capabilities = nil,
-- on_attach function that'll be called when the LSP is attached to a buffer
on_attach = nil
},
logging = {
-- The minimum log level.
Expand All @@ -55,7 +62,7 @@ Using lazy.nvim:
}
```

## Features
## 🌟 Features

### Remove Unnecessary Using Statements

Expand Down
4 changes: 4 additions & 0 deletions lua/csharp/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ local default_config = {
default_timeout = 1000,
enable_package_auto_restore = true,
debug = false,
--- @type table<string, any>|nil
capabilities = nil,
---@type fun(client: lsp.Client, bufnr: number)|nil
on_attach = nil,
},
---@class CsharpConfig.Logging
logging = {
Expand Down
2 changes: 2 additions & 0 deletions lua/csharp/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ local function start_omnisharp(args)
name = "omnisharp",
cmd = cmd,
root_dir = root_dir,
capabilities = config.capabilities,
on_attach = config.on_attach,
}, {
bufnr = buffer,
})
Expand Down

0 comments on commit c0b6c0d

Please sign in to comment.