Coder Social home page Coder Social logo

elixir-tmbundle's Introduction

Elixir.tmbundle

A TextMate / Sublime Text Bundle for the Elixir programming language.

It provides syntax highlighting, snippets, and keybindings. Contributions and extensions are welcome!

Note: For a package that provides tighter and more up-to-date integration with Sublime Text 4, see ElixirSyntax.

Installation

If you are using TextMate 2 you can install from Preferences → Bundles. To install manually type the following commands in your shell:

mkdir -p ~/Library/Application\ Support/TextMate/Pristine\ Copy/Bundles
cd ~/Library/Application\ Support/TextMate/Pristine\ Copy/Bundles
git clone git://github.com/elixir-lang/elixir-tmbundle Elixir.tmbundle

If you are using Sublime Text 3, type the following commands in your shell:

cd ~/.config/sublime-text-3/Packages # If you are on Linux
cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages # If you are on OS X
cd %HOMEPATH%\AppData\Roaming\Sublime^ Text^ 3\Packages # If you are on Windows Vista or above
cd %HOMEPATH%\Application^ Data\Sublime^ Text^ 3\Packages # If you are on Windows XP
git clone git://github.com/elixir-lang/elixir-tmbundle Elixir

You can now use Elixir's color syntax in files. In some cases, you should restart Sublime Text to make changes work.

Installation for outdated editors

Type the following commands to setup the bundle for TextMate 1:

mkdir -p ~/Library/Application\ Support/TextMate/Bundles
cd !$
git clone git://github.com/elixir-lang/elixir-tmbundle Elixir.tmbundle
cd Elixir.tmbundle
git checkout tm1
osascript -e 'tell app "TextMate" to reload bundles'

If you are using Sublime Text 2, type the following commands in your shell:

cd ~/.config/sublime-text-2/Packages # If you are on Linux
cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages # If you are on OS X
cd %HOMEPATH%\AppData\Roaming\Sublime^ Text^ 2\Packages # If you are on Windows Vista or above
cd %HOMEPATH%\Application^ Data\Sublime^ Text^ 2\Packages # If you are on Windows XP
git clone git://github.com/elixir-lang/elixir-tmbundle Elixir
cd Elixir
git checkout tm1

Code formatting for Sublime Text 3

Elixir v1.6 includes a code formatter. This package includes super+shift+c as a keybinding to automatically save and format the current file you are working on. If the file has invalid syntax, an alert will appear.

You can also add your own keybindings as follows:

{ "keys": ["super+e"], "command": "mix_format_file" }

You can also set up the package to automatically format the file on save. To do this, go to Preferences -> Package Settings -> Elixir -> Settings and add "mix_format_on_save": true.

elixir-tmbundle's People

Contributors

azizk avatar bharendt avatar binaryseed avatar bryanenders avatar caiquemitsuoka avatar elia avatar ericmj avatar hedgesky avatar infininight avatar jayjun avatar jefffederman avatar josevalim avatar maxmellen avatar murb avatar pchaigno avatar pgbezerra avatar princemaple avatar rgreenjr avatar robin850 avatar sevab avatar smanolloff avatar sriehl avatar srpelissier avatar stanislav-lapata avatar syamilmj avatar talklittle avatar tarzan avatar thomasbrus avatar xtian avatar ybakos 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  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  avatar  avatar  avatar  avatar

elixir-tmbundle's Issues

Issues with -> in string

defmodule Test do
  def test do
    IO.puts "->"
    ret
  end
end

both the "puts" and "ret" are parsed as parameters (orange in sublimetext 3).

New changes break syntax highlight on Sublime Text 3

Seems like the latest changes break syntax highlighting when using Sublime Text 3 or at least reduce it's functionality. Function parameters are all shown with same color and worse, the module name is not highlighted in statements like below:

use Behaviour
require Logger
Enum.map [1,2,3], fn x -> x + 1 end

Here is a couple of screenshots showing what it looks like for me:

The last working one was commit 56efe61
working-56efe6116ff92a6979ba94ff2722486e3f440583

The next commit seems to break function parameters:
breaking-1334da9633fec669e80487f448e1b001b2767a6c

And the current master 1a062c3 has breaking Module highlights.
master-1a062c327dcb418462c8d5351990d0cdc13545f3

I do like the fact of trying to highlight functions, but I think the module highlighting is more important for readability, at least in my codebase. Not sure if this issue is related to Sublime Text 3 or does it happen with other editors supporting textmate syntax format.

Possibility of moving syntax definitions into a separate repository

There are some other language support extensions for different editors. Some of those editors directly (Visual Studio Code) or indirectly (Visual Studio Code or Atom) can use .tmLanguage syntax files.

Currently there are multiple Elixir extensions for those editors:

Each of those packages currently maintains its own, incompatible and different syntax definition.

It could be possible to split the current .tmLanguage grammars into their own repository that could then be reused by different editor support packages (including this one).

The good part is that there would be a single source of truth for the Elixir grammar definition across editors, unifying the maintenance efforts.

I could make the changes myself and submit a PR, but I prefer to discuss it first to see if it would make sense.

Different highlighting with default args header

Adding a function header with a default argument is breaking syntax highlighting for this particular module. See commented line (correct highlighting):

screen shot 2017-03-20 at 15 21 15

Uncommented:

screen shot 2017-03-20 at 15 21 29

Minimal code for reproduction:

defmodule Legacy.ExtraAsserts do
  def assert_date_approx(date1, date2, ms_delta \\ 100)

  def assert_date_approx(date1, date2, ms_delta) do
    assert_in_delta(date1_ms, date2_ms, ms_delta)
  end
end

This is on Sublime Text Build 3126

Issue with head/tail syntax in a tuple

Example:

  todo = "Learn Elixir"
  todos = []
  foo = {:bar, [todo | todos]} # syntax highlighting fails from here down
  {:noreply, [todo | todos]}

I'm not sure when I'll have time to take a crack at this, but I figured I'd file the issue anyway. I noticed this issue on Github and Sublime.

TextMate version 2.0-beta.7.1 - installation failed

I tried to install the Textmate bundle as suggested and it failed as follows:

Bundles  osascript -e 'tell app "TextMate" to reload bundles'
23:37: syntax error: A identifier can’t go after this identifier. (-2740)

Anyway, the bundle is in the Textmate bundle list with all its submenus and options. Is it normal ?
Any ideas ?
OS: OS X 10.10.3 x64

Thank you.

Consider making _word or _ grey

Since these are discarded in pattern matching syntax, the color should be grey to indicated the irrelevance. The only purpose is to signify and comment the code so grey(same as comments) should be the color.

Ctrl+B (aka Tools->Build) is not Mix friendly

I usually find myself editing a file inside a project with SublimeText3 and Ctrl+B calls elixir, completely ignoring Mix so if I have things that require in my code I get module Benchmark is not loaded and could not be found

the command is here: https://github.com/elixir-lang/elixir-tmbundle/blob/master/elixir.sublime-build#L5

