Moor ships with an experimental analyzer plugin that provides real-time feedback on errors, hints, folding and outline.
At the moment, the IDE supports
- auto-complete to suggest matching keywords as you type
- warnings and errors for your queries
- navigation (Ctrl click on a reference to see where a column or table is declared)
- an outline view highlighting tables and queries
- folding inside
CREATE TABLEstatements and import-blocks
We would very much like to support syntax highlighting, but sadly VS Code doesn’t support that. Please upvote this issue to help us here.
To use the plugin, you need a supported editor (see below).
First, tell the Dart analysis server to run the moor plugin. Create a file called
analysis_options.yaml in your project root, next to your pubspec. It should contain
analyzer: plugins: - moor
Then, follow the steps for the IDE you want to use.
Using with VS Code
Make sure that your project depends on moor 2.0 or later. Then
- In the preferences, make sure that the
dart.analyzeAngularTemplatesoption is set to true. Contrary to its name, that flag turns on the plugin system, so you don’t need to worry about angular.
- Tell Dart Code to analyze moor files as well. Add this to your
json "dart.additionalAnalyzerFileExtensions": ["moor"]
- Finally, close and reopen your IDE so that the analysis server is restarted. The analysis server will
then load the moor plugin and start providing analysis results for
.moorfiles. Loading the plugin can take some time (around a minute for the first time).
Unfortunately, we can’t support IntelliJ and Android Studio yet. Please vote on this issue to help us here!
As a workaround, you can configure IntellIJ to recognize moor files as sql. Moor-only features like imports and Dart templates will report errors, but the rest of the syntax works well. See this comment on how to set this up.
If you’re looking for support for an other IDE that uses the Dart analysis server, please create an issue. We can probably make that happen.