Sublime Text 3 Doesn't Recognize %i in ruby - ruby

I'm using the latest build of Sublime Text 3. When typing %i[foo bar] Sublime does not seem to recognize this and I don't get the proper highlighting.
Has anyone else experienced this? If so, is there a way I can fix this on my end or is this something that Sublime HQ would have to fix?

The %i[foo bar] # [:foo :bar] literal notation for a symbol array was only implemented in Ruby 2.0, while the Ruby language definition that ships with ST3 is mostly focused on 1.9 and earlier. I searched around a bit, but unfortunately I couldn't find any .tmLanguage files that are updated for 2.0, let alone include this literal notation, so I can't point you to a ready-made solution. But, I do have a few suggestions.
First, head over to the unofficial Sublime Text Issues tracker and post a bug report. We're not sure how much attention is paid to this list by the developer, but it at least broadens the issue's visibility and may prompt someone to post a fix. You can also reply to this thread on the Sublime Text forum and perhaps reference your issue.
The second option, if you have good regex-fu, is to hack the Ruby.tmLanguage file and add support yourself. I was going to post directions on how to do it, but then I tried it myself and it seemed to work, so feel free to use my work:
Go to Preferences -> Browse Packages to open up the Packages folder in your system's file explorer.
Create a folder called Ruby2.
Copy the contents of this gist into a new file, and save it in your Ruby2 directory as Ruby2.tmLanguage.
Restart Sublime, switch to your problematic code, and select View -> Syntax -> Ruby2. Both lines should now be highlighted the same way. Here's a before and after screenshot using the Neon Color Scheme:
I hope this helps. I'm not a Rubyist, so if I made any blatant errors please let me know.
From my (brief) research there definitely seems to be a need for an updated version of Ruby.tmLanguage for all the new features in 2.0, so hopefully any issues you post will prompt someone to start/publish a project. I've already done something similar for Python, but my Ruby skillz just aren't there for this project :)
Good luck!

Related

Auto complete in Sublime Text giving bizarre suggestions?

I'm sure there's a sensible explanation for this, but I get weird auto complete suggestions in sublime text 3 when coding in ruby or a ruby section in a markdown. Examples - I was hoping it would suggestion the .capitalize method, but instead:
In .md file:
In .rb file:
What I've tried
I looked in my autocomplete preferences, but I don't see anything out of place:
// Enable auto complete to be triggered automatically when typing.
"auto_complete": true,
Question
Why the autocomplete is making bizarre suggestions?
The auto_complete feature of sublime text 3 just scans the files inside of the folder structures and provides those "words" as autocomplete. What you are looking for is called CodeIntel or intelli-sense. Unfortunately those features are usually only available on full blown IDEs.
Sublime has some plugins which are a bit old but should still work:
https://packagecontrol.io/packages/Ruby%20Completions (last update 6 years ago)
https://packagecontrol.io/packages/SublimeCodeIntel (last update 4 years ago)
As an alternative you could use LSP but this requires that you have specific language servers installed:
https://packagecontrol.io/packages/LSP (recent updates)

Colour coding comments in RStudio

I am a very visual person and would like a distinction between #a command I commented out and a ##message for myself or co-worker on the file. I had a look around if RStudio supports different kinds of comments but it doesn't seem like it. Does anyone know a way around this?
Thanks!
You can use
#'* some colorfull comment *
to comment in color.
-R version 3.6.3
-RStudio ‘1.2.5033 "Orange Blossom"
As noted, this isn't an R question but an RStudio question (I've edited as such). RStudio doesn't currently have user-modifiable themes, just the built-in ones. That is apparently an in-development feature.
In the meantime, apparently you can hack away at the .css file that defines a theme to perhaps add what you're after - https://support.rstudio.com/hc/en-us/community/posts/200644098-appearance-Editor-theme
Otherwise, you could use a different editor that allows you to specify your desired syntax highlighting.
#'[Red]
#'#Purple
#'*Green*

Better autocomplete in VIM

