autocmd BufNewFile,BufRead *.nim setlocal tabstop=2 shiftwidth=2 softtabstop=2
This should work (after restarting Vim / re-editing an existing file via :e!) fine, but it mixes filetype detection with filetype settings. Vim has an intermediate abstraction called filetype, which you should use. With it, you map file globs like *.nim to a filetype nim, and then define settings either via an :autocmd FileType, or a filetype plugin in ~/.vim/ftplugin/nim.vim (for the latter, you need :filetype plugin on in your ~/.vimrc).
Steps
So, create a filetype detection in ~/.vim/ftdetect/nim.vim:
autocmd BufRead,BufNewFile *.nim setfiletype nim
Then, create a filetype plugin in ~/.vim/ftplugin/nim.vim:
setlocal tabstop=2 shiftwidth=2 softtabstop=2
You can check that these are loaded correctly via the :scriptnames output. After a restart of Vim, this should work, and you can add additional settings to the latter file. If your filetype is derived from another, you can also add :runtime! ftplugin/javascript.vim (for example) in there to get those settings, too.
echo setlocal tabstop=2 shiftwidth=2 softtabstop=2 >>~/.vim/ftplugin/nim.vim:help filetype-plugin. If your tab does nothing it is probable that you had something mapped to it - you could try:imap <tab>.