Code Monkey home page Code Monkey logo

sublime-crystal's People

Contributors

10xl avatar aljelly avatar asterite avatar bcardiff avatar blacksmoke16 avatar chyzwar avatar epitron avatar faultyserver avatar faustinoaq avatar fgimian avatar greenbigfrog avatar hovsater avatar jacobub avatar luislavena avatar lukateras avatar n-pn avatar oprypin avatar ozra avatar queckezz avatar straight-shoota avatar vladfaust avatar waj 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sublime-crystal's Issues

Stop removing all spaces after save file

Hello,

When i save a file .cr
I tabulate my code with spaces, all of then are deleted.

var1   = "var1"
myvar2 = "myvar2"

=>

var1 = "var1"
myvar2 = "myvar2"

How to delete this action and move it to a function key.
Saving my code should not transforme my code silently, without permission !

Support for ECR

Currently, the .ecr files are being shown as Plain Text files. I couldn't find a way to syntax highlight there. I think it should be a part of official crystal sublime package.

crystal tool xyz; like atom?

crystal lang examples in atom

sublime is always a bit behind atom in terms of user friendly tooling but do you have plans to enable these tooling options for sublime? (if this does not require too much hacking)

and there is a crystal tool hierarchy json option which could enable sensitive auto completion some day maybe?

brackets highlighting

  def initialize(states : State(S, A))
    @states << states
  end

have an issue at State(>>>(<<<S,A))

using sublime 3 and Monokai, Mariana or other themes (just plain, no special config afaik)

thanks for auto format in sublime, works great!

Join to Crystal Tools organization

Hi @matiasgarciaisaia some Crystal community members have the idea of a Crystal Tools organization inspired by Julia Editor Support organization.

We are adding repositories for sublime, emacs, vim, vscode, atom, etc. All in one place well documented easy to follow, collaborate and maintain. :-)

If you accept the proposal of move your repo to Crystal Tools organization, leave a message in Gitter room first.

The editor support for a language is very important. Thanks you for this awesome sublime plugin. ๐Ÿ’“

cmd popup on Sublime Text WIndows 10 + WSL

ezgif-1-e9165bf71d

This issue was discovered by @girng

Solution proposed by @oprypin :

  1. We should replace this line:

with subprocess.Popen([settings.get("crystal_cmd"), "tool", "format", "-", "--format", "json"], stdin = subprocess.PIPE, stdout = subprocess.PIPE) as proc:

  1. by something like this:
            if operating_system == 'win':
                # Prevent flashing windows if used from a GUI application
                startupinfo = subprocess.STARTUPINFO()
                startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
                rc = subprocess.call(proc, stdout = pipe, stderr = pipe,
                                     startupinfo = startupinfo)

https://github.com/coin-or/pulp/blob/bac6d9d2214ba773d638d2de5149940cfd711359/src/pulp/solvers.py#L378-L382

No `support.function.builtin` or format string scopes?

I was converting some Ruby code to Crystal (for Geode) and I noticed that certain functions, methods, and format strings weren't being highlighted, which I then noticed was a side effect of there not being any special scopes for them.

Ruby:
image
image
image

Crystal:
image
image
image

Removes lines on save

I don't know if I am the only one experiencing this, but when I press save the plugin removes all the empty lines in my program..
The indentation is useful. But I want some whitespace between some of my code blocks.
Does anyone have a solution for this?

Syntax highlighting does not work correctly for generic types in function parameters

Describe the bug
Syntax highlighting starts doing weird things when there are generic types in a parameter list.

To Reproduce
Paste this snippet to sublime code buffer with Crystal syntax selected:

def func(a : String, b : Array(String), c : String)
  p a
end

Expected behavior
I expect the parameter c to be the same color as a and b, and the parens in Array(String) to both be same color.

Screenshots
image

Add `entity.name` scopes to property definitions

See https://www.sublimetext.com/docs/3/scope_naming.html#entity. entity scopes are used to populate the symbol list and enable the "Jump to Definition" behavior.

An example:

class Foo
  property bar : String

  def baz; end
end


foo = Foo.new
foo.baz
foo.bar

Putting the cursor in the word baz in foo.baz and then pressing alt+cmnd+down will jump to the definition of baz on Foo (or if there are multiple definitions of it, it brings up a palette to jump between definitions).

However, doing the same on bar does not jump to the definition because there is no actual function definition in the source code.

I think that jumping to property definitions should be supported, and they use a scope like entity.name.property instead of entity.name.function to be semantically accurate.

I know there's some effort to do this with Scry, but it can also just be done with the symbol scoping so why not at least start there. It's not a perfect solution and doesn't address issues with jumping to things defined by macros, but it's a good step towards that and would feel more consistent overall.

`:!` and `:!=` are considered operators rather than Symbols

:! and :!= are both considered Symbols in Crystal:

puts typeof(:!)  #=> Symbol
puts typeof(:!=) #=> Symbol

However, the sublime syntax highlighter scopes them as operators instead:

screen shot 2018-02-10 at 5 54 58 pm

