summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/lib/editor_options.js
blob: 289027c3054693a15c8caf3ea3db83676b8b138f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { useNewFonts } from '~/lib/utils/common_utils';
import { getCssVariable } from '~/lib/utils/css_utils';

const fontOptions = {};

if (useNewFonts()) {
  fontOptions.fontFamily = getCssVariable('--code-editor-font');
}

export const defaultEditorOptions = {
  model: null,
  readOnly: false,
  contextmenu: true,
  scrollBeyondLastLine: false,
  minimap: {
    enabled: false,
  },
  wordWrap: 'on',
  glyphMargin: true,
  automaticLayout: true,
  ...fontOptions,
};

export const defaultDiffOptions = {
  ignoreWhitespace: false,
};

export const defaultDiffEditorOptions = {
  ...defaultEditorOptions,
  quickSuggestions: false,
  occurrencesHighlight: false,
  ignoreTrimWhitespace: false,
  readOnly: false,
  renderLineHighlight: 'none',
  hideCursorInOverviewRuler: true,
  glyphMargin: true,
};

export const defaultModelOptions = {
  insertFinalNewline: true,
  trimTrailingWhitespace: false,
};

export const editorOptions = [
  {
    readOnly: (model) => Boolean(model.file.file_lock),
    quickSuggestions: (model) => !(model.language === 'markdown'),
  },
];