Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
82a2a87
Add initial Language Server Protocol (LSP) integration
bajrangCoder Oct 10, 2025
22b9d17
fix
bajrangCoder Oct 12, 2025
6a70dd0
fix: gutter area
bajrangCoder Oct 12, 2025
9d73725
Merge branch 'Acode-Foundation:main' into lsp-codemirror
bajrangCoder Oct 13, 2025
c3b6662
Add clangd server to LSP registry
bajrangCoder Oct 13, 2025
507aa77
Remove custom install prompts from server registry
bajrangCoder Oct 13, 2025
abfed3d
Filter builtin extensions with custom diagnostics
bajrangCoder Oct 13, 2025
a8947df
Improve LSP formatter options and extension handling
bajrangCoder Oct 14, 2025
1efcc4c
fix: Emmet syntax resolution
bajrangCoder Oct 14, 2025
2494110
feat: Add CodeMirror tooltip styles
bajrangCoder Oct 16, 2025
ffcf7e5
fix
bajrangCoder Oct 16, 2025
f0133c3
fix
bajrangCoder Oct 16, 2025
7384562
Merge branch 'Acode-Foundation:main' into lsp-codemirror
bajrangCoder Oct 19, 2025
342b504
Normalize rootUri handling for LSP clients
bajrangCoder Oct 19, 2025
603089a
fix: install lsp server message
bajrangCoder Oct 19, 2025
0319ed5
chore(codemirror): migrate problems page of acode
bajrangCoder Oct 19, 2025
9ef840b
feat: add lsp and lint related commands
bajrangCoder Oct 19, 2025
91f7428
Merge branch 'Acode-Foundation:main' into lsp-codemirror
bajrangCoder Oct 24, 2025
51542cd
Simplify base URI extraction in EditorManager
bajrangCoder Oct 26, 2025
c697b7b
Merge branch 'Acode-Foundation:main' into lsp-codemirror
bajrangCoder Nov 2, 2025
efe2566
Implement cursor visibility and auto-scroll in editor
bajrangCoder Nov 3, 2025
5a7adf2
Merge remote-tracking branch 'origin/main' into lsp-codemirror
bajrangCoder Nov 7, 2025
7c83617
chore: update lsp client lib
bajrangCoder Nov 7, 2025
b3b536c
Merge remote-tracking branch 'origin/main' into lsp-codemirror
bajrangCoder Nov 23, 2025
f6e1728
update
bajrangCoder Nov 23, 2025
b28da61
feat: add vtsls and eslint lsp
bajrangCoder Nov 27, 2025
024cee1
fix: font family on different widget
bajrangCoder Nov 27, 2025
47976c7
fix
bajrangCoder Nov 27, 2025
5bdf88b
feat: add lintgutter setting to toggle lsp diag on gutter
bajrangCoder Nov 27, 2025
10a7c26
fix: keep default codemirror lint plugin to be hidden
bajrangCoder Nov 27, 2025
b808f1a
Merge remote-tracking branch 'origin/main' into lsp-codemirror
bajrangCoder Nov 27, 2025
c77359d
Merge remote-tracking branch 'origin/main' into lsp-codemirror
bajrangCoder Dec 5, 2025
02d08b0
update
bajrangCoder Dec 5, 2025
96fb2ad
Merge remote-tracking branch 'origin/main' into lsp-codemirror
bajrangCoder Dec 16, 2025
5633a60
Merge branch 'codemirror' into lsp-codemirror
bajrangCoder Dec 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/cm/baseExtensions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { closeBrackets } from "@codemirror/autocomplete";
import { closeBrackets, completionKeymap } from "@codemirror/autocomplete";
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
import {
bracketMatching,
Expand All @@ -14,6 +14,7 @@ import {
drawSelection,
dropCursor,
highlightActiveLine,
highlightActiveLineGutter,
highlightSpecialChars,
keymap,
rectangularSelection,
Expand All @@ -25,8 +26,10 @@ import {
*/
export default function createBaseExtensions() {
return [
highlightActiveLineGutter(),
highlightSpecialChars(),
history(),
foldGutter(),
drawSelection(),
dropCursor(),
EditorState.allowMultipleSelections.of(true),
Expand All @@ -38,7 +41,6 @@ export default function createBaseExtensions() {
crosshairCursor(),
highlightActiveLine(),
highlightSelectionMatches(),
foldGutter(),
keymap.of([...defaultKeymap, ...historyKeymap]),
keymap.of([...completionKeymap, ...defaultKeymap, ...historyKeymap]),
];
}
173 changes: 173 additions & 0 deletions src/cm/commandRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ import {
undo,
} from "@codemirror/commands";
import { indentUnit as indentUnitFacet } from "@codemirror/language";
import {
closeLintPanel,
nextDiagnostic,
openLintPanel,
previousDiagnostic,
} from "@codemirror/lint";
import {
LSPPlugin,
closeReferencePanel as lspCloseReferencePanel,
findReferences as lspFindReferences,
formatDocument as lspFormatDocument,
jumpToDeclaration as lspJumpToDeclaration,
jumpToDefinition as lspJumpToDefinition,
jumpToImplementation as lspJumpToImplementation,
jumpToTypeDefinition as lspJumpToTypeDefinition,
nextSignature as lspNextSignature,
prevSignature as lspPrevSignature,
renameSymbol as lspRenameSymbol,
showSignatureHelp as lspShowSignatureHelp,
} from "@codemirror/lsp-client";
import { Compartment, EditorSelection } from "@codemirror/state";
import { keymap } from "@codemirror/view";
import prompt from "dialogs/prompt";
Expand Down Expand Up @@ -132,6 +152,8 @@ const CODEMIRROR_COMMAND_MAP = new Map(
);

registerCoreCommands();
registerLspCommands();
registerLintCommands();
registerCommandsFromKeyBindings();
rebuildKeymap();

Expand Down Expand Up @@ -834,6 +856,137 @@ function registerCoreCommands() {
});
}

function registerLspCommands() {
addCommand({
name: "formatDocument",
description: "Format document (Language Server)",
readOnly: false,
requiresView: true,
run: runLspCommand(lspFormatDocument),
});
addCommand({
name: "renameSymbol",
description: "Rename symbol (Language Server)",
readOnly: false,
requiresView: true,
run: runLspCommand(lspRenameSymbol),
});
addCommand({
name: "showSignatureHelp",
description: "Show signature help",
readOnly: true,
requiresView: true,
run: runLspCommand(lspShowSignatureHelp),
});
addCommand({
name: "nextSignature",
description: "Next signature",
readOnly: true,
requiresView: true,
run: runLspCommand(lspNextSignature, { silentOnMissing: true }),
});
addCommand({
name: "prevSignature",
description: "Previous signature",
readOnly: true,
requiresView: true,
run: runLspCommand(lspPrevSignature, { silentOnMissing: true }),
});
addCommand({
name: "jumpToDefinition",
description: "Go to definition (Language Server)",
readOnly: true,
requiresView: true,
run: runLspCommand(lspJumpToDefinition),
});
addCommand({
name: "jumpToDeclaration",
description: "Go to declaration (Language Server)",
readOnly: true,
requiresView: true,
run: runLspCommand(lspJumpToDeclaration),
});
addCommand({
name: "jumpToTypeDefinition",
description: "Go to type definition (Language Server)",
readOnly: true,
requiresView: true,
run: runLspCommand(lspJumpToTypeDefinition),
});
addCommand({
name: "jumpToImplementation",
description: "Go to implementation (Language Server)",
readOnly: true,
requiresView: true,
run: runLspCommand(lspJumpToImplementation),
});
addCommand({
name: "findReferences",
description: "Find references (Language Server)",
readOnly: true,
requiresView: true,
run: runLspCommand(lspFindReferences),
});
addCommand({
name: "closeReferencePanel",
description: "Close references panel",
readOnly: true,
requiresView: true,
run(view) {
const resolvedView = resolveView(view);
if (!resolvedView) return false;
return lspCloseReferencePanel(resolvedView);
},
});
}

function registerLintCommands() {
addCommand({
name: "openLintPanel",
description: "Open lint panel",
readOnly: true,
requiresView: true,
run(view) {
const resolvedView = resolveView(view);
if (!resolvedView) return false;
return openLintPanel(resolvedView);
},
});
addCommand({
name: "closeLintPanel",
description: "Close lint panel",
readOnly: true,
requiresView: true,
run(view) {
const resolvedView = resolveView(view);
if (!resolvedView) return false;
return closeLintPanel(resolvedView);
},
});
addCommand({
name: "nextDiagnostic",
description: "Go to next diagnostic",
readOnly: true,
requiresView: true,
run(view) {
const resolvedView = resolveView(view);
if (!resolvedView) return false;
return nextDiagnostic(resolvedView);
},
});
addCommand({
name: "previousDiagnostic",
description: "Go to previous diagnostic",
readOnly: true,
requiresView: true,
run(view) {
const resolvedView = resolveView(view);
if (!resolvedView) return false;
return previousDiagnostic(resolvedView);
},
});
}

function registerCommandsFromKeyBindings() {
Object.entries(keyBindings).forEach(([name, binding]) => {
if (commandMap.has(name)) return;
Expand Down Expand Up @@ -894,6 +1047,26 @@ function resolveView(view) {
return view || editorManager?.editor || null;
}

function notifyLspUnavailable() {
toast?.("Language server not available");
}

function runLspCommand(commandFn, options = {}) {
return (view) => {
const resolvedView = resolveView(view);
if (!resolvedView) return false;
const plugin = LSPPlugin.get(resolvedView);
if (!plugin) {
if (!options?.silentOnMissing) {
notifyLspUnavailable();
}
return false;
}
const result = commandFn(resolvedView);
return result !== false;
};
}

function humanizeCommandName(name) {
return name
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
Expand Down
Loading