diff --git a/lib/ext-main-theme.js b/lib/ext-main-theme.js index 8165bea..d6234be 100644 --- a/lib/ext-main-theme.js +++ b/lib/ext-main-theme.js @@ -51,7 +51,15 @@ const sidebarStylo = { }, '.cm-activeLine': { backgroundColor: '#00aaff10' - } + }, + '.cm-completionIcon-scope-module': {'&:after': {content: '"M"', 'font-style': 'italic' } }, + '.cm-completionIcon-scope-class': {'&:after': {content: '"C"', 'font-style': 'italic' } }, + '.cm-completionIcon-scope-other': {'&:after': {content: '"O"', 'font-style': 'italic' } }, + + '.cm-completionIcon-var-parameter': {'&:after': {content: '"p"'} }, + '.cm-completionIcon-var-reg': {'&:after': {content: '"r"'} }, + '.cm-completionIcon-var-wire': {'&:after': {content: '"w"'} }, + '.cm-completionIcon-var-other': {'&:after': {content: '"o"'} } }; const extMainTheme = EditorView.theme(sidebarStylo, {dark: true}); diff --git a/lib/ext-waveql-lang-with.js b/lib/ext-waveql-lang-with.js index e7ab834..ba42c80 100644 --- a/lib/ext-waveql-lang-with.js +++ b/lib/ext-waveql-lang-with.js @@ -4,47 +4,12 @@ const {StreamLanguage, syntaxHighlighting, HighlightStyle} = require('@codemirro const {tags} = require('@lezer/highlight'); const get = require('./get-sig.js'); +const getScopeType = require('./get-scope-type.js'); +const getVarType = require('./get-var-type.js'); // waveql syntax // https://codemirror.net/docs/ref/#language.StreamLanguage -const varTypes = { - // event: {id: 1, tag: 'variableName'}, - // integer: {id: 2, tag: 'variableName'}, - parameter: {id: 3, tag: 'macroName'}, - // real: {id: 4, tag: 'variableName'}, - // realtime: {id: 5, tag: 'variableName'}, - reg: {id: 6, tag: 'atom'}, - // supply0: {id: 7, tag: 'variableName'}, - // supply1: {id: 8, tag: 'variableName'}, - // time: {id: 9, tag: 'variableName'}, - // tri: {id: 10, tag: 'variableName'}, - // triand: {id: 11, tag: 'variableName'}, - // trior: {id: 12, tag: 'variableName'}, - // trireg: {id: 13, tag: 'variableName'}, - // tri0: {id: 14, tag: 'variableName'}, - // tri1: {id: 15, tag: 'variableName'}, - // wand: {id: 16, tag: 'variableName'}, - wire: {id: 17, tag: 'bool'} - // wor: {id: 18, tag: 'variableName'} -}; - -const scopeTypes = { - module: {id: 0, tag: 'meta'}, - // task: {id: 1, tag: 'namespace'}, - // function: {id: 2, tag: 'namespace'}, - // begin: {id: 3, tag: 'namespace'}, - // fork: {id: 4, tag: 'namespace'}, - // extra scopes from Verilator - // generate: {id: 5, tag: 'namespace'}, - // struct: {id: 6, tag: 'namespace'}, - // union: {id: 7, tag: 'namespace'}, - class: {id: 8, tag: 'className'} - // interface: {id: 9, tag: 'namespace'}, - // package: {id: 10, tag: 'namespace'}, - // program: {id: 11, tag: 'namespace'} -}; - // https://github.com/lezer-parser/highlight/blob/main/src/highlight.ts @@ -82,7 +47,7 @@ const waveQlLang = wires => ({ if (stream.eatSpace()) { return null; } - mat = stream.match(/^#/); if (mat) { stream.skipToEnd(); return 'comment'; } + mat = stream.match(/^\/\//); if (mat) { stream.skipToEnd(); return 'comment'; } mat = stream.match(/^@\d+[munpf]*s(\.\w+)*(\s+|$)/); if (mat) { return 'unit'; } @@ -107,21 +72,22 @@ const waveQlLang = wires => ({ if (ero) { if (ero.kind === 'scope') { stt.path = newPath; - return (scopeTypes[ero.type] || {tag: 'namespace'}).tag; + return (getScopeType(ero.type)).tag; } if (ero.kind === 'var') { // stt.varWidth = ero.size; - return (varTypes[ero.type] || {tag: 'variableName'}).tag; + return (getVarType(ero.type)).tag; } } return 'comment'; } + }, + languageData: { + commentTokens: {line: '//'} } }); - - const extWaveqlLangWith = (wires) => { // console.log(wires); return [ diff --git a/lib/get-scope-type.js b/lib/get-scope-type.js new file mode 100644 index 0000000..8ccfd70 --- /dev/null +++ b/lib/get-scope-type.js @@ -0,0 +1,22 @@ +'use strict'; + +const getScopeType = (key) => { + const lut = { + module: {id: 0, tag: 'meta', icon: 'module'}, + // task: {id: 1, tag: 'namespace'}, + // function: {id: 2, tag: 'namespace'}, + // begin: {id: 3, tag: 'namespace'}, + // fork: {id: 4, tag: 'namespace'}, + // extra scopes from Verilator + // generate: {id: 5, tag: 'namespace'}, + // struct: {id: 6, tag: 'namespace'}, + // union: {id: 7, tag: 'namespace'}, + class: {id: 8, tag: 'className', icon: 'class'} + // interface: {id: 9, tag: 'namespace'}, + // package: {id: 10, tag: 'namespace'}, + // program: {id: 11, tag: 'namespace'} + }; + return lut[key] || {tag: 'namespace', icon: 'other'}; +}; + +module.exports = getScopeType; diff --git a/lib/get-var-type.js b/lib/get-var-type.js new file mode 100644 index 0000000..3483312 --- /dev/null +++ b/lib/get-var-type.js @@ -0,0 +1,27 @@ +'use strict'; + +const getVarType = (key) => { + const lut = { + // event: {id: 1, tag: 'variableName'}, + // integer: {id: 2, tag: 'variableName'}, + parameter: {id: 3, tag: 'macroName', icon: 'parameter'}, + // real: {id: 4, tag: 'variableName'}, + // realtime: {id: 5, tag: 'variableName'}, + reg: {id: 6, tag: 'atom', icon: 'reg'}, + // supply0: {id: 7, tag: 'variableName'}, + // supply1: {id: 8, tag: 'variableName'}, + // time: {id: 9, tag: 'variableName'}, + // tri: {id: 10, tag: 'variableName'}, + // triand: {id: 11, tag: 'variableName'}, + // trior: {id: 12, tag: 'variableName'}, + // trireg: {id: 13, tag: 'variableName'}, + // tri0: {id: 14, tag: 'variableName'}, + // tri1: {id: 15, tag: 'variableName'}, + // wand: {id: 16, tag: 'variableName'}, + wire: {id: 17, tag: 'bool', icon: 'wire'} + // wor: {id: 18, tag: 'variableName'} + }; + return lut[key] || {tag: 'variableName', icon: 'other'}; +}; + +module.exports = getVarType; diff --git a/lib/waveql-parser-with.js b/lib/waveql-parser-with.js index ecbd8eb..cf20209 100644 --- a/lib/waveql-parser-with.js +++ b/lib/waveql-parser-with.js @@ -75,7 +75,7 @@ const waveqlParserWith = wires => str => { cols.some(col => { // EOL comment - if (col[0] === '#') { + if (col[0] === '//') { return true; }