odoo-shortcuts

LSP and Language Features

Odoo Shortcuts includes a proprietary Language Server (LSP) that provides intelligent autocomplete, code navigation, and static analysis for JavaScript/TypeScript in the Odoo context.

OWL LSP Features
OWL LSP 1
OWL LSP 2
OWL LSP 3
OWL LSP 4

๐Ÿš€ LSP Features

Intelligent Autocomplete

The LSP provides context-aware autocomplete for:

Code Navigation

Real-time Analysis

โš™๏ธ Configuration

Odoo Server Paths

The LSP needs to know where Odoo files are to index them:

{
  "odooShortcuts.odooServerPaths": [
    "/home/user/odoo",
    "/home/user/enterprise"
  ]
}

LSP Activation

The LSP starts automatically when you open JavaScript/TypeScript files. It activates for:

๐Ÿ“Š LSP Commands

Restart LSP

Restart the language server (useful if there are issues):

Command: Odoo Shortcuts: Restart OWL/JS Language Server

Reindex JavaScript

Force reindexing of all JavaScript files:

Command: Odoo Shortcuts: Reindex JavaScript Files (LSP)

Shows a notification with progress and result.

Auto Import

When you use an unimported symbol, the LSP can suggest automatic imports.

๐ŸŽฏ Usage Examples

Component Autocomplete

Component Autocomplete

/** @odoo-module **/
import { Component } from "@odoo/owl";

export class MyComponent extends Component {
    setup() {
        // Type "use" and press Ctrl+Space
        this.state = useState({});  // โ† Autocompletes useState
    }
}

Go to Definition

import { Dialog } from "@web/core/dialog/dialog";

// Ctrl+Click on "Dialog" to go to its definition

Auto Import

/** @odoo-module **/

// Type "Component" without importing it
class MyComponent extends Component {
    // LSP will suggest: import { Component } from "@odoo/owl";
}

๐Ÿ“ˆ Progress Bar

When the LSP is indexing files, youโ€™ll see in the status bar:

๐Ÿ”„ Indexing JS: 45%

This indicates the server is scanning your codebase. Once completed, all features will be available.

๐Ÿ› Troubleshooting

LSP doesnโ€™t start

  1. Verify you have JavaScript/TypeScript files open
  2. Check server path in configurations
  3. Restart LSP manually

Autocomplete doesnโ€™t work

  1. Wait for initial indexing to finish
  2. Reindex files manually
  3. Verify files have /** @odoo-module **/

Slow performance

If you have a very large codebase:

  1. Reduce paths in odooServerPaths to only whatโ€™s necessary
  2. Exclude directories in .gitignore
  3. Restart VS Code if necessary

Connection errors

If you see connection errors to the LSP:

  1. Close and reopen VS Code
  2. Restart the LSP
  3. Verify no other process is using the port

๐Ÿ”ง Architecture

The LSP is divided into two parts:

Client (VS Code Extension)

Server (Node.js)

๐Ÿ“š Supported Symbols

The LSP indexes and provides information about:

๐ŸŽจ Customization

The LSP behavior automatically adjusts based on:

No additional manual configuration required.


Next: CodeLens