Code completion for MacRuby/PyObjC/RubyMotion - xcode

One of Xcode's most powerful features is it's Intellisense completion, which brings up a list of potential candidates as you type the name of a Foundation/Cocoa/UIKit API. I am very interested in MacRuby, PyObjC, or the more recent RubyMotion, however without code completion these tools seem like more trouble than they're worth.
Is there any code completion feature (not necessarily Intellisense) for any of the three technologies above, for any text editor (but preferably for Vim or Xcode)? Bonus points for an IDE solution which allows for building and running the application in a single command (like Xcode's Run button).
It's my understanding that Xcode 4 dropped support for MacRuby/PyObjC, so Intellisense is no longer available. Should I install Xcode 3 alongside Xcode 4 for the code completion? How is everyone else doing it (surely you guys use some form of code completion -- I can't believe anyone can remember all the classes in Foundation/Cocoa/UIKit)?

RubyMotion comes with vi ctag support. Run rake ctags to create them.

FWIW, there is a Code completion package for Sublime Text 2, which can also be installed via the package manager of the Sublime text.
And it seems to work rather well for me.

Yes, you can give yourself Vim code completion by running $ rake ctags in the root directory of your RubyMotion app. To take that a step further, use a shell script to generate ctags automatically every time you create a new RubyMotion app. This article shows how to build such a script:
http://rayhightower.com/blog/2013/02/12/automatic-ctags-with-rubymotion-and-vim/

Related

How to spellcheck R comments with RStudio on R source files?

How to conveniently spellcheck R comments with RStudio on R source files?
I am writing a package and I want it to look professional. Thanks to Oxygen, all package's documentation lives in R comments, which by default is excluded from spell checking. So even if spell checking functionality does exist in RStudio, I don't know how to use it.
The spelling package is great for this: https://github.com/ropensci/spelling.
devtools::install_github("ropensci/spelling")
spelling::spell_check_package() # path to package Project
RStudio 1.3 will include this feature; and it is possible to already try it out.
Well this is moot now that Rstudio has spellcheck for spin documents!
So, I write a lot of my lessons and examples for teaching using spin rather than markdown. It just makes for an easier flow. The problem is that there is no spell-check in a spin document, much like your package documentation example.
What I have resorted to is using the terminal then running a command line spellchecker on the document.
I'm on linux so here is my workflow.
save the file I am working let's say example_lesson.R (typos and all)
open the terminal pane of Rstudio and cd to the right folder
make sure the file example_lesson.R is there
run the spell-checker
> aspell check example_lesson.R
Once I'm done with aspell, I go back to the editor window in Rstudio and it updates what I am working on with the spell-checked version. I spin it and I am done.
I've only tested with small examples, but it has worked thus far. Your mileage may vary. Hope that helps.

Swift Scripting Autocomplete

After finding a number of articles that describe using Apple's Swift for scripting purposes, I wanted to try my hand at it. I want to do some simple scripts that perform actions on the file system: moving things around, renaming things, and so on.
My preferred text editor is Sublime, and while there is a package for Swift syntax, you obviously don't get any kind of autocomplete. Alternatively, I could use Xcode, which historically has had awesome autocomplete. From the command-line, I can type open myFile.swift to pop open an Xcode editor window for that file.
However, when I do this there's no autocomplete. I fear that I need to have a whole Xcode project set up with a build target, etc. to get autocomplete going...is this the case?
Does anyone know a simple way to get Swift autocomplete in Xcode (or Sublime) for scripting purposes? Thanks!
You should try using a playground in XCode if you don't need to reference other files. This lets you perform some basic debug as well.
After checking the help command with swift package --help I noticed about the generate-xcodeproj subcommand:
generate-xcodeproj Generates an Xcode project
So, you can generate an Xcode project doing swift package generate-xcodeproj and benefit the awesome autocompletion that Xcode gives you, even using dependencies.
Just generate and open the project file. Resolving new package dependencies will not update the project, so you need to rerun the generate-xcodeproj command on every dependencies change.

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/

mirroring Terminal with gets Ruby

There may be a good gem out there for this, but I've run out of Google.
I'm creating a command line interface with a basic gets each inputed command. I also want to have basic terminal features like hitting the up arrow and having it cycle the history. Are there gems which mimic this or is there a simple way to implement it?
Not to self-promote, but my friend and I wrote a project that is mostly functional with this goal. Check it out here: https://github.com/jamez01/arsh
It's also a packaged gem that you can install.
Some time ago I did a "smart telnet" using "Readline". I even enabled autocompletion.
It has all the cool features like up down arrow, autocompletion, ...
Take a look at it

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