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

feat: add doc and range formatting if clang-format is available #27

Merged
merged 6 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BasedOnStyle: Google
DerivePointerAlignment: false
PointerAlignment: Left
101 changes: 90 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "protols"
description = "Language server for proto3 files"
version = "0.5.0"
version = "0.6.0"
edition = "2021"
license = "MIT"
homepage = "https://github.com/coder3101/protols"
Expand All @@ -23,6 +23,9 @@ tree-sitter = "0.22.6"
tracing-appender = "0.2.3"
protols-tree-sitter-proto = "0.2.0"
walkdir = "2.5.0"
hard-xml = "1.36.0"
tempfile = "3.12.0"
serde = { version = "1.0.209", features = ["derive"] }

[dev-dependencies]
insta = { version = "1.39.0", features = ["yaml"] }
79 changes: 62 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,76 @@
# protols
[![Crates](https://img.shields.io/crates/v/protols.svg)](https://crates.io/crates/protols)
# Protols - Protobuf Language Server

[![Crates.io](https://img.shields.io/crates/v/protols.svg)](https://crates.io/crates/protols)
[![Build and Test](https://github.com/coder3101/protols/actions/workflows/ci.yml/badge.svg)](https://github.com/coder3101/protols/actions/workflows/ci.yml)

A Language Server for **proto3** files. It uses tree-sitter parser for all operations.
**Protols** is an open-source Language Server Protocol (LSP) for **proto3** files, powered by the robust and efficient [tree-sitter](https://tree-sitter.github.io/tree-sitter/) parser. With Protols, you get powerful code assistance for protobuf files, including auto-completion, syntax diagnostics, and more.

![](./assets/protols.mov)

## Features
- [x] Completion (keywords, enums and messages of the package)
- [x] Diagnostics - based on sytax errors
- [x] Document Symbols
- [x] Go to definition
- [x] Hover
- [x] Rename
## ✨ Features

- ✅ Code Completion
- ✅ Diagnostics
- ✅ Document Symbols
- ✅ Code Formatting
- ✅ Go to Definition
- ✅ Hover Information
- ✅ Rename Symbols

## 🚀 Getting Started

### Installation

## Installation
#### For Neovim

To install Protols, run:

```bash
cargo install protols
```

### Neovim
Run `cargo install protols` to install and add below to setup using [`nvim-lspconfig`](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#protols)
Then, configure it with [`nvim-lspconfig`](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#protols):

```lua
require'lspconfig'.protols.setup{}

```

### Visual Studio Code
#### For Visual Studio Code

You can use the [Protobuf Language Support](https://marketplace.visualstudio.com/items?itemName=ianandhum.protobuf-support) extension, which leverages this LSP under the hood.

> **Note:** This extension is [open source](https://github.com/ianandhum/vscode-protobuf-support) but is not maintained by us.

## 🛠️ Usage

### Code Completion

Protols provides intelligent autocompletion for messages, enums, and proto3 keywords within the current package.

### Diagnostics

Diagnostics are powered by the tree-sitter parser, which catches syntax errors but does not utilize `protoc` for more advanced error reporting.

### Code Formatting

Formatting is enabled if [clang-format](https://clang.llvm.org/docs/ClangFormat.html) is available. You can control the [formatting style](https://clang.llvm.org/docs/ClangFormatStyleOptions.html) by placing a `.clang-format` file in the root of your workspace. Both document and range formatting are supported.

### Document Symbols

Provides symbols for the entire document, including nested symbols, messages, and enums.

### Go to Definition

Jump to the definition of any custom symbol, even across package boundaries.

### Hover Information

Displays comments and documentation for protobuf symbols on hover. Works seamlessly across package boundaries.

### Rename Symbols

Allows renaming of symbols like messages and enums, along with all their usages across packages. Currently, renaming fields within symbols is not supported directly.

You can install an extension called [Protobuf Language Support](https://marketplace.visualstudio.com/items?itemName=ianandhum.protobuf-support) which uses this LSP under the hood.
---

> NOTE: It is [open-sourced](https://github.com/ianandhum/vscode-protobuf-support) but do not own or maintain it.
Protols is designed to supercharge your workflow with **proto3** files. We welcome contributions and feedback from the community! Feel free to check out the [repository](https://github.com/coder3101/protols) and join in on improving this tool! 🎉
Loading