mirror of
https://github.com/James-Yu/LaTeX-Workshop.git
synced 2024-10-04 15:17:59 +03:00
Add intellisense.command.unimathsymbols.enabled
to control hint length
This commit is contained in:
parent
ca8ece29e6
commit
fcf150a918
@ -786,6 +786,11 @@
|
||||
"default": false,
|
||||
"markdownDescription": "When `\\` is typed with text selected, surround the selection with LaTeX command."
|
||||
},
|
||||
"latex-workshop.intellisense.command.unimathsymbols.enabled": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"markdownDescription": "When `\\` is typed, show unimath symbols in the dropdown selector."
|
||||
},
|
||||
"latex-workshop.message.badbox.show": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
|
@ -11,9 +11,11 @@ export class Command {
|
||||
commandInTeX: { [id: string]: {[id: string]: AutocompleteEntry} } = {}
|
||||
refreshTimer: number
|
||||
defaultCommands: {[key: string]: vscode.CompletionItem} = {}
|
||||
defaultSymbols: {[key: string]: vscode.CompletionItem} = {}
|
||||
newcommandData: {[id: string]: {position: vscode.Position, file: string}} = {}
|
||||
specialBrackets: {[key: string]: vscode.CompletionItem}
|
||||
usedPackages: string[] = []
|
||||
packageCmds: {[pkg: string]: any} = {}
|
||||
|
||||
constructor(extension: Extension) {
|
||||
this.extension = extension
|
||||
@ -39,7 +41,7 @@ export class Command {
|
||||
})
|
||||
Object.keys(defaultSymbols).forEach(key => {
|
||||
const item = defaultSymbols[key]
|
||||
this.defaultCommands[key] = this.entryToCompletionItem(item)
|
||||
this.defaultSymbols[key] = this.entryToCompletionItem(item)
|
||||
})
|
||||
Object.keys(envSnippet).forEach(key => {
|
||||
const item = envSnippet[key]
|
||||
@ -62,14 +64,13 @@ export class Command {
|
||||
return this.suggestions
|
||||
}
|
||||
this.refreshTimer = Date.now()
|
||||
const suggestions = {}
|
||||
Object.keys(this.defaultCommands).forEach(key => {
|
||||
if (this.defaultCommands[key].sortText === undefined) {
|
||||
suggestions[key] = this.defaultCommands[key]
|
||||
} else if (this.usedPackages.indexOf(this.defaultCommands[key].sortText || '') > -1) {
|
||||
suggestions[key] = this.defaultCommands[key]
|
||||
const configuration = vscode.workspace.getConfiguration('latex-workshop')
|
||||
let suggestions
|
||||
if (configuration.get('intellisense.command.unimathsymbols.enabled')) {
|
||||
suggestions = Object.assign({}, {...this.defaultCommands, ...this.defaultSymbols})
|
||||
} else {
|
||||
suggestions = Object.assign({}, this.defaultCommands)
|
||||
}
|
||||
})
|
||||
Object.keys(this.extension.manager.texFileTree).forEach(filePath => {
|
||||
if (filePath in this.commandInTeX) {
|
||||
Object.keys(this.commandInTeX[filePath]).forEach(key => {
|
||||
@ -150,7 +151,6 @@ export class Command {
|
||||
}
|
||||
command.documentation = item.documentation
|
||||
command.detail = item.detail
|
||||
command.sortText = item.package // Here we abuse the sortText field
|
||||
if (item.postAction) {
|
||||
command.command = { title: 'Post-Action', command: item.postAction }
|
||||
}
|
||||
@ -172,7 +172,6 @@ export class Command {
|
||||
}
|
||||
}
|
||||
} while (result)
|
||||
console.log(this.usedPackages)
|
||||
}
|
||||
|
||||
getCommandsTeX(filePath: string) {
|
||||
|
@ -28,22 +28,19 @@ export class Completer implements vscode.CompletionItemProvider {
|
||||
this.input = new Input(extension)
|
||||
let defaultEnvs: string
|
||||
let defaultCommands: string
|
||||
let defaultPkgCommands: string
|
||||
let defaultSymbols: string
|
||||
let defaultPackages: string
|
||||
fs.readFile(`${this.extension.extensionRoot}/data/environments.json`)
|
||||
.then(data => {defaultEnvs = data.toString()})
|
||||
.then(() => fs.readFile(`${this.extension.extensionRoot}/data/commands.json`))
|
||||
.then(data => {defaultCommands = data.toString()})
|
||||
.then(() => fs.readFile(`${this.extension.extensionRoot}/data/packagecommands.json`))
|
||||
.then(data => {defaultPkgCommands = data.toString()})
|
||||
.then(() => fs.readFile(`${this.extension.extensionRoot}/data/unimathsymbols.json`))
|
||||
.then(data => {defaultSymbols = data.toString()})
|
||||
.then(() => fs.readFile(`${this.extension.extensionRoot}/data/packagenames.json`))
|
||||
.then(data => {defaultPackages = data.toString()})
|
||||
.then(() => {
|
||||
const env = JSON.parse(defaultEnvs)
|
||||
this.command.initialize({...JSON.parse(defaultCommands), ...JSON.parse(defaultPkgCommands)}, JSON.parse(defaultSymbols), env)
|
||||
this.command.initialize(JSON.parse(defaultCommands), JSON.parse(defaultSymbols), env)
|
||||
this.environment.initialize(env)
|
||||
this.package.initialize(JSON.parse(defaultPackages))
|
||||
this.extension.logger.addLogMessage(`Default data loaded.`)
|
||||
|
Loading…
Reference in New Issue
Block a user