All,
I have been working with vim for some time now, and love everything about it - there is only one thing I really miss from IDEs like RubyMine, and that is advanced autocompletion.
For reference, here is my standard VIM setup: https://github.com/wrwright/.vim
I have tried ctags with omnicomplete + supertab, and the one major element I miss is the ability to bring up a context sensitive list of attributes/constants/methods. For example, as I learn RubyMotion, I'd love to have some help remembering iOS SDK constants/attributes/methods, but my VIM autocomplete stops with suggesting class names..or if it does suggest methods/attributes, it lists a ton of methods/attributes that don't even apply to the class I'm working with.
I'd like to (simple example) be able to type UIColor.bl and have it autocomplete with UIColor.blueColor (or suggest if there are multiple options that start with "bl" that are properties of UIColor.
RubyMine does this very well, and if I can get VIM to be similarly smart with autocomplete it would be heavenly (and a great boon while learning RubyMotion/iOS Development.
I have also tried SnipMate (and even a RubyMotion tailored variation at https://github.com/rcyrus/snipmate-snippets-rubymotion), but that doesn't seem to offer the features I'm looking for either.
Relatively satisfied with stock Vim's omnicomplete + vim-ruby and vim-rails having completion abilities on par with NetBeans but with all the bells&whistles of Vim and much lower resource requirements, of course.
From my .vimrc concerning completion options :
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
One thing that I have had a bit of luck with Rubymotion is YouCompleteMe and enabling tag Support. you will need a lot of ram(YCM uses ~2GB when indexing a large tag file) because the tags that rubymotion uses are about 40k tags.
The downside is that the rubymotion people don't seem to want to review pull requests and provide any feedback so I am not sure if they will add the needed things to the rake task that creates the tag files for ycm to work correctly out of the box.
To get it to work you need to set the tags files correct
set tags=./tags;,tags;
and then you need to setup ycm to complete off tags.
let g:ycm_collect_identifiers_from_tags_files = 1
you need to make the ctags file compatible with ycm as well. This pull request does that. You need to add a language field to the ctags creation and then change bridgesupport to ruby.
pull request for that
after that you need to run rake ctags in the root of your project.
If you don't want to modify the project.rb file you could probably create your own rake task that does pretty much the same thing.
Yes, Vim is an awesome... text editor.
As such, it can't be expected to match any IDE's "code awareness". Furthermore, it completely relies on the community for providing more than default support for a given language. If google or the rubymotion site didn't help you to find a serious "autocompletion" solution I doubt you'll find it here.
The process explained in the blog post below sounds ok, if not very precise on the vim configuration front.
http://rayhightower.com/blog/2013/02/12/automatic-ctags-with-rubymotion-and-vim/

How to turn on syntax highlighting in etherpad

There are many free etherpad implementations since it went open source. Does etherpad support syntax highlighting or is some kind of add-on available?
I tried
http://typewith.me/
http://sync.in/
http://www.piratenpad.de/
You can install a plugin in Etherpad called "Syntax highlighting".
To install the plugin simple visit /admin/plugins on your Etherpad deployment and then search for "syntax" and click Install.
For details on the plugin see https://npmjs.org/package/ep_syntaxhighlighting
UPDATE: Syntax highlighting is available as a plugin in the current Etherpad -- see John's answer below.
The original etherpad creators were working on highlighting, but complex sync-problems made them abandon that feature -- as documented in a .txt file in the source code.
Many etherpad sites run on a mostly standard etherpad.org release. If highlighting would get added, you'd probably see it quickly adopted at sketchpad.cc. Perhaps watch them and wait? Or if you really want highlighting, a good first attempt/experiment would be the read-only view. Example: http://sketchpad.cc/sp/pad/view/BACfNDybki/latest
Try to use some existing highlighting javascript library to highlight the text inside DIV#padcontent or perhaps $('DIV#padcontent')[0].textContent
The complexity is getting the highlighted text formatting back into the DB. For this you might need to use operational transformations (which is the foundations of etherpad and as of recently also used in the Google Docs word processor). A tutorial: http://www.codecommit.com/blog/java/understanding-and-applying-operational-transformation
The etherpad plugin ep_codepad provides syntax highlighting - based on highlight.js - for etherpad.
https://www.npmjs.com/package/ep_codepad

What are the most important IDE features missing in Vim?

I have been programming almost exclusively in Vim since 1/1/2001, and I feel that Vim fulfulls all my needs as an editor/IDE, but I can't help but wonder if perhaps there have been some new killer features developed for other IDEs in the last decade that would allow me to be more productive than I can be using Vim. So I ask: What are the most important IDE features missing in Vim??
Integrated debugging with all the fanciness that Visual Studio/Eclipse provide (thread debugging, etc etc)
Autocomplete with inline documentation support for methods/properties
Build and run from 'within' the editor application
I miss the excellent refactoring support and code tips from tools such as Resharper. Regexs are powerful for code modification, but understanding the code as Resharper does is just a tad better IMO.
Fortunately I can get both Resharper and Vim in Visual Studio so I am happy.
The real question is: what do VIM have that IDEs are missing.
I find that refactoring would be a real nice thing to have. Changing a java package name in vim with lots of source files can be pretty cumbersome.
Originally the refactoring was the killer feature that made us switch from Emacs. I have now used Eclipse extensively for Java for the last 6 years, and I expect any replacement to have:
Refactoring: Rename variables, functions, change method signatures (including all calls to it).
Debugging: "You are here" "Your current variables are" plus stuff like "go to the defined class for this object" or "go to the actual type for this object". I belive the latter requires quite a bit of integration between debugger and editor.
Code replacement while debugging. Change code, press Ctrl-S and the code in your debugging session is updated with what you just changed. A killer feature for big programs.
Navigation: Simple navigation of class hierarchy (please show me all implementations of this method in this interface and similar).
Javadoc integration - Eclipse can show javadoc just by hovering the mouse over an identifier.
Plus some more :)
Edit: I occasionally miss the Emacs functionality inside Eclipse, but the Eclipse editor has become stronger so it is not so bad anymore. In this regard the Save Action allowing a Format at every save was a killer. This ensures that changes show up properly in the source repository.
Search in files: In most editors, there is a separate window doing the search in files, and simultaneously editing can continue on the main window. The search results are updated as and when they are found. Also the current results can be viewed by clicking on it, even when the searching is ongoing, without waiting for the entire search to be completed.(whereas in cim one has to wait till vimgrep/ctags has finished to view the results)
This is particularly useful for search in large number of files.
So basically something like a search in background and simultaneously show results which can be clicked on to view them simultaneously.
(something like Microsoft Visual Studio 6.0 does)
The things I missed were code completion and debugging. That's why I started using eclim http://eclim.sourceforge.net/index.html so I could use vim for what it does best and eclipse when I actually need it. Try it out - it's a fantastic combination.
It's like the old question "What's worn under a kilt?"
Answer: "Nothing. Everything's in perfect working order!".
But seriously, I'd like to see a more intuitive (easy to use) help system added to Vim.
There is nothing missing in Vim that an IDE has. The only thing we could argue about is; Vim needs to be customized and IDE comes out of the box.
Let me comment the other answeres and how to solve such "needs".
build
As mentioned, use :make and learn how to customize it.
refactoring
Use the very well known ropevim (for Python), it makes a great reafactoring tool. You won't need more than that. There are many others, search for your language.
Autocompletion
I use this snippet together with mapping to TAB (I think supertab plugin does that)
" python stuff
python << EOF
import os
import sys
import vim
for p in sys.path:
if os.path.isdir(p):
vim.command(r"set path+=%s" % (p.replace(" ", r"\ ")))
EOF
" tags for python libs
set tags+=~/.vim/tags/python.ctags
autocmd FileType python,mako set omnifunc=pythoncomplete#Complete
autocmd FileType html,mako set omnifunc=htmlcomplete#Complete
autocmd FileType html,mako set omnifunc=htmlcomplete#CompleteTags
autocmd FileType mako set filetype=mako.html.js
Help system
in Vim is perfect, you just have to learn it's system. It has it's own conventions how are things organized.
Debugging
I don't know for other languages than Python, but running pdb and !python % does it's job.

Resources