{"id":15974436,"url":"https://github.com/patwie/polyglot_ls","last_synced_at":"2025-09-12T15:56:07.385Z","repository":{"id":250949203,"uuid":"835944286","full_name":"PatWie/polyglot_ls","owner":"PatWie","description":"An LLM-based LS implementation that makes use of tree-sitter context to perform code actions","archived":false,"fork":false,"pushed_at":"2024-09-06T13:51:21.000Z","size":1315,"stargazers_count":4,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T05:47:47.480Z","etag":null,"topics":["aws","aws-bedrock","claude-ai","llm","lsp","lsp-server","neovim","polyglot-ls","rust","vscode"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PatWie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-30T20:54:18.000Z","updated_at":"2024-11-15T19:04:07.000Z","dependencies_parsed_at":"2024-09-06T15:45:43.976Z","dependency_job_id":"a67559d3-83a2-4a2d-bd44-c456d7ce4034","html_url":"https://github.com/PatWie/polyglot_ls","commit_stats":null,"previous_names":["patwie/llm-sitter-ls"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PatWie%2Fpolyglot_ls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PatWie%2Fpolyglot_ls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PatWie%2Fpolyglot_ls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PatWie%2Fpolyglot_ls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PatWie","download_url":"https://codeload.github.com/PatWie/polyglot_ls/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243891341,"owners_count":20364576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","aws-bedrock","claude-ai","llm","lsp","lsp-server","neovim","polyglot-ls","rust","vscode"],"created_at":"2024-10-07T21:41:37.801Z","updated_at":"2025-03-17T22:31:11.643Z","avatar_url":"https://github.com/PatWie.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Polyglot-LS\n\nThe only sensible way to bring Large Language Models (LLMs) into any editor\nthat speaks the Language Server Protocol (LSP).\n\n![Polyglot-LS Preview](.github/preview.gif)\n\nPolyglot-LS is a language server written in Rust that embeds Lua scripting,\nresponsible for creating prompts, post-processing LLM answers, and determining\nwhere to place the LLM output. It has access to the Tree-Sitter Abstract Syntax\nTree (AST) and can navigate nodes and form Tree-Sitter queries.\n\n![Polyglot-LS Overview](.github/polyglot-ls-overview-scene.svg)\n\n## Some Use Cases\n\nUtilizing Lua scripting allows you to access structured information from the\ncurrent file and construct any string for LLM prompts. Here are some practical\nuse cases:\n\n### Add Documentation\n\nAutomatically add or update docstrings for functions in various languages. This\nprovides context and determines where to place these docstrings, enabling\ndocumentation updates without altering the code.\n\n### Adjust Function Signatures\n\nUsing tree-sitter, a code-action can extract context from various parts of your\ncode, such as the function source, the nearest class source, or any specific\nTree-Sitter node. This allows you to form prompts that target other Tree-Sitter\nnodes, such as parameter lists of functions or other code segments, which can\nthen be substituted with LLM outputs. This provides you with full control over\nwhich parts of the code remain untouched, ensuring precise and targeted\nmodifications.\n\n### Chat Locally\n\nEngage with LLMs using Markdown files. When you select your prompt, all\nprevious text is used as context, and the model's response is output below,\nsimilar to web-based UIs.\n\nFor Neovim users, combine this with fuzzy-finding of all `.md` files in a\nspecific directory:\n\n```lua\nvim.keymap.set(\"n\", \"\u003cleader\u003ecc\", function()\n  builtin.find_files({\n    prompt_title = \"\u003c Chats \u003e\",\n    cwd = \"$HOME/.chats/\",\n  })\nend)\n```\n\nPair this with [undotree](https://github.com/mbbill/undotree) for powerful\nhistory features and quick access to different chats.\n\n### Fix Typos\n\nUse tree-sitter information to fix selected text wording, including Git commit\nmessages written in your editor. Or even reformulate entire Git commit\nmessages.\n\nSee [configs](./config/code_actions/) for examples.\n\n## Setup\n\n### Prerequisites\n\n- **Rust**: Install Rust from the [official Rust\n  website](https://www.rust-lang.org/tools/install).\n- **AWS Profile**: Create an AWS profile named `my-aws-bedrock` to obtain\n  credentials for using the Bedrock `anthropic.claude-3-haiku-20240307-v1:0`\n  model.\n\n### Compilation\n\n1. Clone the repository:\n\n   ```sh\n   git clone https://github.com/patwie/polyglot_ls.git\n   cd polyglot_ls\n   ```\n\n2. Build the project:\n\n   ```sh\n   cargo build --release\n   ```\n\n3. The binary will be located in `target/release/polyglot_ls`.\n\n### Using the Language Server\n\n1. Copy or symlink the contents of the `code_actions` configs directory to\n   `$HOME/.config/polyglot_ls/code_actions/`.\n\n    ```sh\n    mkdir -p ${HOME}/.config/polyglot_ls\n    ln -s $(realpath config/code_actions) ${HOME}/.config/polyglot_ls/code_actions\n    ```\n\n2. Run the server:\n\n   ```sh\n   ./target/release/polyglot_ls --socket=9257\n   ```\n\n   For direct usage in Neovim:\n\n   ```sh\n   ./target/release/polyglot_ls --stdio\n   ```\n\n## Limitations\n\n- Currently supports only the AWS Bedrock model (no ChatGPT, no Ollama).\n- Many settings are hard-coded (e.g., the used model).\n\n## Integration\n\nFor Neovim with the \"neovim/nvim-lspconfig\" plugin, use the following setup:\n\n```lua\nlocal configs = require 'lspconfig.configs'\n\nif not configs.polyglot_ls then\n    configs.polyglot_ls = {\n      default_config = {\n        cmd = { \"/path/to/polyglot_ls\" , \"--stdio\" },\n        -- for debugging, launch \"polyglot_ls\" with --bind=9257 and use:\n        -- cmd = vim.lsp.rpc.connect('127.0.0.1', 9257),\n        filetypes = { 'python', 'rust', 'text', 'go', 'gitcommit', 'markdown' },\n        single_file_support = true,\n      },\n    }\nend\n```\n\n## Configuration Tutorial\n\nSee the [Tutorial.md](./TUTORIAL.md).\n\n# Test Integration\n\nPrepare NVIM integration tests via\n\n```sh\nln -s $(realpath editor_integrations/nvim/nvim-config) ${HOME}/.config/nvim-test\nNVIM_APPNAME=nvim-test nvim --headless \"+Lazy! update\" +qa\n```\n\nThen running\n\n```sh\nNVIM_APPNAME=nvim-test ./tests/run_all.sh\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatwie%2Fpolyglot_ls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatwie%2Fpolyglot_ls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatwie%2Fpolyglot_ls/lists"}