Kusto language plugin for the Monaco Editor. It provides the following features when editing CSL, KQL files:
- Code completion
- Syntax highlighting
- Validation: Syntax errors and linting
- code folding / outlining
- Hovers
- Find definition
- find all references
- rename symbol
npm install @kusto/monaco-kusto
or yarn add @kusto/monaco-kusto
/esm
Contains esm version of the library/dev
Contains an AMD version of the library/min
Contains a minified AMD version of the library
Example at /samples/amd
- Run
npm run copyMonacoFilesAMD <path>
oryarn copyMonacoFilesAMD <path>
where is where you want the monaco and kusto amd modules to be. These files will need to be served as-in. - Using a amd module loader, import
vs/language/kusto/monaco.contribution
1. The monaco editors included loader can be made available via a global requirerequire
by adding the script tag:<script src="<path>/vs/loader.js"></script>
- You should now be able to create monaco editors with
language: 'kusto'
. The kusto worker can be reached via the monaco global:monaco.languages.kusto.getKustoWorker()
- If using typeScript, add "@kusto/monaco-kusto/globalApi" to compilerOptions.types in tsconfig.json`
Parcel example at /samples/parcel
- Configure your bundler so
@kusto/monaco-kusto/release/esm/kusto.worker
has it's own entry point - Configure the global
MonacoEnvironment
with eithergetWorkerUrl
orgetWorker
- You should now be able to create monaco editors with
language: 'kusto'
. The kusto worker can be reached via the monaco global:monaco.languages.kusto.getKustoWorker()
There are 2 APIs to set a Kusto schema:
setSchema
- the passed schema is of typeClusterType
(defined inschema.ts
). The database in ROOT.database will be the one in context.setSchemaFromShowSchema
- a method to set a schema from the result of the Kusto query.show schema as json
. The result is a list of databases (see interfaceResult
inschema.ts
), so when this method is used, it also requires a cluster URI and the name of the database in context.
- Install Node.js 16 from https://nodejs.org/
- Install Yarn from https://yarnpkg.com/
- Clone repo and run
yarn
in repo root - Run
yarn watch
from /package and a http-server will automatically open the index.html
- Set CI environment variable to "tru"
- Run
yarn build
- feat:
plotly
is now supported in intellisense as a render command
- fix:
KustoWorker#setParameters
will now apply changes immediately
- feat: Kusto worker will now respect
MonacoEnvironment.baseUrl
configuration when running in a different origin. Checkout our new example for details
- fix: Added types back to global api
- Added "themeNames" object to exports which contains the theme we register with monaco: kusto-light, kusto-dark, and kusto-dark2
- fix: Exported types don't match types used in many cases
- BREAKING CHANGE: Bumped monaco-editor peer dependency to ~0.37.0
- This version of monaco-editor no longer requires a patch to work with Parcel. Details here: microsoft/monaco-editor#2966
- fix: "monaco is not defined" errors when consuming esm files
- Moved types from global interface (
monaco.languages.kusto.*
) to esm index fileimport { SomeType } from '@kusto/monaco-kusto
. With this, esm consumer no longer need to include@kusto/monaco-kusto/release/monaco.d.ts
. - ESM output no longer requires
MonacoEnvironment.globalApi
to betrue
- Moved
@kusto/monaco-kusto/release/monaco.d.ts
content to@kusto/monaco-kusto/globalApi.d.ts
. Original file now references this new one, and will be removed in a future release.
- Esm output not longer requires
self.MonacoEnvironment
to be true @kusto/monaco-kusto
no exports the same api asmonaco.languages.kusto
- Improved quality of AMD build artifacts
- BREAKING CHANGE: AMD build artifacts now include a new "main" file that contains shared code
- BREAKING CHANGE: ESM build artifacts no longer vender dependencies in a "deps" folder. node_modules imports are left as-is, and are now in package.json#dependencies
- fix: trigger suggestion when previous suggestion selected.
- fix: low color contrast for foreground/background in suggestWidget for dark theme
- fix: low color contrast for foreground/background in suggestWidget
- fix:
setSchemaFromShowSchema
now supports for external tables.
- fix: update language service to latest version. fixes issues with scan operator being shown first in completion list.
- fix: don't do kusto specific highlighting when other language is selected.
- BREAKING CHANGE: update monaco-editor-core and monaco-editor version to 0.24.0
- Usage for ESM modules: add
globalAPI: true
in window.MonacoEnvironment declaration to havemonaco
on the window
- fix: external table erroneously shown for materialized views
- feat: update language service
- feat: expose custom syntax error message options
- feat: update language service to support python code strings
- fix:
RenderOptions
type missingnull
property union variants
- fix: errors are shown twice on hover
- update language service.
- Expose formatting options
- Bug fix:
union *
is auto-formatted intounion*
- Bug fix: Intellisense doesn't show columns when using this syntax
materialized_view("<table name>") | where
- Bug Fix: In
mv-expand kind=array
kind is shown with a squiggly error line - Update @kusto/language-service-next
- Colorize public query options.
- Bug Fix: Format query hangs in some use cases.
- A function validation fails (shows squiggly red lines), if the function is defined with a parameter that has a default value, but it is used without passing a value for that parameter.
- Fix bug: Scalars function parameters are always showing "Table expected" error with squiggly error red line when using setSchemaFromShowSchema.
- Missing tokens are no longer added when formatting queries.
- Fix exception "Cannot read property 'getText' of null TypeError: Cannot read property 'getText' of null at e.parseDocumentV2"
- Added a sample react project
- Upgrade to latest monaco (which includes many changes amongst them accessibility improvements)
- Fix typo in 2.1.14.
- Add a theme with a darker background color.
- Fix error "Database has no tables".
- Allow formatting commands in cursor location.
- Upgrade to latest bridge.net which fixes an exception from indexOf.
- Schema with no functions was throwing "Cannot read property 'map' of undefined".
- Add DocString to onHover tooltip
- Update language service.
- Updated render kind typing to include map.
- Added
enableHover
option to languages settingss.
- Added
onDidProvideCompletionItems
to languages settings as callback function for doComplete operations.
- Fix
getCommandsInDocumentV2
not to take new lines as command.
- Fix
doRangeFormat
to work with all kind of user text selection.
- Added esm release bundles.
- Added package.json scripts to replace gulp completely.
- Fix
getRenderInfo
in cases where there is not with clause.
- Some more type fixes.
- Fixed typings.
- Added
getRenderInfo
that returns the render command visualization options in a query.
- Added
setParameters
that set parameters to the schema without providing the entire schema.
- Added
getReferencedGlobalParams
that returns the global (ambient) parameters that are actually being referenced in the query.
- Control command completion bug fix (updating intellisense library)
- null pointer exception fix.
- actually made the change described in 2.0.0
- [Breaking] Change default to use intellisense V2
- fix exception in CM & DM clusters when intellisenseV2 is on
- Abiltiy to get global parameters in scope (getGlobalParams)).
- Ability to injet global parameters to intellisense (in setSchema)
- Updated language service
- Fix corrupt monaco.d.ts
- Introduce a new function in language service called
getQueryParams
. it will return an array of all delcared query parameters for the query on cursor.
- Fix 1.1.13 to return ranges based on 1 (as monaco expects) rather than 0 (as kusto language server returns).
- Introduce a new function in language service called
getCommandAndLocationInContext
. it will return both the text and the range of the command in context.
- Update language service to latest version.
- Fix IE compatibility issue (remove new URL usage)
- Fix broken dependency on language service.
- don't suggest chart types that we do not support yet.
- don't kill web worker after 2 minutes of inactivity by default. Reason: In exterme cases where schema is very large, trying to stringify the schema in web worker causes an OOM. This is configurable though.
- Fix broken Diagnostics
- Fix vulnerability in dependency
- Support for adding and removing line comments with keyboard shortcut.
- Support hover
- Support for go-to definition, find all refrences, rename symbol.
- [Breaking] put minified versions of language serivce in npm package.
- [How to migrate]:
include the .min (minified files) rather than the unminified files (which are no longer available)
<script src="%PUBLIC_URL%/monaco-editor/min/vs/language/kusto/bridge.min.js"></script> <script src="%PUBLIC_URL%/monaco-editor/min/vs/language/kusto/kusto.javascript.client.min.js"></script> <script src="%PUBLIC_URL%/monaco-editor/min/vs/language/kusto/newtonsoft.json.min.js"></script> <script src="%PUBLIC_URL%/monaco-editor/min/vs/language/kusto/Kusto.Language.Bridge.min.js"></script>
- Increase contrast of operators in syntax highlighting.
- Updated dependency @kusto/language-service-next.
- Updated dependency on @kusto/language-service.
- [Breaking] Support monaco-editor v15. This removes supprot for pre 15 versions.
- Abiltiy to suppress completion items from intellisense.
- Dark theme support (set by calling monaco.editor.setTheme('kusto.dark'))
- Don't try to run logic on disposed models.
- Format current command always formatted the 1st command.
- Removed completion options that arent' curerntly supported.
- Colorization didn't work when asked to colorize entire document
- Updated language server dependnecy to latest version.
- improve V2 intellisense colorization performance.
- V2 intellisense now correctly reverts to V1 for control commands.
- Add decimal support to V2 instllisense .
- Fix v2 intellisense.
- fix quirks in interactions between non-semantic and semantic colorization by not using semantic coloring to color plain text.
- Fixed an issue where colorization is working on an older vesion of the document, which results in wrong colorization.
- Intellisense didn't work properly when editing in the middle of a block that is not the 1st block on the page.
- Monarch colorization now colorizes sub-opeators the same as semantic colorization (which makes the changes less jarring when completing semantic colorization).
- When switching context, colorization didn't recolorize.
- (perf) Only colorize the currently edited block(s) - this supports multi-cursor editing
- (perf) don't deeply parse the entire doc when doing completion. just get the list of commands and then parse the relevant command's all tokns.
- removed semantic colorization from main thread. From now on basic colorization (schema-unaware) will happen on main thread, and semantic colorization will happen in background thread. This should improve typing performance on long rows, or on large databases.
- Support for DM intellisense
- fix incorrect column types
- upgrade to latest kusto.javascript.client (based on a newer version of bridge.net and the code itself)
- upgrade to latest Kusto.Language.Bridge (based on a newer version of bridge.net and the code itself)
- improve performance for function parsing by levaraging new functionality in Kusto.Language.Bridge.
- Update langauge service dependencies to versions with unified bridge.net version and bridge.json settings.
- [breaking] Cache clutsser schema in memory. This breaks backward compatibility since it now requries schema to include minor and major version of databases.
- Upgrade version of Kusto.Language.Bridge so solve some issues.
- enable get current command logic to V2.
- Fix ability to set schema using .show schema as json.
- fix bug that caused diagnostics and colorizaiton to be wrong until first text was typed.
- fix bug that rendered validation unusable
- Add colorization support to intellisense API v2
- Add functions support to intellisense API V2
- update version of @kusto/language-service-next to 0.0.10, integrated following functionality:
- library orders items on its own, so no need to order in monaco-kusto
- add support for the cursor not ending in the end of the completion text (like in the 1st parmaeter7 of a function for example)
- add '|' after table name
- Make sure to never parse the same text more than once.
- add diagnostics (a.k.a error message) support (when v2 parser enabled).
- add folding (a.k.a outlining) support. one can now fold commands and hide them from screen.
- [breaking] - introduce new intellisense library (off by default). requires adding the following line to code
<script src="../node_modules/kusto-language-service/kusto.javascript.client.js"></script>
- [breaking] - Update monaco-editor peer dependency to "^0.12.0" because of bug fixes performed there. Also making the dependency more permissive (allow later minor versions).
- Add missing dependency bridge newtonsoft.json.js to npm package.
- updated @kusto/lagnuage-service to latest version. this contains the latest operators, documentation, and charting logic.
- Added peer dependency for
monaco-editor@0.11
so that consumers of the package get a warning if their version of monaco is too old.
- [breaking] - The package now requires
monaco-editor@0.11.1
to function correctly. adds support for markdown in intellisense documentation.
- Added
setSchemaFromShowSchema
: a new method to set a schema from the result of .show schema as json exewcution
- [breaking]: make setSchema async so that big schemas do not block the ui thread (specifically - tokenization code is running in ui thread so it can block rendering).
- fixed label casing of
editor.action.kusto.formatCurrentCommand
command.
- add
getAdminCommand
method toKustoWorker
, which returns an object with a boolean property signifying whether the text is an admin command, and a string property that contains the command without leading comments.
- null pointer exception when creating and destroying multiple monaco models
- add
getClientDirective
method toKustoWorker
, which returns an object with a boolean property signifying whether the text is a client directive, and a string property that contains the directive without leading comments.
- fix getCurrentCommand bug when there are multiple commands in document
- fix intellisense issue when trying to get suggestions for a new query (2 newlines after previous query)
- command formatting and document formatting now work (ctrl K + ctrl F and alt+shift+F respectively)
- setSchema does not update syntax highlighting
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.