Coder Social home page Coder Social logo

language-server-for-translation's Introduction

Language Server Protocol Extension with Python and VSCode

This README will guide you through the process of using the ServerFunctions class to extend the functionality of a Language Server Protocol (LSP) implementation using Python and Visual Studio Code (VSCode). The ServerFunctions class provides a way to add custom completion, diagnostic, and action features to your language server.

Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.7 or higher
  • Visual Studio Code
  • Install scripture-language-support from the extension store

How it works:

  1. First, you need to create an instance of LanguageServer from the pygls package:

    from pygls.server import LanguageServer
    
    server = LanguageServer("your-language-server-name", "your-version")
  2. Then, create an instance of ServerFunctions by providing the server object and a path to store project data (this is relative to the workspace):

    from your_module import ServerFunctions
    
    server_functions = ServerFunctions(server=server, data_path='/path_to_project_data')

Adding Custom Server Functions

Implementing a Skeleton Class

Create a skeleton class that will hold the logic for your completion, diagnostic, and action handlers:

def my_completion_handler(server, params, range, sf):
    # Implement your completion logic here
    pass

def my_diagnostic_handler(server, params, sf):
    # Implement your diagnostic logic here
    pass

def my_action_handler(server, params, range, sf):
    # Implement your action logic here
    pass

Registering Handlers

Register your feature handlers with the ServerFunctions instance:

# Instantiate your custom feature class
import custom_features

# Register completion, diagnostic, and action handlers
server_functions.add_completion(custom_features.my_completion_handler)
server_functions.add_diagnostic(custom_features.my_diagnostic_handler)
server_functions.add_action(custom_features.my_action_handler)

Starting the Server

After registering all your handlers, you must start the server functions and then start the language server:

if __name__ == "__main__":
    server_functions.start()
    server.start_io()

language-server-for-translation's People

Contributors

dadukhankevin avatar ryderwishart avatar

Watchers

 avatar  avatar

Forkers

yunuserez

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.