I was wondering if it makes sense to have it run mix somehow but not sure how it would detect the current project's root because it's getting passed a file, and for that matter how would it know if I wanted to run mix test or mix run (in my case it's a test file so I wanted mix test)

But even if I wanted to run one of those two, I wouldn't know how to make mix run from project root folder instead of folder where the file is

that's where sublime wants to run it:

Sun 07/28/2013 18:50:06.23 S:\workspace.elixir.2013\elixir_exhaust_samples\test>call mix.bat test S:\workspace.elixir.2013\elixir_exhaust_samples\test\elixir_exhaust_samples_test.exs   2>&1  | wac
** (Mix) Cannot run tests because test helper file "test/test_helper.exs" does not exist
[Finished in 1.7s]

I guess I could customize my own .bat file to be run for my project and have it placed in my project near the file that I'm editing so that way, depending on the folder that I am in, it would always run the right commands(in the batch file), so having elixir.bat files in the test folder which do cd .. && mix test and in the lib folder which do cd .. && mix run hmm, interesting so far... I guess there's no point for me to raise this issue anymore, maybe I submit+close it just so this wasn't all in vain :) or maybe you guys have other ideas about it

Interpolated string snippet #{} should allow manually typed brace

PR #103 was an improvement, but would be perfect if it did not duplicate the {} if you manually type #{}

As soon as you type # within a string, it adds the {} which is fine. But if you continue to type the opening brace, so you've typed #{ so far, then it ends up as #{{}} which is annoying. Would be better if the manually-typed { is ignored.

Single line function's `do` being rendered as keyword list

I updated recently and I've found that in a single-line function, the do: and else: look like they're being treated as a keyword list instead of the standard operator

def start_link(_), do: Supervisor.start_link(_args)

screen shot 2015-11-08 at 10 22 11 pm

Previously, it'd look like this:

screen_shot_2015-11-08_at_10_20_34_pm

cc/ @endersstocker I see you're tagged on a handful of these recent issues, could you help track this one down? I tried fixing it myself, but the tmLanguage format isn't exactly straightforward...

/usr/local/bin/elixir: line 126: exec: erl: not found

Hello,

I'm using bundle with sublime 3 my installation path is /usr/local/bin/ (homebrew installation)

and this is my build file

{ "cmd": ["/usr/local/bin/elixir", "$file"], "selector": "source.elixir", "windows": { "working_dir": "$file_path", "cmd": ["elixir.bat", "$file_name"] } }

with cmd+b returns

/usr/local/bin/elixir: line 126: exec: erl: not found

any ideas?

mix_format_on_save causes formatter to run on EEx templates in SublimeText

I installed the package for SublimeText 3 and configured the preferences as:

{
  "mix_format_on_save": true,
  "reload_after_mix_format": true
}

Now, whenever I save an HTML(EEx) template the mix format task is being run on this file. I would either expect this file type to be excluded by the formatter config file or by the run command in the python script. The former is (presumably) by design and the latter goes wrong here:

if scope.find('source.elixir') != -1:

as it matches these in the EEx templates:
<string>source.elixir</string>

and EEx tags are being supported in the HTML templates since 36aa122

Regression in binary (string) interpolation tokenizer (Sublime Text 3)

I think that this change introduced a regression in the binary interpolation syntax: "#{}". It also affects heredocs (""") and sigils (~w and ~s, e.g. ~w(foo #{1+1})). This is happening on Sublime Text 3 on macOS.

(I noticed this yesterday even though it looks like the PR was merged in August. I'm not sure if Sublime/PackageControl hadn't updated this package until a few days ago, or if recently I've just not written enough Elixir to notice earlier.)

I have configured my own color scheme to highlight Elixir in a way consistent with Ruby. For example, this snippet contains some Elixir code highlighted as Ruby, to illustrate how Sublime has usually highlighted Elixir before this regression:

ruby

With the regression, I now see this:

elixir

In the past, when this elixir-tmbundle package introduced breaking changes I would just update my color scheme to match the new tokenization. This time I can't because of an issue with the closing } character.

The next four screenshots illustrate the language scopes that the tokenizer is assigning.

opencloseclose_wrongscreenshot 2018-11-21 at 13 28 09

The new bits are the begin and end in punctuation.section.embedded.begin.elixir. That is fine, I can just update the color scheme to deal with those. The problems are:

  1. The closing } character is tokenized with a further scope: source.elixir. It's being treated as source code.
  2. When the interpolation block #{} contains something that ends with } (for example a tuple), then the closing } of the tuple will be used as end of the interpolation block, and the actual closing } will not be tokenized at all, and treated as part of the string.

With these two issues fixed, I will be able to update my color scheme.

While I'm opening this issue to report the regression, I'd also like to ask why #155 had to introduce so many breaking changes (the PR doesn't say). Was it to ensure compatibility with the latest TextMate 2? A quick Google search suggests that today Sublime Text is widely more used than TextMate (1 or 2), so I wonder if introducing so many syntax definition changes is worth it and if they can be rolled back.

If they can't, and this issue can't be fixed, I suppose that another option would be to stop managing this package with Package Control and just install it manually with git, and target the tm1 tag, that points to the latest commit before #155 was merged.

Add this project to "Sublime Package Control"

( @rodrigoflores please read, this is related to your elixir-sublimetext project )

I think it would be nice to add this project as a package in Sublime Package Control. That's easy, but the tricky part is, I think its name should be "Elixir," but there is already an existing package with that name. Since the existing package is an older, out-of-date version of this project, I'd suggest removing the existing package and then adding this one.

The existing package is elixir-sublimetext by @rodrigoflores. Other than the readme, it has just one file, Elixir.tmLanguage, which is identical to an old version of that file in this project, from June 10, 2012 (653bb06). It doesn't have the latest additions to that file, nor does it have the other features that this project has, such as snippets, indenting, comment/uncomment, and so on.

Sublime Package Control, for those who don't know, is the ubiquitous package manager that is used by most Sublime Text users when they want to install a package. It is a very popular way of finding packages for Sublime Text, and most users use that instead of directly cloning a repo.

@rodrigoflores I hope you're okay with removing your project from Sublime Package Control, and adding this one. What do you say?

could `def*` `end` act like brackets?

If they could, Ctrl+M would be able to jump through them just like it does for brackets

I find myself looking at and end whose def I cannot find/see, especially since Reindent lines didn't do a great job (probably because of the # comments inbetween)

oh wait I see it, it's a fn() -> that's the beginning of this end

Textmate 2

I'm on TM2 beta nightly builds and it looks like they gonna make it 2.0 soon, so currently they got rid of Avian directory so this won't work:

mkdir -p ~/Library/Application\ Support/Avian/Bundles
cd ~/Library/Application\ Support/Avian/Bundles
git clone git://github.com/elixir-lang/elixir-tmbundle Elixir.tmbundle

instead the directory was named as for TM1 version:

mkdir -p ~/Library/Application\ Support/TextMate/Bundles
cd ~/Library/Application\ Support/TextMate/Bundles
git clone git://github.com/elixir-lang/elixir-tmbundle Elixir.tmbundle

Maybe we should add an extra section for those who's on TM2.0 beta nightly builds... not sure

Double quoting in Windows / Sublime Text 3

I'm using Sublime Text 3, and I get the error
path\to\file.ex""=="" was unexpected at this time (double quoting) from the build system + elixir.bat file. I am able to build with the following modifications to the build file:

...
"windows": {
"cmd": ["elixir.bat", "$file"]
}
...

to

...
"windows": {
"working_dir": "$file_path",
"cmd": ["elixir.bat", "$file_name"]
}
...

Formatter not working

I'm using Sublime Text 3.1 and I cannot get my formatter to work.

I've enabled format_on_save in my package settings but whenever I save i get the following message in the ST console:

no such context .nest_curly_and_self in Packages/Elixir/Syntaxes/Elixir.tmLanguage
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 1072, in run_
    return self.run(edit)
  File "/Users/johan/Library/Application Support/Sublime Text 3/Installed Packages/Elixir.sublime-package/mix_format_file.py", line 49, in run
  File "./python3.3/subprocess.py", line 819, in __init__
  File "./python3.3/subprocess.py", line 1448, in _execute_child
FileNotFoundError: [Errno 2] No such file or directory: 'mix'

Do I need to configure anything in particular in order to get the formatter to work?

Enable Auto-pairing for common markdown chars

I find this a missing feature when I need to use backticks around code.
Also i think I could be useful to add support for * and _

I have tried adding to Typing Pairs.tmPreferences
but it didn't work...any idea why?

            <array>
                <string>`</string>
                <string>`</string>
            </array>
            <array>
                <string>_</string>
                <string>_</string>
            </array>
            <array>
                <string>*</string>
                <string>*</string>
            </array>

try/do indenting is incorrect in sublimetext when rescue is present

like so:

        try do
            assert !is_integer([1,2,3,4,5])
        rescue
        RuntimeError -> "rescued"
    end

looks like it's because of that -> after RuntimeError, when that is not present the indenting works fine ie. Edit->Line->Reindent

it's probably related to fn () -> ... end indenting? because the rescue keyword need not be present and it still happens

EDIT: actually, it happens when rescue exists and -> doesn't, but not when rescue doesn't and -> does
EDIT2: I edited the title

Consider escaping ^

I got this issue microsoft/vscode-textmate#37 that this grammar does not tokenize in certain cases. e.g.
nonspecial_token 123 :foo "bar"

The root cause appears to be IMHO an issue with a certain rule:

<dict>
	<key>match</key>
	<string>(\|\|\||&amp;&amp;&amp;|^^^|&lt;&lt;&lt;|&gt;&gt;&gt;|~~~)</string>
	<key>name</key>
	<string>keyword.operator.bitwise.elixir</string>
</dict>

IMHO ^ should be escaped i.e.

<string>(\|\|\||&amp;&amp;&amp;|\^\^\^|&lt;&lt;&lt;|&gt;&gt;&gt;|~~~)</string>

File Icons

The elixir file icons for the file drawer are looking pretty plain. Ruby has some sweet ones but I can't find anything in the ruby bundle that specifies these icons. Do you happen to know how to change these? I'd be willing to put something together to spiff it up a bit and contribute it back.

Thanks!

Format file keybinding conflicts with default

Hi, it looks like the new update that includes a keybinding for the format file command conflicts with the default "Slurp Find String" keybinding.

Slurp Find String

Copies the current selection or word into the “find” field of the find panel.

I think it might make sense to use another keybinding for your command, since it was very surprising when this happened, and it was tough to find out which package was causing it.

For others that want to override it, just add the following to your User keymap:

{
  "keys": ["super+e"],
  "command": "slurp_find_string"
}

Auto-formatting within a monorepo

I work on a couple projects with multiple discrete Elixir apps in top-level directories in a single git repo. These apps are deployed independently and there are other kinds of apps as well (e.g., JS) so an umbrella project isn't appropriate.

Usually I will open the top-level directory in Sublime so I can easily work and search across apps, however the current mix format integration breaks in this case as there is no mix.exs or .formatter.exs at this location.

So: it would be great if the path to the file passed to mix format was recursively descended until a mix.exs was found. I'm happy to put together a PR for this functionality if that solution is considered appropriate.

Thanks!

[Sublime Text 3] Arrows break indentation

I have this .exs file

defmodule Bob do
  import String
  def hey(input) do
    cond do
      "" == trim(input) -> 
        "Fine. Be that way!"
      ends_with?(input, "?") -> 
        "Sure."
      input == upcase(input) && input != downcase(input) -> 
        "Whoa, chill out!"
      true ->  
        "Whatever."
    end
  end
end

And in my keybindings I have

{"keys": ["ctrl+alt+/"], "command": "reindent", "args": {"single_line": false}},

But when I reident the file I get

defmodule Bob do
  import String
  def hey(input) do
    cond do
      "" == trim(input) ->
        "Fine. Be that way!"
        ends_with?(input, "?") ->
          "Sure."
          input == upcase(input) && input != downcase(input) ->
            "Whoa, chill out!"
            true ->
              "Whatever."
            end
          end
        end

This happens when the arrow -> is at the end of the line. If the statement is in the same line then the code formatting works fine.

defmodule Bob do
  import String
  def hey(input) do
    cond do
      "" == trim(input) -> "Fine. Be that way!"
      ends_with?(input, "?") -> "Sure."
      input == upcase(input) && input != downcase(input) -> "Whoa, chill out!"
      true ->  "Whatever."
    end
  end
end

And here is an example what happens with a longer file.

defmodule BinarySearch do
  @spec search(tuple, integer) :: {:ok, integer} | :not_found
  def search(numbers, key) do
    high = tuple_size(numbers) - 1
    _search(numbers, key, 0, high)
  end

  defp _search(numbers, key, low, high) do
    midpoint = low + div((high - low), 2)
    cond do
      low > high ->
        :not_found
        elem(numbers, midpoint) == key ->
          {:ok, midpoint}
          elem(numbers, midpoint) > key ->
            _search(numbers, key, low, midpoint - 1)
            elem(numbers, midpoint) < key ->
              _search(numbers, key, midpoint + 1, high)
            end
          end
        end

No parameter highlighting

Parameter highlighting was removed in 77e37ce for false positives, but no adequate replacement has been introduced.

I have witnessed a number of users pinned to 026c95e for this reason.

What is the "~/.config/sublime-text-2/Packages" path for windows?

cd ~/.config/sublime-text-2/Packages # If you are on Linux
cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages # If you are on Mac
cd xxx # if you are on Windows

On my machine:
C:\Users\Charles\AppData\Roaming\Sublime Text 3\Packages

Please confirm if this is the correct equivalent for windows, and kindly update the read-me to reflect this.

some errors:

C:>cd tools

C:\Tools>git clone git://github.com/elixir-lang/elixir-tmbundle Elixir
Cloning into 'Elixir'...
remote: Counting objects: 572, done.
Receiving objects: 73% (418/572), 36.00 KiB | 50.00 KiB/s 572
Receiving objects: 100% (572/572), 108.85 KiB | 50.00 KiB/s, done.
Resolving deltas: 100% (271/271), done.
Checking connectivity... done.
error: Invalid path 'Preferences/Symbol List: Module.tmPreferences'
error: Invalid path 'Preferences/Symbol List: Private Function.tmPreferences'
error: Invalid path 'Preferences/Symbol List: Public Function.tmPreferences'

C:\Tools>

Thanks!

Create a stable release or tag

Since the master branch is always evolving, it would be nice to have a stable release to point to for package managers.

Maybe it is just as simple as adding a tag?

`@spec import()` considers import as `keyword.control.elixir`

Given this code:

  @spec import(Plug.Conn.t(), map()) :: Plug.Conn.t()
  def import(conn, attrs) do
    # implementation here
  end

The syntax highlighter treats the function name in @spec import as an import keyword.

image

Expects @spec import to be treated as a part of the function spec. As in the screenshot above, the text should be in white rather than red.

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.