Git Product home page Git Product logo

atom-language-julia's Introduction

Julia Grammar

Build Status

Julia grammar definition for Atom, VS Code, and GitHub.

The source of truth in this repo is grammars/julia.template.json; julia.json, julia.cson, and julia_vscode.json are automatically generated in a pre-commit hook or with npm run generate.

Contributing

We love contributors. Here are the steps we have taken to develop on this package:

  1. Install prerequisites: Node.js and npm (comes bundled with Node). We recommend using a Node version manager. LTS is recommended, but any node version newer than 14 should do.
  2. Clone this repo and cd into it
  3. Run npm ci
  4. Open grammars/julia.template.json in your favourite editor and fix a bug or implement additional highlighting rules
  5. Add corresponding tests at the bottom of test/test.js
  6. Run the updated tests with npm run test
  7. Once tests pass and you're happy with your changes, commit them and open a PR against this repo. This should automatically run a pre-commit hook that generates derivative grammars for VS Code and Atom from julia.template.json.

Testing the updated grammar in VS Code

Follow the julia-vscode developer instructions to get the extension setup. Afterwards, simply copy the updated julia_vscode.json from this repo into julia-vscode/syntaxes and you should see your changes in the debug editor after reloading it.

Contributor list

Atom package

Atom package (sunset end of 2022)

This is also an Atom package to provide Julia syntax highlighting, snippets, and docstring folding. Originally based off of JuliaLang/julia.tmBundle, merged with new ideas from language-julia.

Features:

  • Syntax highlighting
  • Snippets for common Julia keywords and constructs (see snippets/language-julia.cson)
  • Toggle folding of docstrings

Installation

Installation happens normally either through apm install language-julia or through the install section of the settings tab within Atom.

Note: if you already have a different version of language-julia plugin installed (e.g. this one), you would need to remove it first using apm uninstall language-julia

Recommended Extras

  • The LaTeX Completions package provides support for unicode characters similarly to the Julia REPL.
  • The Indent Detective package will help you keep to the style guidelines when working on Base or packages.
  • Install language-markdown for syntax highlighting in docstrings.
  • Install atom-language-r for syntax highlighting of R string macros.

Toggling docstrings

Two Atom commands are provided to toggle all docstrings or the docstring under the cursor: language-julia:toggle-docstrings and language-julia:toggle-all-docstrings. These are not assigned keys. Here is one example of adding these to keymaps using org-mode style keys:

'atom-text-editor[data-grammar="source julia"]:not([mini])':
  'tab':       'language-julia:toggle-docstrings'
  'shift-tab': 'language-julia:toggle-all-docstrings'

atom-language-julia's People

Contributors

alyst avatar apieum avatar ararslan avatar aviatesk avatar beastyblacksmith avatar benph avatar catawbasam avatar garborg avatar grayjack avatar haberdashpi avatar jarrison avatar jbruer avatar jianghaizhu avatar keno avatar kylebarron avatar maximsch2 avatar mikeinnes avatar mitiemann avatar mortenpi avatar paalon avatar pfitzseb avatar sbromberger avatar scls19fr avatar sglyon avatar tetralux avatar totalverb avatar tshort avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

atom-language-julia's Issues

Pair infix constructors confuse coloring

Any function calls that occur on the same line as a => gets colored as a function definition. This actually extends outward to the left; nested calls are all colored, unless an outer call occurs on a separate line.

screen shot 2016-10-01 at 1 44 09 pm

Also note the weird indentation--though I think that's JunoLab/Atom.jl#62, which has been addressed.

Should add an explicit license file

The package.json file says MIT, but could always be more explicit about it.

Should ask for permission on reused code from the previous package, just in case.

Doesn't handle this syntax `t("(")`

Everything after is ends up being highlighted as if it was a string. So in that example the closing brace would be highlighted the same colour as the brace between the quotes.

t("(")

This seems to of been caused by the latest update too by the way

Colouring of typed functions different

I noticed that usually functions (kind a orange) that are typed get the type brace colored yellowish,
which I think is nice. However, this does not happen for typed operators, as the following screenshot illustrates.
typedcolor
Is that intentional? I think it would be nicer to have a typed operator also embraced with a yellowish type bracket

Version bump?

Assuming we're replacing the existing language-julia package, I think we need a higher version number. Right now, my (heavily modified local install of) Atom prompts me to upgrade this package to the old package that we're replacing.

