It currently requires [gnome-terminal] and [screen] to run (both are
installed by default with Ubuntu and other gnome-based distros),
though it shouldn't be difficult to edit it to allow other terminal
type programs.
I put the following commands in my [~/.vimrc] to make for nice
keybindings:
noremap <F9> :M2Exit<CR>
noremap <F11> :M2Send<CR><CR>
noremap <F12> :M2Start<CR>
I hope it's useful. Please let me know if you have any problems with
it.
Cheers,
David
P.S. Yes, I know it doesn't work with cygwin--good luck with that.
Thank you!
> noremap <F9> :M2Exit<CR>
> noremap <F11> :M2Send<CR><CR>
> noremap <F12> :M2Start<CR>
It might help, perhaps, if there are maps for calling M2Send from
normal (i.e., command) mode and insert mode. E.g.,
noremap <F11> :M2Send<CR> j "for command mode
inoremap <F11> :M2Send<CR>o "for insert mode
Manoj.
-- begin applescript
on run argv
set folderName to item 1 of argv
set scrName to item 2 of argv
tell application "Terminal"
activate
set cmdToRun to "cd " & quoted form of (folderName as string) & "&&
screen -d -RR -S " & quoted form of (scrName as string) & " M2"
tell application "System Events"
keystroke "n" using {command down}
end tell
do script cmdToRun in first window of application "Terminal"
end tell
end run
-- end applescript
Paste this into the Apple Script Editor, and save it as ~/local/
Applications/VimM2.scpt ('File > Save As > Script').
Now replace the 'M2Start()' in David Cook's original 'Macaulay2.vim'
as below.
function! M2Start() let cwd = getcwd()
let cmd = printf("/usr/bin/osascript ~/local/Applications/
VimM2.scpt %s %s", cwd, b:screens)
let log = system(cmd)
if v:shell_error
call M2Warning(log)
return
endif
endfunction
Manoj.
Manoj wrote:
> In case someone is interested in running M2 from vim in Mac OS X
> Terminal.app, here is an applescript:
Thanks for the original vim script, David, and thanks for the applescript, Manoj.
Two remarks:
1. In the original David Cook Macaulay2.vim in the previous message, it seems that the function M2Warning seems to be moved above the first place where it is used, i.e. before the bunch of tests about the presence of the executables screen, gnome-terminal and M2
2. If the Macaulay2.vim script is intended to be used on a mac in Terminal.app, it the lines checking if gnome-terminal is installed should obviously be removed. I mean these lines:
> elseif !executable('gnome-terminal')
> call M2Warning("Please install 'gnome-terminal' to run vim-M2-plugin")
> sleep 2
> finish
And now a request...
Has anyone made a syntax highlighting file for M2 syntax in vim? I've googled a bit and couldn't find one. It would really be nice to have one.
Baptiste
> 2. If the Macaulay2.vim script is intended to be used on a mac in Terminal.app, it the lines checking if gnome-terminal is installed should obviously be removed. I mean these lines:
>
> > elseif !executable('gnome-terminal')
> > call M2Warning("Please install 'gnome-terminal' to run vim-M2-plugin")
> > sleep 2
> > finish
Yes! I forgot to mention that.
> Has anyone made a syntax highlighting file for M2 syntax in vim? I've googled a bit and couldn't find one. It would really be nice to have one.
I do have a syntax file and a dictionary file (for keyword
completion). I created both by dumping the Dictionary of M2 1.3.1
after startup). I have posted them, along with changes in the rc
file, at http://www.math.purdue.edu/~nkummini/M2/vimM2.html
HTH.
Manoj.
Great! Thanks a lot, this will make the intersection of the set of vim users and the set of M2 users very happy.
If it's not already somewhere that I missed in the documentation, it would be a good idea to mention your syntax and dictionary file for vim users, in the same way that the emacs plugins are mentioned.
Baptiste
> If it's not already somewhere that I missed in the documentation, it would be a good idea to mention
> your syntax and dictionary file for vim users, in the same way that the emacs plugins are mentioned.
I did not know how many people used M2 with vim, so I didn't post it
anywhere.
Instead of posting the files, I would rather post a script (M2,sed/
awk) that does it, which has the advantage of being able to update the
set of keywords if one installs/loads new packages. Does anyone know
an efficient way of generating and classifying keywords, loosely,
based on their nature, i.e., whether they are methods, objects,
constants etc?
Manoj.
> On Mar 7, 5:56 pm, Baptiste Calmès <baptiste.cal...@gmail.com> wrote:
>
>> If it's not already somewhere that I missed in the documentation, it would be a good idea to mention
>> your syntax and dictionary file for vim users, in the same way that the emacs plugins are mentioned.
>
> I did not know how many people used M2 with vim, so I didn't post it
> anywhere.
Well, I don't know either, but people who prefer vim to emacs as a text editor would probably be happy to use it with M2.
> Instead of posting the files, I would rather post a script (M2,sed/
> awk) that does it, which has the advantage of being able to update the
> set of keywords if one installs/loads new packages. Does anyone know
> an efficient way of generating and classifying keywords, loosely,
> based on their nature, i.e., whether they are methods, objects,
> constants etc?
Well, at least, it would be great to have your syntax file more widely distributed. For me, syntax highlighting is a lot more important than word completion.
Anyway, in your vimrc file, on your website, there is a line:
setfiletype m2
If I understand well, this line sets the filestyle to m2 if it has not already been set by vim. Well, on my computer, vim recognizes .m2 files as "modula2" type files, and then your line doesn't set anything. I my case, to override this modula2 style, I had to write the line:
au BufRead,BufNewFile *.m2 set filetype=m2
in a newly created .vim/ftdetect/m2.vim file, as explained in the vim documentation :help new-filetype, under method A.
Baptiste
> Anyway, in your vimrc file, on your website, there is a line:
> setfiletype m2
>
> If I understand well, this line sets the filestyle to m2 if it has not already been set by vim. Well, on my computer, vim recognizes .m2 files as "modula2" type files, and then your line doesn't set anything. I my case, to override this modula2 style, I had to write the line:
>
> au BufRead,BufNewFile *.m2 set filetype=m2
True, that is necessary. I have m2.vimrc saved as one file, which
sourced by an autocmd on BufRead and BufNewFile. I forgot to say that
in the instructions.
Manoj.