Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Adds syntax highlighting and indent support for MoonScript in vim.
### Using [Vundle](https://github.com/gmarik/vundle)

1. Add the following to your `.vimrc` where other bundles are located:

Bundle 'leafo/moonscript-vim'

2. Run from command line:
Expand All @@ -30,7 +30,13 @@ Adds syntax highlighting and indent support for MoonScript in vim.
indent/moon.vim
ftdetect/moon.vim

## Support CoffeeTags on Tagbar

CoffeeTags works perfectly on MoonScript.
The CoffeeTags vim plugin has been mreged into this moonscript-vim.
You can install and enable CoffeeTags in Vim according to [this readme](https://github.com/lukaszkorecki/coffeetags)

## Thanks

Special thanks to the <https://github.com/kchmck/vim-coffee-script> project. I
copied the syntax and indent code as a starting point.
copied the syntax and indent code as a starting point.
88 changes: 88 additions & 0 deletions ftplugin/moon.vim
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,91 @@ setlocal comments=:--
setlocal commentstring=--\ %s

let b:undo_ftplugin = "setlocal commentstring< comments< formatoptions<"

if !has("ruby")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this going to show a warning every time someone runs vim without ruby regardless of whether they have coffeetags installed or not?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leafo : I assume it is. I haven't got a vim without ruby integration to check. But I thinks that if statment is to make sure the client machine has got ruby env, since CoffeeTags is actually a ruby script.
Do you think we shall remove echohl WarningMsg to make sure the plugin won't be annoying on vim client without ruby? Please let me know. I can do that.

echohl WarningMsg
echo "Coffee auto tag requires Vim to be compiled with Ruby support"
echohl none
finish
endif

let s:CoffeeAutoTagFile="./tags"
let s:CoffeeAutoTagIncludeVars=0
let s:CoffeeAutoTagTagRelative=1

if !exists("g:CoffeeAutoTagDisabled")
let g:CoffeeAutoTagDisabled = 0
endif

if exists("g:CoffeeAutoTagFile")
let s:CoffeeAutoTagFile = g:CoffeeAutoTagFile
endif

if exists("g:CoffeeAutoTagIncludeVars")
let s:CoffeeAutoTagIncludeVars = g:CoffeeAutoTagIncludeVars
endif

if exists("g:CoffeeAutoTagTagRelative")
let s:CoffeeAutoTagTagRelative = g:CoffeeAutoTagTagRelative
endif

if s:CoffeeAutoTagIncludeVars
let s:raw_args="--include-vars"
else
let s:raw_args=""
endif

let g:tagbar_type_moon = {
\ 'ctagsbin' : 'coffeetags',
\ 'ctagsargs' : s:raw_args,
\ 'kinds' : [
\ 'f:functions',
\ 'c:classes',
\ 'o:object',
\ 'v:variables',
\ 'p:prototypes',
\ 'b:blocks'
\ ],
\ 'sro' : ".",
\ 'kind2scope' : {
\ 'f' : 'object',
\ 'o' : 'object',
\ }
\ }






function! CoffeeAutoTag()
if g:CoffeeAutoTagDisabled
finish
endif

let cmd = 'coffeetags --append -f ' . s:CoffeeAutoTagFile . ' '

if s:CoffeeAutoTagIncludeVars
let cmd .= '--include-vars '
endif

if s:CoffeeAutoTagTagRelative
let cmd .= '--tag-relative '
endif

let cmd .= expand("%:p")

let output = system(cmd)

if exists(":TlistUpdate")
TlistUpdate
endif
endfunction

augroup CoffeeAutoTag
au!
autocmd BufWritePost,FileWritePost *.moon call CoffeeAutoTag()
augroup END