You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

473 lines
9.6 KiB

  1. 'use strict';
  2. import { TraceLevel } from './logger';
  3. export interface Config {
  4. autolinks: AutolinkReference[] | null;
  5. blame: {
  6. avatars: boolean;
  7. compact: boolean;
  8. dateFormat: string | null;
  9. format: string;
  10. heatmap: {
  11. enabled: boolean;
  12. location: 'left' | 'right';
  13. };
  14. highlight: {
  15. enabled: boolean;
  16. locations: BlameHighlightLocations[];
  17. };
  18. ignoreWhitespace: boolean;
  19. separateLines: boolean;
  20. toggleMode: AnnotationsToggleMode;
  21. };
  22. changes: {
  23. locations: ChangesLocations[];
  24. toggleMode: AnnotationsToggleMode;
  25. };
  26. codeLens: CodeLensConfig;
  27. currentLine: {
  28. dateFormat: string | null;
  29. enabled: boolean;
  30. format: string;
  31. pullRequests: {
  32. enabled: boolean;
  33. };
  34. scrollable: boolean;
  35. };
  36. debug: boolean;
  37. defaultDateFormat: string | null;
  38. defaultDateShortFormat: string | null;
  39. defaultDateSource: DateSource;
  40. defaultDateStyle: DateStyle;
  41. defaultGravatarsStyle: GravatarDefaultStyle;
  42. gitCommands: {
  43. closeOnFocusOut: boolean;
  44. search: {
  45. matchAll: boolean;
  46. matchCase: boolean;
  47. matchRegex: boolean;
  48. showResultsInView: boolean;
  49. };
  50. skipConfirmations: string[];
  51. };
  52. heatmap: {
  53. ageThreshold: number;
  54. coldColor: string;
  55. hotColor: string;
  56. toggleMode: AnnotationsToggleMode;
  57. };
  58. hovers: {
  59. annotations: {
  60. changes: boolean;
  61. details: boolean;
  62. enabled: boolean;
  63. over: 'line' | 'annotation';
  64. };
  65. autolinks: {
  66. enabled: boolean;
  67. enhanced: boolean;
  68. };
  69. currentLine: {
  70. changes: boolean;
  71. details: boolean;
  72. enabled: boolean;
  73. over: 'line' | 'annotation';
  74. };
  75. avatars: boolean;
  76. avatarSize: number;
  77. changesDiff: 'line' | 'hunk';
  78. detailsMarkdownFormat: string;
  79. enabled: boolean;
  80. pullRequests: {
  81. enabled: boolean;
  82. };
  83. };
  84. insiders: boolean;
  85. keymap: KeyMap;
  86. liveshare: {
  87. allowGuestAccess: boolean;
  88. };
  89. menus: boolean | MenuConfig;
  90. mode: {
  91. active: string;
  92. statusBar: {
  93. enabled: boolean;
  94. alignment: 'left' | 'right';
  95. };
  96. };
  97. modes: Record<string, ModeConfig>;
  98. outputLevel: TraceLevel;
  99. remotes: RemotesConfig[] | null;
  100. showWhatsNewAfterUpgrades: boolean;
  101. sortBranchesBy: BranchSorting;
  102. sortTagsBy: TagSorting;
  103. statusBar: {
  104. alignment: 'left' | 'right';
  105. command: StatusBarCommand;
  106. dateFormat: string | null;
  107. enabled: boolean;
  108. format: string;
  109. reduceFlicker: boolean;
  110. };
  111. strings: {
  112. codeLens: {
  113. unsavedChanges: {
  114. recentChangeAndAuthors: string;
  115. recentChangeOnly: string;
  116. authorsOnly: string;
  117. };
  118. };
  119. };
  120. views: ViewsConfig;
  121. advanced: AdvancedConfig;
  122. }
  123. export enum AnnotationsToggleMode {
  124. File = 'file',
  125. Window = 'window',
  126. }
  127. export interface AutolinkReference {
  128. prefix: string;
  129. url: string;
  130. title?: string;
  131. alphanumeric?: boolean;
  132. ignoreCase?: boolean;
  133. }
  134. export enum BlameHighlightLocations {
  135. Gutter = 'gutter',
  136. Line = 'line',
  137. Overview = 'overview',
  138. }
  139. export enum BranchSorting {
  140. NameDesc = 'name:desc',
  141. NameAsc = 'name:asc',
  142. DateDesc = 'date:desc',
  143. DateAsc = 'date:asc',
  144. }
  145. export enum ChangesLocations {
  146. Gutter = 'gutter',
  147. Overview = 'overview',
  148. }
  149. export enum CodeLensCommand {
  150. DiffWithPrevious = 'gitlens.diffWithPrevious',
  151. RevealCommitInView = 'gitlens.revealCommitInView',
  152. ShowCommitsInView = 'gitlens.showCommitsInView',
  153. ShowQuickCommitDetails = 'gitlens.showQuickCommitDetails',
  154. ShowQuickCommitFileDetails = 'gitlens.showQuickCommitFileDetails',
  155. ShowQuickCurrentBranchHistory = 'gitlens.showQuickRepoHistory',
  156. ShowQuickFileHistory = 'gitlens.showQuickFileHistory',
  157. ToggleFileBlame = 'gitlens.toggleFileBlame',
  158. }
  159. export enum CodeLensScopes {
  160. Document = 'document',
  161. Containers = 'containers',
  162. Blocks = 'blocks',
  163. }
  164. export enum CustomRemoteType {
  165. Bitbucket = 'Bitbucket',
  166. BitbucketServer = 'BitbucketServer',
  167. Custom = 'Custom',
  168. GitHub = 'GitHub',
  169. GitLab = 'GitLab',
  170. }
  171. export enum DateSource {
  172. Authored = 'authored',
  173. Committed = 'committed',
  174. }
  175. export enum DateStyle {
  176. Absolute = 'absolute',
  177. Relative = 'relative',
  178. }
  179. export enum FileAnnotationType {
  180. Blame = 'blame',
  181. Changes = 'changes',
  182. Heatmap = 'heatmap',
  183. }
  184. export enum GravatarDefaultStyle {
  185. Faces = 'wavatar',
  186. Geometric = 'identicon',
  187. Monster = 'monsterid',
  188. MysteryPerson = 'mp',
  189. Retro = 'retro',
  190. Robot = 'robohash',
  191. }
  192. export enum KeyMap {
  193. Alternate = 'alternate',
  194. Chorded = 'chorded',
  195. None = 'none',
  196. }
  197. export enum StatusBarCommand {
  198. DiffWithPrevious = 'gitlens.diffWithPrevious',
  199. DiffWithWorking = 'gitlens.diffWithWorking',
  200. RevealCommitInView = 'gitlens.revealCommitInView',
  201. ShowCommitsInView = 'gitlens.showCommitsInView',
  202. ShowQuickCommitDetails = 'gitlens.showQuickCommitDetails',
  203. ShowQuickCommitFileDetails = 'gitlens.showQuickCommitFileDetails',
  204. ShowQuickCurrentBranchHistory = 'gitlens.showQuickRepoHistory',
  205. ShowQuickFileHistory = 'gitlens.showQuickFileHistory',
  206. ToggleCodeLens = 'gitlens.toggleCodeLens',
  207. ToggleFileBlame = 'gitlens.toggleFileBlame',
  208. }
  209. export enum TagSorting {
  210. NameDesc = 'name:desc',
  211. NameAsc = 'name:asc',
  212. DateDesc = 'date:desc',
  213. DateAsc = 'date:asc',
  214. }
  215. export enum ViewBranchesLayout {
  216. List = 'list',
  217. Tree = 'tree',
  218. }
  219. export enum ViewFilesLayout {
  220. Auto = 'auto',
  221. List = 'list',
  222. Tree = 'tree',
  223. }
  224. export enum ViewLocation {
  225. Explorer = 'explorer',
  226. GitLens = 'gitlens',
  227. SourceControl = 'scm',
  228. }
  229. export enum ViewShowBranchComparison {
  230. Branch = 'branch',
  231. Working = 'working',
  232. }
  233. export interface AdvancedConfig {
  234. abbreviatedShaLength: number;
  235. blame: {
  236. customArguments: string[] | null;
  237. delayAfterEdit: number;
  238. sizeThresholdAfterEdit: number;
  239. };
  240. caching: {
  241. enabled: boolean;
  242. };
  243. fileHistoryFollowsRenames: boolean;
  244. fileHistoryShowAllBranches: boolean;
  245. maxListItems: number;
  246. maxSearchItems: number;
  247. messages: {
  248. suppressCommitHasNoPreviousCommitWarning: boolean;
  249. suppressCommitNotFoundWarning: boolean;
  250. suppressFileNotUnderSourceControlWarning: boolean;
  251. suppressGitDisabledWarning: boolean;
  252. suppressGitVersionWarning: boolean;
  253. suppressLineUncommittedWarning: boolean;
  254. suppressNoRepositoryWarning: boolean;
  255. suppressSupportGitLensNotification: boolean;
  256. };
  257. quickPick: {
  258. closeOnFocusOut: boolean;
  259. };
  260. repositorySearchDepth: number;
  261. similarityThreshold: number | null;
  262. useSymmetricDifferenceNotation: boolean;
  263. }
  264. export interface CodeLensConfig {
  265. authors: {
  266. enabled: boolean;
  267. command: CodeLensCommand | false;
  268. };
  269. enabled: boolean;
  270. includeSingleLineSymbols: boolean;
  271. recentChange: {
  272. enabled: boolean;
  273. command: CodeLensCommand | false;
  274. };
  275. scopes: CodeLensScopes[];
  276. scopesByLanguage: CodeLensLanguageScope[] | null;
  277. symbolScopes: string[];
  278. }
  279. export interface CodeLensLanguageScope {
  280. language: string | undefined;
  281. scopes?: CodeLensScopes[];
  282. symbolScopes?: string[];
  283. }
  284. export interface CompareViewConfig {
  285. avatars: boolean;
  286. enabled: boolean;
  287. files: ViewsFilesConfig;
  288. location: ViewLocation;
  289. }
  290. export interface FileHistoryViewConfig {
  291. avatars: boolean;
  292. enabled: boolean;
  293. location: ViewLocation;
  294. }
  295. export interface LineHistoryViewConfig {
  296. avatars: boolean;
  297. enabled: boolean;
  298. location: ViewLocation;
  299. }
  300. export interface MenuConfig {
  301. editor:
  302. | false
  303. | {
  304. blame: boolean;
  305. clipboard: boolean;
  306. compare: boolean;
  307. details: boolean;
  308. history: boolean;
  309. remote: boolean;
  310. };
  311. editorGroup:
  312. | false
  313. | {
  314. compare: boolean;
  315. history: boolean;
  316. };
  317. editorTab:
  318. | false
  319. | {
  320. clipboard: boolean;
  321. compare: boolean;
  322. history: boolean;
  323. remote: boolean;
  324. };
  325. explorer:
  326. | false
  327. | {
  328. clipboard: boolean;
  329. compare: boolean;
  330. history: boolean;
  331. remote: boolean;
  332. };
  333. scm:
  334. | false
  335. | {
  336. authors: boolean;
  337. };
  338. scmGroupInline:
  339. | false
  340. | {
  341. stash: boolean;
  342. };
  343. scmGroup:
  344. | false
  345. | {
  346. compare: boolean;
  347. openClose: boolean;
  348. stash: boolean;
  349. };
  350. scmItem:
  351. | false
  352. | {
  353. clipboard: boolean;
  354. compare: boolean;
  355. history: boolean;
  356. remote: boolean;
  357. stash: boolean;
  358. };
  359. }
  360. export interface ModeConfig {
  361. name: string;
  362. statusBarItemName?: string;
  363. description?: string;
  364. annotations?: 'blame' | 'changes' | 'heatmap';
  365. codeLens?: boolean;
  366. currentLine?: boolean;
  367. hovers?: boolean;
  368. statusBar?: boolean;
  369. views?: boolean;
  370. }
  371. export interface RemotesConfig {
  372. domain: string;
  373. name?: string;
  374. protocol?: string;
  375. type: CustomRemoteType;
  376. urls?: RemotesUrlsConfig;
  377. }
  378. export interface RemotesUrlsConfig {
  379. repository: string;
  380. branches: string;
  381. branch: string;
  382. commit: string;
  383. file: string;
  384. fileInBranch: string;
  385. fileInCommit: string;
  386. fileLine: string;
  387. fileRange: string;
  388. }
  389. export interface RepositoriesViewConfig {
  390. autoRefresh: boolean;
  391. autoReveal: boolean;
  392. avatars: boolean;
  393. branches: {
  394. layout: ViewBranchesLayout;
  395. };
  396. compact: boolean;
  397. enabled: boolean;
  398. files: ViewsFilesConfig;
  399. includeWorkingTree: boolean;
  400. location: ViewLocation;
  401. showBranchComparison: false | ViewShowBranchComparison;
  402. showTrackingBranch: boolean;
  403. }
  404. export interface SearchViewConfig {
  405. avatars: boolean;
  406. enabled: boolean;
  407. files: ViewsFilesConfig;
  408. location: ViewLocation;
  409. }
  410. export interface ViewsConfig {
  411. fileHistory: FileHistoryViewConfig;
  412. commitFileDescriptionFormat: string;
  413. commitFileFormat: string;
  414. commitDescriptionFormat: string;
  415. commitFormat: string;
  416. compare: CompareViewConfig;
  417. defaultItemLimit: number;
  418. lineHistory: LineHistoryViewConfig;
  419. pageItemLimit: number;
  420. repositories: RepositoriesViewConfig;
  421. search: SearchViewConfig;
  422. showRelativeDateMarkers: boolean;
  423. stashFileDescriptionFormat: string;
  424. stashFileFormat: string;
  425. stashDescriptionFormat: string;
  426. stashFormat: string;
  427. statusFileDescriptionFormat: string;
  428. statusFileFormat: string;
  429. }
  430. export interface ViewsFilesConfig {
  431. compact: boolean;
  432. layout: ViewFilesLayout;
  433. threshold: number;
  434. }
  435. export const viewKeys: (keyof Pick<
  436. Config['views'],
  437. 'repositories' | 'fileHistory' | 'lineHistory' | 'compare' | 'search'
  438. >)[] = ['repositories', 'fileHistory', 'lineHistory', 'compare', 'search'];