BUG: Tab completion of sub modules

Not sure if this is a problem in this package or somewhere else, but when I try tab-completions of submodules the parent module gets consumed. Eg. - if I'm using Gadfly and type Coord., I get a list of completions, select Cartesian and hit <tab>, then instead of Coord.Cartesian I end up with just Cartesian

broken highlighting for md"""....""" strings

The following code breaks the highlighting logic:

edit_magic_help(magic::AbstractString, args::AbstractString) = md"""
    An analogue of IPython's `%edit` magic is provided by
    the `edit` function and the `@edit` macro in Julia, as
    described [in the Julia manual](http://docs.julialang.org/en/latest/stdlib/base/#Base.edit).

    For example, instead of `%edit -n line 'filename'"` in IPython, you would do
    `edit("filename", line)` followed by `include("filename")` if you
    want to execute the file when you are done editing.  The analogue
    of `%edit` (which creates a temporary file) is `n=tempname(); edit(n)`
    followed by `include(n)`.

    If you have a function `foo()`, then `%edit foo` in IPython opens
    the file where `foo` was defined.  The analogue of this in Julia is
    to do `@edit foo()`   Note that you need to supply sample arguments
    to `foo` (which is not actually called), so that Julia knows *which*
    method of `foo` you want to edit.

    If `s` is a string variable, IPython's `%edit s` loads its contents
    into an editor.  In Julia, you would have to explicitly write
    to a temporary file with `n=tempname(); write(n, s); edit(n)` followed
    by `include(n)` to execute it."""

# any subsequent code is highlighted as if it were part of a string!!

Is this package listed in the APM?

sorry for posting a question here instead of an issue - but if I wanted to move to atom-language-julia from language-julia, how would I do it?

(Perhaps something in README.md?)

Cannot start Julia within Atom using Juno

I have just installed Juno-atom on my windows 7 64bit Pro PC. Julia version is 0.4.5 and it runs OK in its own window. I cannot get Juno to recognize the path "C:\Users\Eagle\AppData\Local\Julia-0.4.5\bin\julia.exe" I have tried "//", "", "", everything I can think of. It will not recognize the path.

What am I doing wrong?

Thank,

Tom Eagle

Inconsistent highlighting of DataTypes

Highlighting every other of the following is worse than no highlighting at all:

x = [Int, Bool, Vector, Array, Integer, FloatingPoint, DataArray, DataFrame]

Seems like consistent options are:

  • Highlight every type exported from Base
  • Go farther highlighting everything that's proven to be a type by syntax (e.g. x = Union{...............})
  • Both of the above
  • Remove 'storage.type.julia'

I think the latter is the cleanest and means the least distracting false alarms, but I wouldn't be that surprised if others like the second option.

Thoughts?

Evaluating A Script Does Not Open Plot Window

If you evaluate the whole script via Shift+Enter, the script will run but the plots won't display. Example code:

using Gadfly
x = 0:.01:2
y = rand(length(x))
println(y)
plot(layer(x=x,y=y,Geom.line))

If you Shift+Enter, it prints y but does not display the plot. If you then click to the line for the plot and do Ctrl+Enter it will display the plot.

Whitespace in type annotation should be ignored

The following two snippets should be interpreted identically.

x::UInt8
x   ::   UInt8

When you have a function or type constructor which takes lots of arguments, such that you break them up into multiple lines, it is nice to be able to align them. :)

function doit(
        firstarg :: Int
        second   :: UInt
        third    :: Bool
        forth    :: AbstractArray)

   # function body
end

Or, if they are kwargs...

function doit(;
        firstarg ::           Int = -45
        second   ::          UInt = 247
        third    ::          Bool = true
        forth    :: AbstractArray = [])

   # function body
end

malformed increaseindent regex

The current regex to increase indentation level is

^(\\s*|.*=\\s*|.*@\\w*\\s*)(if|while|for|function|stagedfunction|macro|immutable|type|let|quote|try|begin|.*\\)\\s*do|else|elseif|catch|finally)\\b(?!.*\\bend\\b[^\\]]*$).*$

Pasting that into http://regexpal.com/ highlights an extra closing paren. I'm not familiar enough with what this regex is supposed to do, but I'm guessing that might be causing some trouble.

Markup broken for certain Blockquotes in @doc s

If I have the following @doc string

"""
    myFunction() computes something based on the reference
> My Paper I Would like to quote
> Further quote...
"""

