Archive | Programming RSS feed for this section

Enhancing vim for Scala

6 Apr

You like Scala. You like programming. You like vim. You are happy.

Here’s the 2-line solution to increase your happiness even more:

cd ~/.vim
svn export --force http://lampsvn.epfl.ch/svn-repos/scala/scala-tool-support/trunk/src/vim .

And there you go, nice indent and syntax highlighting support for Scala.

Massive thanks to Nico “@nfmelendez” Meléndez for pointing this excellent package!

Advertisements

A “did you mean” alternative to the NASCAR problem

2 Apr

I’ve been playing with an experimental UI for avoiding the NASCAR problem. The main idea is to be more open in the expected input from the user.

Nowadays we have several popular identities we use in business cards, e-mail signatures, presentation slides, etc. Depending on what I do like the most, and probably depending on the context as well, I may say I’m @luisfarzati. Or lfarzati@gmail.com. Or facebook.com/luisfarzati. Or just find me by luisfarzati: it’s the screen name I use everywhere: LinkedIn, Flickr, GitHub, and so on.

Most of these services have an open API with a public, limited access that allows anyone to know if there’s a person registered under a certain username.

Why don’t we leverage these APIs and let the user input whatever they want to login? If it exists as a valid username out there, we’ll find it and suggest it.

Feel free to try with many combinations. @twittername, facebook.com/name, name@gmail.com, youtube.com/name, WordPress blog URL, Open ID URL, etc.

You can try the concept demo or get the source files on GitHub.

Enhancing vim as an HTML/JS/CSS/PHP editor

11 Jan

I have enough of heavyweight, sometimes cluttered IDEs. I don’t know, maybe I’m getting too old-school or something, but I find myself working faster with plain old vim.

Of course, over time I have been optimizing the editor with the addition of several plugins and customization of its settings.

Here is my current vim setup focused on HTML, JS, CSS and PHP programming:

  1. Install NERDTree
    This gives you a nice tree view of the filesystem.
  2. Install IndentAnything
    Name says it all.
  3. Install JavaScript indentation
    A nice JS indentation for IndentAnything
  4. Install JSLint
    Validates the code for compilation errors as well as styling and informs you of this, almost in real-time!

You might want to throw in some visual enhancements as well. The railscasts color scheme along with the Monaco font are a pretty good combination.

Finally, my .vimrc file:

"Keyboard mappings
map :NERDTreeToggle

"FileType support
set filetype=on
filetype plugin on
filetype indent on

"Color scheme and font
autocmd FileType javascript,html,css,php colorscheme railscasts
autocmd FileType javascript,html,css,php set gfn=Monaco\ 10

"Hightlight current line
autocmd FileType javascript,html,css,php autocmd InsertLeave * set nocursorline
autocmd FileType javascript,html,css,php autocmd InsertEnter * set cursorline
autocmd FileType javascript,html,css,php highlight CursorLine ctermbg=40 cterm=NONE

"Indentation
autocmd FileType javascript,html,css,php set ai
autocmd FileType javascript,html,css,php set sw=2
autocmd FileType javascript,html,css,php set ts=2
autocmd FileType javascript,html,css,php set sts=2
autocmd FileType javascript,css,php set textwidth=79

"Enable autocompletion
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS

"Enable line numbers
autocmd FileType javascript,css,php set number

"Enable incremental search
autocmd FileType javascript,html,css,php set incsearch

And that’s it. Please feel free to post your suggestions!

%d bloggers like this: