angularjs-lsp
Language Server Protocol (LSP) implementation for AngularJS 1.x applications.
Features
- Completion - Auto-complete AngularJS controllers, services, directives, and methods
- Context-aware: Controllers are excluded from completions when inside a controller
$scope. completions show only properties/methods from the current controller
- Service method completions with
ServiceName. prefix
- Go to Definition - Jump to AngularJS component, service, controller, and directive definitions
- Find References - Find all usages of AngularJS symbols across your workspace
- Hover Information - Display type and documentation information on hover
- Signature Help - Display function parameter hints while typing
- CodeLens - Show controller/template relationships with navigation support
- Workspace Symbol - Search AngularJS symbols across the workspace (
Ctrl+T / Cmd+T)
- Diagnostics - Show warnings for undefined scope properties and local variables in HTML templates
- TypeScript Fallback - Automatically falls back to
typescript-language-server for non-AngularJS symbols
Supported AngularJS Constructs
- Controllers (
app.controller())
- Services (
app.service(), app.factory())
- Directives (
app.directive())
- Components (
app.component())
- Modules (
angular.module())
Installation
Building from Source
git clone https://github.com/mochi33/angularjs-lsp.git
cd angularjs-lsp
cargo build --release
The binary will be located at target/release/angularjs-lsp.
Prerequisites
- Rust 1.70+
- (Optional)
typescript-language-server for fallback support
AI Coding Agent Setup
Claude Code
-
マーケットプレイスを追加:
claude plugin marketplace add mochi33/angularjs-lsp
-
プラグインをインストール:
claude plugin install angularjs-lsp-plugin
angularjs-lsp バイナリがPATHに必要です。ビルド済みバイナリは Releases からダウンロードするか、ソースからビルドしてください。
GitHub Copilot (CLI / VS Code)
language-servers 設定でLSPサーバーを登録できます。~/.config/github-copilot/config.json に以下を追加:
{
"language-servers": {
"angularjs": {
"command": "angularjs-lsp",
"languages": ["javascript", "html"]
}
}
}
Editor Setup
Neovim (nvim-lspconfig)
local lspconfig = require('lspconfig')
local configs = require('lspconfig.configs')
if not configs.angularjs_lsp then
configs.angularjs_lsp = {
default_config = {
cmd = { '/path/to/angularjs-lsp' },
filetypes = { 'javascript', 'html' },
root_dir = lspconfig.util.root_pattern('package.json', '.git'),
},
}
end
lspconfig.angularjs_lsp.setup({})
Custom Commands
CodeLens uses the angularjs.openLocation command for navigation. Add this handler to enable CodeLens click-to-jump:
vim.lsp.commands["angularjs.openLocation"] = function(command, ctx)
local locations = command.arguments[1]
if #locations == 0 then
return
elseif #locations == 1 then
-- Single location: jump directly
local loc = locations[1]
vim.cmd("edit " .. vim.uri_to_fname(loc.uri))
vim.api.nvim_win_set_cursor(0, { loc.range.start.line + 1, loc.range.start.character })
else
-- Multiple locations: show selection UI
vim.ui.select(locations, {
prompt = "Select location:",
format_item = function(loc)
return vim.fn.fnamemodify(vim.uri_to_fname(loc.uri), ":t")
end,
}, function(selected)
if selected then
vim.cmd("edit " .. vim.uri_to_fname(selected.uri))
vim.api.nvim_win_set_cursor(0, { selected.range.start.line + 1, selected.range.start.character })
end
end)
end
end
VS Code
-
Build the extension:
cd vscode-extension
npm install
npm run compile
-
In VSCode, open the vscode-extension folder and press F5 to launch Extension Development Host, or package as VSIX:
npm run package
-
Configure the server path in VS Code settings:
{
"angularjsLsp.serverPath": "/path/to/angularjs-lsp/target/release/angularjs-lsp"
}
Configuration
Create an ajsconfig.json file in your project root to customize the language server behavior.
{
"include": ["src/**/*.js", "app/**/*.js"],
"exclude": ["**/test/**", "**/vendor/**"],
"cache": true,
"diagnostics": {
"enabled": true,
"severity": "warning"
}
}
Options