The editor gets confused in its markup and does not recognize the closing """. Everything until the end of the document is marked as if it was code in (colorwise).

However as noted by @spencerlyon2 here adding an empty line direktly after the last line starting with > fixes the markup, i.e.

"""
    myFunction() computes something based on the reference
> My Paper I Would like to quote
> Further quote...

"""

yields a correct color markup and the same if even theres more text following the quote, it only colors the code following correctly if theres a blank line after the blockquote.

Docstring Highlighting

This docstring makes highlighting go funky:

"""
    @switch isa(x, _) begin
      Integer; "x is an integer!"
      FloatingPoint; "x is a float!"
      "x is something else!"
    end

Where `_` is replaced by the value for testing in each case. The final
"""
macro switch(args...)

screenshot 2015-08-02 12 51 32

The _ seems to start an italic section despite being in a code block, and this doesn't happen without the ). Also, for some reason the final """ isn't closing off the docstring either.

Highlighting top-level strings as markdown is a great idea, but maybe it would then be good to remove the string scope so that the default colour isn't yellow. It'd also be pretty cool if we could highlight indent code blocks as Julia by default.

Scoping of symbols is incomplete

There's some confusion in the spec as to what really constitutes a symbol, and in turn how we check for and handle the keyword.other, storage.modifier and keyword.control categories.

At the moment, we tokenize general symbols (e.g. :foo) with a negative look behind checking for a :. The colon here matches another representation, which is the keyword.operator.range.julia category (previously operator.ternary) and what follows becomes constant.other.symbol.julia.

Thus, we have two different colours highlighting one thing, and in the back end we get this complication that symbols are actually somehow also a range. The probable fix for this would be drop the negative look behind for symbols, but add a negative look ahead on the range.

The second point, which is where I feel some confusion comes in inside the spec are the checks for these three categories I listed above. Each have a test that matches scopes exactly the same as the symbols, so whilst they currently pass, it looks as though these tests are incomplete. In addition to that, storage.modifier's test looks for :using, but using isn't even in storage.modifier, it has its own category keyword.control.using.julia.

What I think needs to happen here is actually drop the : in front of each of the tests for these three categories. Why are we testing for symbols of these keywords anyway? I may be missing something here, but it seems to make more sense without the colons. Then the tests can be matched against the proper scopes.

If this gets sorted out, I'd say that #75 should also be inherently (or at least easily) solved.

I think I can fix these issues pretty quickly, but some feedback on my thoughts would be appreciated.

BUG: currently indexing an array thinks the array is a type

In

xs[i]

we would have that xs is scoped as a type. I can think of a few instances where we want this to be a type:

  • Float64[] -- creating an empty, typed array
  • Float64[1, 2, 3] -- creating a non-empty, typed array
  • Float64[f(i) for i in x]-- typed comprehension

Not sure how we separate case 2 and indexing...

Maybe we just wait until when (if?) Jeff wins and we moved the type for typed comprehensions/arrays to the end (e.g. [...]T instead of the current T[...])

Highlighting bug caused by ' and subscripts

The highlighting of '(transpose) is mistakenly recognized as '' when using cascaded subscripts:

bug

Currently, a workaround is to use brackets, but I hope this can be fixed. Thanks!

BUG: Splitting plots to a new pane is a pain.

If you make a plot in Gadfly but then want to split the plot to a new screen, you get the following error. I was able to reproduce it on 3 computers: 2 Windows, 1 Linux.

