Crates.io | odoo-lsp |
lib.rs | odoo-lsp |
version | 0.5.0 |
source | src |
created_at | 2023-08-27 06:20:35.979492 |
updated_at | 2024-08-28 03:33:11.166455 |
description | Language server for Odoo Python/JS/XML |
homepage | |
repository | https://github.com/Desdaemon/odoo-lsp |
max_upload_size | |
id | 955911 |
size | 475,960 |
Works for record
s, template
s, env.ref()
and other structures.
For VSCode, also includes schema-based validation and completions for Odoo XML.
Provides syntax highlighting in VSCode for Python, JavaScript, and XPath expressions in Odoo XML.
https://github.com/Desdaemon/odoo-lsp/assets/36768030/6003d5fe-9617-41df-ae3d-a704af77455c
For more features check out the wiki.
The VSCode extension handles downloading the latest releases automatically; other editors need odoo-lsp
on the path.
Nightly binaries are also available for major platforms, please check Releases for the latest downloads.
# One-line
curl -L https://github.com/Desdaemon/odoo-lsp/releases/download/nightly/odoo-lsp-x86_64-unknown-linux-musl.tgz | tar -xzvf -
# Apple Silicon
curl -L https://github.com/Desdaemon/odoo-lsp/releases/download/nightly/odoo-lsp-aarch64-apple-darwin.tgz | tar -xzvf -
# With cargo-binstall
cargo binstall odoo-lsp
# Install from source
cargo install odoo-lsp
# Update in-place, optionally with --nightly
odoo-lsp self-update
For detailed usage instructions please check the wiki (work in progress).
odoo-lsp is available from the Visual Studio Marketplace and the Open VSX Registry. Alternatively, you can grab the latest nightly builds from Releases.
odoo-lsp
on your path~/.config/helix/
on Linuxlanguages.toml
in your Helix runtime folder (create one if none exists) to include these lines:[language-server]
# Update the path to match your setup
odoo-lsp.command = "odoo-lsp"
[[language]]
name = "xml"
language-servers = ["odoo-lsp"]
roots = [".odoo_lsp", ".odoo_lsp.json"]
[[language]]
name = "python"
roots = [
".odoo_lsp", ".odoo_lsp.json",
# add the default roots here
]
# Order is important here
language-servers = [
"odoo-lsp",
# add the default language servers here
"pylsp",
# and any you need
]
$ROOT/.helix/languages.toml
where $ROOT
is your Odoo modules root to include the above lines.Instructions copied from lsp-zero docs
odoo-lsp
on your path~/.config/nvim/init.lua
to use lsp-zero.nvim,
adding odoo-lsp as a new server before calling lsp.setup()
:-- lsp-zero stanza
local lsp = require('lsp-zero').preset({})
lsp.on_attach(function(client, bufnr)
lsp.default_keymaps({buffer = bufnr})
end)
local lspconfigs = require 'lspconfig.configs'
-- define our custom language server here
lspconfigs.odoo_lsp = {
default_config = {
name = 'odoo-lsp',
cmd = {'odoo-lsp'},
filetypes = {'javascript', 'xml', 'python'},
root_dir = require('lspconfig.util').root_pattern('.odoo_lsp', '.odoo_lsp.json', '.git')
}
}
local configured_lsps = {
odoo_lsp = {},
-- optional but recommended, requires pyright-langserver on path
pyright = {},
}
local lspconfig = require 'lspconfig'
for name, config in pairs(configured_lsps) do
lspconfig[name].setup(config)
end
-- LSP setup done
lsp.setup()
A complete example can be found in examples/init.lua.
Run your editor with the RUST_LOG
environment variable like below, e.g. for VSCode:
RUST_LOG=odoo_lsp=debug code ..
This will enable debug logs for the LSP server itself, which can be seen via your editor's logging mechanism. Please include these logs when opening an issue.
Don't know where to start? Run cargo doc --bin odoo-lsp
for a quick overview of the codebase. All contributions welcome!
pnpm i
cargo build
Launch Client
Note If encountered errors like
Cannot find module '/xxx/xxx/dist/extension.js'
please try run commandtsc -b
manually, you could refer https://github.com/IWANABETHATGUY/tower-lsp-boilerplate/issues/6 for more details