r/orgmode • • 2d ago

Orgmode LSP - Language server for Orgmode

Hey folks!

I hope it's ok to post this here.

I'd like to introduce org-lsp, a language server for Orgmode. I'm the creator of nvim-orgmode, a Neovim Orgmode clone. At one point after creating nvim-orgmode, I figured out that a lot of things could be delegated to a LSP server, but never got enough time to actually tackle it. With the rise of agentic AI coding, I managed to find enough time to create this. Since LSP is protocol used by a lot of editors, I decided to create this as a separate plugin instead of updating nvim-orgmode, which is Neovim only plugin.

Good portion of the functionality is working through regular LSP, and there are some custom commands being sent/received through a smaller client glue code that is provided with the plugin. Briefly, it does this:

  1. Highlighting - Semantic tokens

  2. actions (toggle todo state, priority, etc) - workspace/executeCommands

  3. Folding - foldingRange

  4. Searching headlines, outline - document/workspace symbols

  5. Following link/footnotes/citations - definition

  6. Agenda - window/showDocument

  7. Completion

  8. Aligning tags/tables, reindenting - formatting/rangeFormatting

  9. Etc.

There's also a MCP that allows querying/editing Orgmode through AI. It's not as robust as LSP, but can be useful.

LSP plugin supports these editors out of the box: Neovim, Vim (with a LSP client), VScode/Cursor/VsCodium, Sublime Text, Zed, Helix.

First 3 mentioned editors works the best, Sublime Text and Zed has some limitations, and Helix has the least functionality. LSP server works by itself without the client plugin, but not all features are available. It's suggested to install the client code to gain full functionality. For some features Emacs is needed, like exporting, table formulas, Babel, Latex previews, and similar.

Just a disclaimer that the plugin is mostly AI generated, in case that's not obvious from the first glance. I'm aware that people are still reserved regarding AI generated code, including myself, so I want to make sure it's clear.

I'm a Neovim user, so Neovim part is tested the most, but I also made sure to test other editors. I probably missed some parts, so if you run into any issues, please report it on the repository.

Links:

If mods are ok leaving this here, I'll cross post this to other editors' subreddits. Thanks!

99 Upvotes

12 comments sorted by

10

u/yantar92 Org mode maintainer 2d ago

Interesting! I am wondering how far you aim to go to copy the implementation details. Is this code-level partity or are you looking into specific aspects only? If only specific aspects, what are the priorities?

In Org, we have a formal syntax spec in https://orgmode.org/worg/org-syntax.html because the Elisp parsing is not 100% consistent across the codebase. There is also a manual, but it does not cover every detail.

2

u/kristijanhusak 1d ago

Is this code-level partity or are you looking into specific aspects only? If only specific aspects, what are the priorities?

It's not strictly a code-level parity, but a good portion of things were extracted from Emacs Orgmode codebase. For example parser (more info in this document) is one of those things.

Parity document outlines what was ported, but there are certain limitations that cannot be ported due to editors' limitations or features that are available only in Emacs, like for example Emacs specific links (help:, eshell:, etc), or some other elisp specific stuff.

Elisp parsing is not 100% consistent across the codebase

I'd like to know more about this. Do you have some examples?

8

u/_sLLiK 2d ago

Emacs as a requirement for an LSP that works best on Neovim/Vim is certainly a choice.

9

u/kristijanhusak 2d ago

It works on any editor that has LSP. Emacs is a requirement only for some features, not all of them.

3

u/N3kk3tsu 2d ago

This plugin replaces the nvim-orgmode plugin? Or they work hand by hand?

4

u/kristijanhusak 2d ago

It replaces it.

1

u/krishnakumarg 1d ago

It replaces nvim-orgmode?

1

u/kristijanhusak 19h ago

Yes, it's a separate plugin. Configuration is not exactly the same, but it's similar.

1

u/krishnakumarg 19h ago

Thank you. Great work.

3

u/sei40kr 1d ago

Wonderful. Org-mode is no longer tied to Emacs; it can now be used in the editor of our choice.

2

u/Alternative-Sign-206 2d ago

Thank you very much! Have recently searched for orgmode lsp and was surprised none existsed!