FWIW, the most recent Ruby highlighter (built into Sublime) also has this same problem.

Octal literals have no scope applied to them

screen shot 2018-04-01 at 3 12 39 pm

Unlike Ruby, which just uses a prefix 0 to denote octal literals, Crystal uses 0o (which I really like). However, this difference is not handled in the current syntax highlighter, meaning octal literals have no scope applied to them, and thus can't be highlighted.

To match other numeric literals, octal literals should get the scope constant.numeric.crystal.

Jump to method definition

crystal browser lets you navigate to methods by clicking on them. It would be amazing if that functionality existed in Sublime.

Formatting errors aren't properly handled when `auto_format` is enabled

Given this file:

class Foo <

This is what I've got in the console:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 818, in run_
    return self.run(edit)
  File "crystal_format in /home/faust/.config/sublime-text-3/Installed Packages/sublime-crystal.sublime-package", line 52, in run
  File "./python3.3/json/__init__.py", line 316, in loads
  File "./python3.3/json/decoder.py", line 351, in decode
  File "./python3.3/json/decoder.py", line 369, in raw_decode
ValueError: No JSON object could be decoded
Traceback (most recent call last):
  File "./python3.3/json/decoder.py", line 367, in raw_decode
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 818, in run_
    return self.run(edit)

... and so on

Basic formatting works, but if there is an error in the code, it's not handled properly - no message is given except these errors in the console.

code randomly gets cut off on save

this started happening after the patch to fix the popup cmd on save. basically, sometimes when you save your entire code gets cut off in half. i can't reproduce this consistently, it happens out of pure randomness (about 3 times per day). so am not sure how to debug / test it.

but i figured i'd make a issue for the record incase anyone else experiences this.

happens on Windows WSL 10, 64-bit. latest sublime text 3.
edit: iirc, it happened more if the file was > 500 lines of code. it's been happening for the past several months, I just never really made an issue about it cause i just did ctrl+z and got my text back. however, i can't take it anymore

Support for flat rescue/ensure/else block in do/end block

This formatting is correct:

require "uuid"

module Foo
  proc = ->(x : String) do
    puts UUID.new(x)
  rescue ArgumentError
    puts "Invalid UUID!"
  end

  proc.call("abc")
end

While the plugin does not think so:

require "uuid"

module Foo
  proc = ->(x : String) do
    puts UUID.new(x)
rescue ArgumentError
  puts "Invalid UUID!"
  end

  proc.call("abc")
end

See crystal-lang/crystal#5114

Highlight `?` in method definitions consistently

When implementing a nilable accessor method ([]?), the trailing ? does not get highlighted along with the brackets. However, when appending a ? to normal query methods, the ? is highlighted with the name:

screen shot 2017-10-30 at 9 20 21 am

For consistency, it'd be nice to have the full []? be highlighted together :)

Autocompletion?

Is it possible to add auto completion like GoSublime since it is a compiled language?
Or do we need a daemon like gocode? And something for formatting would also be good like gofmt.

Crystal 0.27.1 does not work

Description

This problem causes all features of the plugin to be unavailable.
This problem occurs in 0.27.1 version and higher.

Version Info

Sublime:
  Version 3.1.1, Build 3176
---
Crystal:
  Crystal 0.27.1 (2019-02-01)
  LLVM: 6.0.1
  Default target: x86_64-apple-macosx

Console Log

Traceback (most recent call last):
  File "./python3.3/json/decoder.py", line 367, in raw_decode
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Applications/Sublime.app/Contents/MacOS/sublime_plugin.py", line 1072, in run_
    return self.run(edit)
  File "/Users/User/Library/Application Support/Sublime Text 3/Installed Packages/Crystal.sublime-package/crystal_format.py", line 62, in run
  File "./python3.3/json/__init__.py", line 316, in loads
  File "./python3.3/json/decoder.py", line 351, in decode
  File "./python3.3/json/decoder.py", line 369, in raw_decode
ValueError: No JSON object could be decoded

Screenshot

Auto format doesn't respect sublime indentation settings

If my indentation is tabs or different form 2 spaces saving the file with trailing whitespace will cause it to get converted to two spaces.

Issue on ST3 with the following config:

{
	"color_scheme": "Packages/Colorsublime - Themes/Flatland_Black.tmTheme",
	"detect_indentation": true,
	"draw_white_space": "all",
	"ensure_newline_at_eof_on_save": true,
	"font_size": 10,
	"hot_exit": false,
	"ignored_packages":
	[
		"Emmet"
	],
	"remember_open_files": false,
	"theme": "Adaptive.sublime-theme",
	"trim_trailing_white_space_on_save": true,
	"vintage_start_in_command_mode": true,
	"vintage_use_clipboard": true
}

Avoid always applying `primary.control` scope to `type`

screen shot 2018-04-05 at 7 32 21 pm

I often end up using the word type in my code for various things. But, it almost always ends up getting highlighted incorrectly for the context in which it's being used.

afaik, the only place where type is a valid keyword is inside of a lib definition, or in macros (and even then, it's @type), so I think the highlighting for the word should be restricted to that context.

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.