diff --git a/CHANGELOG.md b/CHANGELOG.md index c8d29b1..104d0a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,44 +1,68 @@ -## WIP -- Improved error message parsing +# Changelog +All notable changes to this project will be documented in this file. -## 0.7.0 - Split grammar definitions +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) +and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [0.8.0] - 2017-11-17 +### Removed +- Moved the linting functionality into a seperate package, [`linter-mzn`](https://github.com/Dekker1/linter-mzn). With eyes to the future and possibility for a full MiniZinc Suite in Atom. + +## 0.7.0 +### Changed - Create seperate definitions for FlatZinc + Output models and DZN files. +### Fixed - Fixes linting error when opening DZN files -## 0.6.1 - Moved repository +## 0.6.1 +### Changed - Change the repository URL -## 0.6.0 - Linter v2 +## 0.6.0 +### Changed - Upgrade to Linter API v2 -## 0.5.0 - Column matching +## 0.5.0 +### Added - The linter now indicates the right column if indicated by `mzn2fzn` ## 0.4.1 +### Changed - Enables the user to disable linting in the package settings +### Fixed - Fixes problem in highlighting of numerical constants ## 0.4.0 +### Added - Combines the linter and syntax highlighting package (formerly https://github.com/jjdekker/linter-mzn). I'll look into the possibility of disabling the linter extension at a later stadium. ## 0.3.2 +### Fixed - Removes some duplicate syntax - Fixes the highlighting of numerical constants -## 0.3.1 - One tab too far -- Removes an tab in the forall snippet. +## 0.3.1 +### Fixed +- Removes an tab in the `forall` snippet. -## 0.3.0 - Colored constraints -- Adds function coloring to all predicates documented in the 2.0 documentation. +## 0.3.0 +### Added +- Adds function colouring to all predicates documented in the 2.0 documentation. - Adds indentation rules for parentheses +### Changed - Removes newlines from snippets (just press enter, the indentation rules will do the rest) -## 0.2.0 - Snippets +## 0.2.0 +### Added - Adds snippets for basic MZN functionalities - Adds snippets for possible solve statements -## 0.1.1 - `endif` +## 0.1.1 +### Fixed - Adds syntax highlighting for the `endif` keyword -## 0.1.0 - First Release +## 0.1.0 +### Added - Basic syntax highlighting + +[0.8.0]: https://github.com/Dekker1/linter-mzn/compare/v0.7.0...v0.8.0 diff --git a/README.md b/README.md index 91f854a..5321bed 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MiniZinc for Atom -This package adds syntax highlighting and optional linting for the MiniZinc modeling language (.mzn and .dzn files). The package is based on the [similar package for Sublime](https://github.com/astenmark/sublime-mzn). +This package provides a MiniZinc grammar for Atom to add syntax highlighting. ![A small preview](https://raw.githubusercontent.com/jjdekker/language-mzn/master/sample.png) diff --git a/lib/init.coffee b/lib/init.coffee deleted file mode 100644 index 02605c3..0000000 --- a/lib/init.coffee +++ /dev/null @@ -1,43 +0,0 @@ -{CompositeDisposable} = require 'atom' - -module.exports = AtomLanguageMZN = - config: - enableLinter: - type: 'boolean' - default: true - description: "Enable linting using `mzn2fzn`" - mzn2fznPath: - type: 'string' - default: 'mzn2fzn' - description: 'Path to Minizinc\'s compiler `mzn2fzn`' - - activate: (state) -> - console.log 'language-mzn: package loaded, - ready to get initialized by AtomLinter.' - - if not atom.packages.getLoadedPackage 'linter' - atom.notifications.addError 'Linter package not found', - detail: '[language-mzn] `linter` package not found. \ - Please install https://github.com/AtomLinter/Linter' - - @subscriptions = new CompositeDisposable - - @subscriptions.add atom.config.observe 'linter-mzn.mzn2fznPath', (mzn2fznPath) => - @mzn2fznPath = mzn2fznPath - - deactivate: -> - @subscriptions.dispose() - - serialize: -> - AtomLanguageMZNViewState: @AtomLanguageMZNView.serialize() - - provideLinter: -> - LinterMZN = require('./linter-mzn') - @provider = new LinterMZN() - return { - name: 'MiniZinc', - grammarScopes: ['source.mzn'], - scope: 'file', - lintsOnChange: true, - lint: @provider.lint - } diff --git a/lib/linter-mzn.coffee b/lib/linter-mzn.coffee deleted file mode 100644 index 561e922..0000000 --- a/lib/linter-mzn.coffee +++ /dev/null @@ -1,77 +0,0 @@ -{BufferedProcess} = require 'atom' - -class LinterMZN - lintProcess: null - - config: (key) -> - atom.config.get "language-mzn.#{key}" - - lint: (textEditor) => - if @config 'enableLinter' - return new Promise (resolve, reject) => - output = '' - command = @config 'mzn2fznPath' - args = ['--instance-check-only', textEditor.getPath()] - options = process.env - - stdout = (data) -> - atom.notifications.addWarning data - stderr = (data) -> - output += data - exit = (code) => - if code is 0 - resolve [] - else - messages = @parse output, textEditor.getPath() - resolve messages - - @lintProcess = new BufferedProcess({command, args, options, stdout, stderr, exit}) - @lintProcess.onWillThrowError ({error, handle}) -> - atom.notifications.addError "Failed to run #{command}", - detail: "#{error.message}" - dismissable: true - handle() - resolve [] - else - return [] - - parse: (output, filePath) => - messages = [] - output = output.split('\n') - warningLines = (i for line, i in output when /:([0-9]+):/.test(line) && ! /(did you forget to specify a data file\?)/.test(output[i+1])) - - i = 0 - while i < warningLines.length - if i >= warningLines.length - 1 - messages.push @generateMessage output[warningLines[i]..], filePath - else - messages.push @generateMessage output[warningLines[i]..warningLines[i+1]-1], filePath - i++ - - return messages - - generateMessage: (output, filePath) -> - match = output[0].match(/:([0-9]+):/) - line = parseInt(match[1]) - output = output[1..] - - startcol = 0 - endcol = 500; - if output.length > 1 and /\^/.test(output[1]) - startcol = output[1].match(/\^/).index - endcol = output[1].match(/\^(\s|$)/).index + 1 - output = output[2..] - - message = { - severity: 'error', - excerpt: output.join('\n').replace(/MiniZinc: /, ""), - location:{ - file: filePath, - position: [[line-1,startcol], [line-1,endcol]], - } - } - - return message - - -module.exports = LinterMZN diff --git a/package.json b/package.json index 1d3f860..b4834ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,5 @@ { "name": "language-mzn", - "main": "./lib/init", "version": "0.7.0", "description": "A language package for the MiniZinc constraint modeling language", "repository": "https://github.com/Dekker1/language-mzn", diff --git a/sample.mzn b/sample.mzn index eeeb0bc..8f41d6d 100644 --- a/sample.mzn +++ b/sample.mzn @@ -2,9 +2,7 @@ include "globals.mzn"; % parameters -int: n=; - - +int: n=8; % variables array[1..n] of var 1..n: R; diff --git a/sample.png b/sample.png index 8b5ab0d..eab8af3 100644 Binary files a/sample.png and b/sample.png differ