Emacs code validation - validation

I am having a hard time finding code validation solutions for emacs, something/s to check that my javascript / css / ruby etc is valid code, where is all this stuff at?

I assume that you're referring to basic syntactic correctness, in which case you should look at flymake, which is included with Emacs, and which runs a validation program in the background, parses its output, and marks up the buffer with errors and warnings.
And, to get you started, here is a small module for using flymake with Ruby, and a similar one for flymake with javascript using jslint as the validation program.

that's why you test ruby mate. Even js has test suites now too.
As for the css, you can always use things like autopair, or textmate.el to ensure you close your hashes, and maybe even add the semi-colon to your css as well (I should see if that exists actually, thanks).

for js - there is an emacs wiki page but it seems to be quite out of date: http://emacswiki.org/emacs/FlymakeJavaScript
Here's what I did instead. First I installed jslint on node.js
sudo apt-get install nodejs npm
npm install jslint
ln -s ~/.npm/jslint/0.1.8/package/bin/jslint.js ~/.local/bin/
For emacs integration I then tried installing the package flymake-jslint in emacs (I'm using emacs24 with included package manager) and pointing it at jslint but it just wouldn't work.
I then followed the instructions here http://www.thoughtspark.org/node/59 - I created a bash wrapper script for jslint.js and pointed the .el snippet at it and it works fine.

Related

Cannot install RuboCop on RubyMine

I'm opening ruby file via RubyMine. IDE suggests installing RuboCop. I accept it, but after a few seconds it shows:
Following gems were not installed: rubocop (1.0.0): Cancelled
Documentation says its problem with interpreter path. Problem is its already set. Even when i try to add it like documentation says, it won't let me, because its already set.
Any ideas what i can do? I have been using VisualStudio Code without issues before it, but Ruby support is pretty poor, i had to use terminal, while for example python has full support and you can just run program with one button.

Installing RSense for VIM

I am trying to install RSense for vim in fedora. I read this manual. I downloaded the tar ball of rsense and extracted it. Then I copied it to the root/opt directory as given on that page. Then I made a directory vim/plugin in the opt directory and copied the rsense.vim in the plugin directory. But when I write :RSenseVersion in the vim editor,I get a message that the command is not recognized.What have I missed ?
Till now I have not installed vim-ruby plugin as staged on the documentation page. What is this plugin meant for ? Can't RSense alone solve my purpose of writing a neat ruby code with auto-completion,code hinting ?
No, you didn't read the manual.
Once all the dependancies are dealt with you must put the plugin in ~/.vim/plugin.
As for the differences between vim-ruby and RSense, I don't do Ruby so I don't know for sure. Looking quickly at their doc, it looks like they are very different in scope and have slightly overlapping features. I'd install both: vim-ruby for all the low-level Vim tuning and RSense for its supposed code intelligence.
But I have a feeling none of them will help you write "neat" ruby code. Only your programing/ruby skills will.

Ruby support in vim

If I want to work with Ruby in Vim, how can I add Ruby support to it?
First of all, you would need a Vim version that is compiled with Ruby support enabled. You achieve this with:
./configure <the rest of your options> --enable-rubyinterp
on a Linux system, for example.
The next steps would be installing the plugins of your choice, you probably want NERDTree, snipMate, vim-ruby-debugger....
There are a lot of plugins to make your life easier, but there is always the option to run arbitrary shell commands from within Vim, no extra plugin needed:
!ruby /path/to/script.rb
This will execute script.rb and print the shell output directly in Vim itself.
I would visit https://github.com/ and put "ruby vim" into search box. You should find plenty interesting add-ons for vim this way.

How can I run SASS without installing?

I wanted to use SASS on our company's web app but I can't install any programs on production machines. Everything I searched about SASS required you to run an installation program like gem and also required HAML.
I was hoping to find just a script that processes scss files without needing to install anything else.
Well... if you have Ruby available, you could checkout the Git repository of Sass (https://github.com/nex3/sass). Do so by either typing git clone https://github.com/nex3/sass.git or just downloading it.
Then you could use the interactive Ruby console by typing irb. Try to require 'sass/lib/sass' (this one here) and run Sass.compile_file 'my_styles.css'.
Otherwise... why are you trying to do that? You can also install sass locally, run sass --watch on your sass folder and it compiles your scss files automatically into css files - which you can deploy on your production environment.
If you can run java program in your build system, you could use JRuby for compiling sass. See this answer for more details
Here's a solution for using Sass without using the command line or installing dependencies. It works with Windows, OS X, and Linux. It has a graphical interface, and no installer, just unzip and double-click.
http://scout-app.io
You can also use the java library https://github.com/scireum/server-sass which can be embedded into any java based web-app. It will compile sass on the fly and return the resulting css. This is especially useful if the Sass sources change (i.e. for customizing reasons) and an ahead of time compilation is not possible. (Note: I'm the author of the project - and it is also not yet a complete implementation of the Sass standard).
Alternatively, what you could do is:
Install Ruby
Download the Sass Gem
Navigate to download location
Run: gem install sass-3.3.4.gem
Voila! Sass is installed.
Use the online Sass compiler SassMeister. You just have to paste your sass code on the left panel and get the css code on the right.

How do I use ruby-debug inside Emacs?

I know Emacs has some sort of integration with gdb (though I never used it) to jump through files as you debug a program. I'd like to do the same with Ruby programs.
As erenon said, use ruby debug, which provides a library for emacs that lets you use it just as gdb.
Install rdebug by issuing this command on your terminal(the sudo is optional, depending on your system):
<sudo> gem install ruby-debug
You then need to download the ruby-debug-extra file from rubyforge, and install it in the standard way.
sh ./configure
make
make test # optional, but a good idea
sudo make install
This gives you the elisp files for the interaction with rdebug, plus documentation for ruby-debug that can be viewed from within emacs.
AJ
There is another emacs to ruby-debug interface. See https://github.com/rocky/emacs-dbgr/wiki .
More generally, it works with other ruby debuggers and other debuggers in general.
You may want use rdebug.
I am getting "Cannot open load file: gdb-ui" in GNU Emacs 23.1.50.1 (x86_64-apple-darwin10.0.0, NS apple-appkit-1038.11) of 2009-10-31
I was stuck with same problem with gdb-ui, but I found the solution: I downloaded gdb-ui.el from here and put it into ruby-debug-extra/emacs dir... then I've adjusted Makefiles to point to this file before any other rdebug*.el files. After this step you'll get make working. Since I'm using emacs-snapshot and gdb mode is available already in my emacs environment, this issue is only about to build rdebug mode. After this I've installed it with "sudo make install" and it works perfectly :) Don't forget to add (require 'rdebug) to your ~/.emacs or whatever else you use to bootstrap your config.
The chosen strategy can be made to work, although texi2html and texinfo were not enough on my system, but I stopped pursuing this strategy without installing the extra packages.
Here's what I did: download ruby-debug-extra-0.10.4.tar.gz from http://rubyforge.org/frs/?group_id=1900&release_id=28306, untar it, but DON'T do the whole configure/make/blah/blah thing. Instead, I simply copied the 'emacs' directory to ~/.emacs.d/rdebug, and then added to my ~/.emacs.d/init.el file (you can also use your ~/.emacs file):
(add-to-list 'load-path "~/.emacs.d/rdebug")
(autoload 'rdebug "rdebug" "ruby-debug interface" t)
This won't byte-compile it, I didn't care. I prefer this solution because I got really annoyed that the packages forces you to install the docs.

Resources