Uncaught Error: The workspace can only contain one instance of item [object Object]
/usr/share/atom/resources/app.asar/src/item-registry.js:11
Hide Stack Trace
Error: The workspace can only contain one instance of item [object Object]
at ItemRegistry.module.exports.ItemRegistry.addItem (/usr/share/atom/resources/app.asar/src/item-registry.js:11:15)
at PaneContainer.module.exports.PaneContainer.addedPaneItem (/usr/share/atom/resources/app.asar/src/pane-container.js:374:25)
at /usr/share/atom/resources/app.asar/src/pane-container.js:353:19
at /usr/share/atom/resources/app.asar/src/pane-container.js:97:16
at Function.module.exports.Emitter.simpleDispatch (/usr/share/atom/resources/app.asar/node_modules/event-kit/lib/emitter.js:25:14)
at Emitter.module.exports.Emitter.emit (/usr/share/atom/resources/app.asar/node_modules/event-kit/lib/emitter.js:125:28)
at PaneContainer.module.exports.PaneContainer.didAddPane (/usr/share/atom/resources/app.asar/src/pane-container.js:293:27)
at Pane.module.exports.Pane.setContainer (/usr/share/atom/resources/app.asar/src/pane.js:98:26)
at PaneAxis.module.exports.PaneAxis.addChild (/usr/share/atom/resources/app.asar/src/pane-axis.js:144:13)
at PaneAxis.module.exports.PaneAxis.insertChildAfter (/usr/share/atom/resources/app.asar/src/pane-axis.js:216:19)
at Pane.module.exports.Pane.split (/usr/share/atom/resources/app.asar/src/pane.js:710:23)
at Pane.module.exports.Pane.splitRight (/usr/share/atom/resources/app.asar/src/pane.js:672:19)
at atom-tabs.TabBarView.splitTab (/usr/share/atom/resources/app.asar/node_modules/tabs/lib/tab-bar-view.js:392:31)
at Object.addElementCommands.tabs:split-right (/usr/share/atom/resources/app.asar/node_modules/tabs/lib/tab-bar-view.js:127:26)
at atom-tabs.commandsWithPropagationStopped.(anonymous function) (/usr/share/atom/resources/app.asar/node_modules/tabs/lib/tab-bar-view.js:78:36)
at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/usr/share/atom/resources/app.asar/src/command-registry.js:260:29)
at CommandRegistry.handleCommandEvent (/usr/share/atom/resources/app.asar/src/command-registry.js:3:61)
at CommandRegistry.module.exports.CommandRegistry.dispatch (/usr/share/atom/resources/app.asar/src/command-registry.js:160:19)
at AtomEnvironment.module.exports.AtomEnvironment.dispatchContextMenuCommand (/usr/share/atom/resources/app.asar/src/atom-environment.js:1019:28)
at emitTwo (events.js:87:13)
at EventEmitter.emit (events.js:172:7)
at EventEmitter.ipc.sendSync (/usr/share/atom/resources/atom.asar/renderer/api/lib/ipc.js:21:31)
at BrowserWindow.RemoteMemberFunction as emit
at ContextMenuManager.module.exports.ContextMenuManager.showForEvent (/usr/share/atom/resources/app.asar/src/context-menu-manager.js:156:33)
at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentContextmenu (/usr/share/atom/resources/app.asar/src/window-event-handler.js:250:47)
at HTMLDocument. (/usr/share/atom/resources/app.asar/src/window-event-handler.js:3:61)
The error was thrown from the tabs package. This issue has already been reported.

Identifier highlighting

Regular variables like foo are not highlighted any more specifically than source.julia. I don't know what the standard is for variables but if we could label them as identifier or variable or something that would be really useful.

The reason being that secret plugins, which may or may not exist, might want to highlight variables differently depending on whether they are defined or not.

Different Standard Highlighting for Symbols?

symbols

I think it would be helpful if the default highlighting for symbols was different from type annotations, functions, etc. As it stands, if you use some symbols, your whole code turns the same color (as seen in the picture).

Inconsistent highlighting of Module.name

e.g.

Base.map(+, 4:-1:2) # 'Base.' is highlighted as part of the function
Base.@time(1 + 1) # 'Base.' is not

I'd prefer not highlighting as part of the function, as it would leave Base. highlighted consistently with Base.CONST, import Base, etc.

Thoughts?

TODO, etc, not detected in single-line comments

Here is the issue:

in

# TODO do a thing

The TODO should be highlighted. It it not. By comparison with

#=
TODO do a thing
=#

where it is. TODO and a few others are part of language-todo, which is standard in atom.

Ligature support is being removed in some cases.

Atom v1.1.0 now officially supports ligatures. When this package is active, not all ligatures are displaying.

An example: The left frame has a Julia file and the right an untitled document. The untitled document has != and <= ligatures working, although once saved into a .lj and syntax highlighted, the ligatures are no longer visible.
julia

Not all ligatures are removed, for example -> still works. The problem doesn't occur in other file types (for example a .cpp or .hs file, which aren't syntax highlighted via this package), and I've tested this with most of the ligature enabled fonts: no changes there either.

package name and version

since the release of 0.9.0, atom seems to be extremely confused about which package to install, this one, or the one created by tpoisot.

Could you please tag 0.9.1, just so atom can distinguish the two packages again.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.