Grimoire Language Server is a scaffold for building your own grimoire: a personalized AI-powered language server. Your grimoire can integrate with your editor via the language server protocol, and can be used alongside your existing language servers and tooling, or on its own for languages that do not have a language server.
Grimoire Language Server is built on top of pygls
,
a python library that greatly simplifies the implementation of language servers.
grimoire_ls
provides scaffolding around pygls
and extra helper functions to
make your grimoire more tinker-friendly, and to support its two use-cases that are
unique among language servers: integration with generative AI, and re-use of the
same language server with many different programming languages.
Warning
This project is in early stages of development. I welcome any early adopters who would like to test it and I value your feedback! However, please be advised that the APIs may change as the project develops.
First install the server:
- Install
uv
- Clone this repository and enter it in a terminal
- Create a virtual environment:
uv venv
- Install the this project into the env
uv pip install .
Then configure your editor to use the server:
nvim_create_augroup("grimoire-ls", { clear = true })
nvim_create_autocmd("BufEnter", {
group = "grimoire-ls",
pattern = ""
callback = function()
vim.lsp.start({
name = "grimoire-ls",
cmd = {"/absolute/path/to/cloned/grimoire-ls/.venv/bin/python", "-m", "grimoire_ls.run"},
capabilities = vim.lsp.protocol.make_client_capabilities(),
root_dir = vim.fn.getcwd(),
})
end,
})
(Coming soon)
(Coming soon)
In your cloned repository:
git pull
uv pip install --upgrade .
The simplest grimoire is a single python file called init.py
. You can
indicate where your init.py
is saved in the following ways (in order
of precedence):
- Set the environment variable
GRIMOIRE_LS_HOME
to the path of the directory containing the file. - If your system defines the environment variable
XDG_CONFIG_HOME
, put the file at$XDG_CONFIG_HOME/grimoire-ls/init.py
- Put the file at
$HOME/.config/grimoire-ls/init.py
To get started, check out the examples
folder for some example configurations.
In addition, pygls
provides a full implementation of the language server protocol and
GrimoireServer
inherits from pygls.LanguageServer
, so you can also consult the
pygls
documentation if you would like to use
any of its features directly.
If you would like to install additional python dependencies for your grimoire, make sure you
install them into the virtual environment that you created during installation. An easy way
to do this is to use uv
to install them:
cd
into the clonedgrimoire-ls
repository- Install your dependencies with
uv
:uv pip install <some package>
Absolutely! Check out examples/llama_cpp
for an example.
Sure! As long as you have an API key, anything shown in their API tutorials can be done in your grimoire.
Yes! Your grimoire configuration is just regular python code. Any library you can install on your machine can be used in your grimoire.
Ecosystem
Python has the earliest adoption and most support for generative AI tools. In fact, many implementations of new ideas are available in python first because most cutting-edge research in this area uses python. I feel that having early access to the latest tools and ideas fits grimoire's intended purpose: allowing users to tinker and create their own creative and wonderful tools.
Scripting is not the bottleneck
In the majority of cases, the performance bottleneck of your grimoire will be the models themselves, not the glue code around them. As such, python's relative lack of performance is not likely to affect your experience much.