[mod] settings apply
This commit is contained in:
parent
e38385b593
commit
4ccc684f89
9 changed files with 103 additions and 51 deletions
|
|
@ -1,23 +1,29 @@
|
|||
|
||||
import { EditorState, StateEffect } from '@codemirror/state';
|
||||
import { EditorState, StateEffect, Compartment } from '@codemirror/state';
|
||||
|
||||
import { lineNumbers, highlightActiveLineGutter, highlightSpecialChars,
|
||||
drawSelection, rectangularSelection, crosshairCursor, highlightActiveLine,
|
||||
keymap, dropCursor,EditorView} from '@codemirror/view';
|
||||
import {
|
||||
lineNumbers, highlightActiveLineGutter, highlightSpecialChars,
|
||||
drawSelection, rectangularSelection, crosshairCursor, highlightActiveLine,
|
||||
keymap, dropCursor, EditorView
|
||||
} from '@codemirror/view';
|
||||
|
||||
import { openSearchPanel, highlightSelectionMatches, searchKeymap } from '@codemirror/search';
|
||||
|
||||
import { openLintPanel, lintGutter, lintKeymap, linter} from "@codemirror/lint"
|
||||
import { openLintPanel, lintGutter, lintKeymap, linter } from "@codemirror/lint"
|
||||
|
||||
import { indentWithTab, history, defaultKeymap, historyKeymap } from '@codemirror/commands';
|
||||
|
||||
import { foldGutter, indentOnInput, indentUnit, bracketMatching, foldKeymap,
|
||||
syntaxHighlighting, defaultHighlightStyle , StreamLanguage } from '@codemirror/language';
|
||||
import {
|
||||
foldGutter, indentOnInput, indentUnit, bracketMatching, foldKeymap,
|
||||
syntaxHighlighting, defaultHighlightStyle, StreamLanguage
|
||||
} from '@codemirror/language';
|
||||
|
||||
import { closeBrackets, autocompletion, closeBracketsKeymap, completionKeymap } from '@codemirror/autocomplete';
|
||||
|
||||
import { LSPClient, LSPPlugin, languageServerSupport, languageServerExtensions,
|
||||
formatDocument,formatKeymap } from "@codemirror/lsp-client";
|
||||
import {
|
||||
LSPClient, LSPPlugin, languageServerSupport, languageServerExtensions,
|
||||
formatDocument, formatKeymap
|
||||
} from "@codemirror/lsp-client";
|
||||
|
||||
import { xQuery } from "@codemirror/legacy-modes/mode/xquery"
|
||||
// Language
|
||||
|
|
@ -25,12 +31,35 @@ import { xml } from "@codemirror/lang-xml";
|
|||
|
||||
import { showMinimap } from "@replit/codemirror-minimap"
|
||||
let create = (v) => {
|
||||
const dom = document.createElement('div');
|
||||
return { dom }
|
||||
const dom = document.createElement('div');
|
||||
return { dom }
|
||||
}
|
||||
const compartment = new Compartment();
|
||||
let curOpts = {
|
||||
lineWrap: true,
|
||||
minimap: true
|
||||
}
|
||||
// array of extensions reflecting opts
|
||||
function optExts(opts) {
|
||||
let exts = []
|
||||
if (opts.lineWrap) exts.push(EditorView.lineWrapping)
|
||||
if (opts.minimap) exts.push(
|
||||
showMinimap.compute(['doc'], (state) => {
|
||||
return {
|
||||
create,
|
||||
/* optional showOverlay: 'mouse-over' */
|
||||
displayText: 'characters'
|
||||
|
||||
}
|
||||
}));
|
||||
return exts
|
||||
}
|
||||
|
||||
|
||||
|
||||
function updateCompartment(opts) {
|
||||
view.dispatch({
|
||||
effects: [compartment.reconfigure(optExts(opts))]
|
||||
});
|
||||
}
|
||||
|
||||
// return promise with socket map or reject if no connect
|
||||
function simpleWebSocketTransport(uri) {
|
||||
|
|
@ -60,7 +89,7 @@ const baseExts = [
|
|||
drawSelection(),
|
||||
dropCursor(),
|
||||
EditorState.allowMultipleSelections.of(true),
|
||||
EditorView.lineWrapping,
|
||||
|
||||
keymap.of([indentWithTab]),
|
||||
indentOnInput(),
|
||||
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
|
||||
|
|
@ -81,14 +110,7 @@ const baseExts = [
|
|||
...lintKeymap
|
||||
]),
|
||||
StreamLanguage.define(xQuery),
|
||||
showMinimap.compute(['doc'], (state) => {
|
||||
return {
|
||||
create,
|
||||
/* optional showOverlay: 'mouse-over' */
|
||||
displayText: 'characters'
|
||||
|
||||
}
|
||||
})
|
||||
compartment.of(optExts(curOpts))
|
||||
];
|
||||
|
||||
|
||||
|
|
@ -107,6 +129,8 @@ function listCommands(view) {
|
|||
return commands;
|
||||
};
|
||||
|
||||
export { baseExts, EditorView, EditorState, StateEffect, LSPPlugin, LSPClient,
|
||||
openSearchPanel, openLintPanel, languageServerSupport, languageServerExtensions,
|
||||
simpleWebSocketTransport, linter, formatDocument,keymap,formatKeymap, listCommands };
|
||||
export {
|
||||
baseExts, EditorView, EditorState, StateEffect, LSPPlugin, LSPClient,
|
||||
openSearchPanel, openLintPanel, languageServerSupport, languageServerExtensions,
|
||||
simpleWebSocketTransport, linter, formatDocument, keymap, formatKeymap, listCommands, updateCompartment, curOpts
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue