Skip to content

Commit

Permalink
Final clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Dec 18, 2023
1 parent e3db44c commit ee5d029
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
14 changes: 14 additions & 0 deletions src/language/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { DocSymbolProvider } from './symbol-document'
import { ProjectSymbolProvider } from './symbol-project'
import { DefinitionProvider } from './definition'
import { FoldingProvider, WeaveFoldingProvider } from './folding'
import { SelectionRangeProvider } from './selection'

export const language = {
docSymbol: new DocSymbolProvider(),
projectSymbol: new ProjectSymbolProvider(),
definition: new DefinitionProvider(),
folding: new FoldingProvider(),
weaveFolding: new WeaveFoldingProvider(),
selectionRage: new SelectionRangeProvider()
}
2 changes: 2 additions & 0 deletions src/lw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { compile } from './compile'
import type { preview, server, viewer } from './preview'
import type { locate } from './locate'
import type { completion } from './completion'
import type { language } from './language'
import type { lint } from './lint'
import type { outline } from './outline'
import type { parse } from './parse'
Expand All @@ -33,6 +34,7 @@ export const lw = {
preview: {} as typeof preview,
locate: {} as typeof locate,
completion: {} as typeof completion,
language: {} as typeof language,
lint: {} as typeof lint,
outline: {} as typeof outline,
extra: {} as typeof extra,
Expand Down
22 changes: 8 additions & 14 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ lw.commands = commander

log.initStatusBarItem()

import { DocSymbolProvider } from './language/symbol-document'
import { ProjectSymbolProvider } from './language/symbol-project'
import { DefinitionProvider } from './language/definition'
import { FoldingProvider, WeaveFoldingProvider } from './language/folding'
import { SelectionRangeProvider } from './language/selection'

export function activate(extensionContext: vscode.ExtensionContext) {
void vscode.commands.executeCommand('setContext', 'latex-workshop:enabled', true)

Expand Down Expand Up @@ -261,11 +255,11 @@ function registerProviders(extensionContext: vscode.ExtensionContext) {

extensionContext.subscriptions.push(
vscode.languages.registerHoverProvider(latexSelector, lw.preview.provider),
vscode.languages.registerDefinitionProvider(latexSelector, new DefinitionProvider()),
vscode.languages.registerDocumentSymbolProvider(latexSelector, new DocSymbolProvider()),
vscode.languages.registerDocumentSymbolProvider(bibtexSelector, new DocSymbolProvider()),
vscode.languages.registerDocumentSymbolProvider(selectDocumentsWithId(['doctex']), new DocSymbolProvider()),
vscode.languages.registerWorkspaceSymbolProvider(new ProjectSymbolProvider())
vscode.languages.registerDefinitionProvider(latexSelector, lw.language.definition),
vscode.languages.registerDocumentSymbolProvider(latexSelector, lw.language.docSymbol),
vscode.languages.registerDocumentSymbolProvider(bibtexSelector, lw.language.docSymbol),
vscode.languages.registerDocumentSymbolProvider(selectDocumentsWithId(['doctex']), lw.language.docSymbol),
vscode.languages.registerWorkspaceSymbolProvider(lw.language.projectSymbol)
)

extensionContext.subscriptions.push(
Expand Down Expand Up @@ -311,13 +305,13 @@ function registerProviders(extensionContext: vscode.ExtensionContext) {

extensionContext.subscriptions.push(
vscode.languages.registerCodeActionsProvider(latexSelector, lw.lint.latex.actionprovider),
vscode.languages.registerFoldingRangeProvider(latexSelector, new FoldingProvider()),
vscode.languages.registerFoldingRangeProvider(weaveSelector, new WeaveFoldingProvider())
vscode.languages.registerFoldingRangeProvider(latexSelector, lw.language.folding),
vscode.languages.registerFoldingRangeProvider(weaveSelector, lw.language.weaveFolding)
)

const selectionLatex = configuration.get('selection.smart.latex.enabled', true)
if (selectionLatex) {
extensionContext.subscriptions.push(vscode.languages.registerSelectionRangeProvider({language: 'latex'}, new SelectionRangeProvider()))
extensionContext.subscriptions.push(vscode.languages.registerSelectionRangeProvider({language: 'latex'}, lw.language.selectionRage))
}

extensionContext.subscriptions.push(
Expand Down

0 comments on commit ee5d029

Please sign in to comment.