newlisp.vim 1.31

Started by Cyril, May 09, 2010, 03:33:13 PM

Previous topic - Next topic

Cyril

New release of newlisp.vim syntax highlighter.



* Multiple patches (mostly new function names) by Lutz are included,



* Some typos introduced by Lutz are removed, ;-)



* Minor code cleanup.



This release is numbered 1.31, because 1.28 to 1.30 was used by Lutz. I believe it is ready for newlisp v10.3. Downloadable from the usual locations (http://www.vim.org/scripts/script.php?script_id=2067">one, http://slobin.pp.ru/vim/syntax/newlisp.vim">two).
With newLISP you can grow your lists from the right side!

Lutz

#1
Thanks Cyril for keeping newlisp.vim always in good shape.

TedWalther

#2
Cyril, is there any chance to doll up the string hilighting?



I notice that curly braces {} and [text][/text] blocks aren't highlighted as strings.  And if a quote " char is inside {} like {}, it treats the " as the start of a string, which can be annoying.  Take the following code for instance:



(println {"} (+ 1 2 3) " hi there!")
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

Cyril

#3
Quote from: "TedWalther"I notice that curly braces {} and [text][/text] blocks aren't highlighted as strings.  And if a quote " char is inside {} like {}, it treats the " as the start of a string, which can be annoying.


It does handle strings, including [text]...[/text] and {braces {even nested}}, see example Code Select
:set syntax?

says? It should be "newlisp", not "lisp" (the latter is Common Lisp). To start newlisp highlighter on .lsp files automatically, you should put newlisp.vim in the right place of your file system, and add the following into your .vimrc:


autocmd! filetypedetect BufNewFile,BufRead *.lsp set filetype=newlisp

Hope this helps.
With newLISP you can grow your lists from the right side!

TedWalther

#4
Thank you. I note the following files in my Ubuntu install of vim:


Quote
/usr/share/vim/vim72/ftplugin/lisp.vim

/usr/share/vim/vim72/indent/lisp.vim

/usr/share/vim/vim72/syntax/lisp.vim


So where should I copy newlisp.vim to? The syntax directory? The indent directory?  To all three directories?  If only to the syntax, should I copy indent/lisp.vim over to indent/newlisp.vim?
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

Cyril

#5
The Vim logic of plugin search is a bit complex. The general answer is "the syntax subdirectory of any of the directories listed in 'runtimepath' option". But this is usually a very long list, so the short answer is: /usr/share/vim/vimfiles/syntax for system-wide settings, or ~/.vim/syntax for your personal ones. /usr/share/vim/vim72/syntax will also work, but I believe that /vim72/ directory is intended to be used for standard vim plugins, and /vimfiles/ for third-party ones.



Hmm... I've just browsed the http://pkg-vim.alioth.debian.org/vim-policy.txt">Debian Packaging Policy for Vim, and it claims that the right directory is /usr/share/vim/addons/syntax. You see, all three system-wide locations will in fact work the same, the difference is only in keeping your Debian (or Ubuntu) system in the sane state. Matter of policy, that is.



And as for other question: my newlisp.vim is syntax file only, it has nothing to do with indent or ftplugin. I just don't feel like a need for special indentation mode for newlisp, so I didn't care. You can experiment with either copying standard lisp files from indent and ftplugin directories, or just not using any lisp-specific indent mode. I am quite happy with the later option. ;-)
With newLISP you can grow your lists from the right side!

Lutz

#6
This is what you also can do: in my /Users/lutz/.vimrc file. At the end, I have the following 2 lines:


au BufRead,BufNewFile *.lsp set filetype=newlisp
au! Syntax newlisp source /Users/lutz/etc/newlisp.vim


... and then I put newlisp.vim in /Users/lutz/etc/newlisp.vim. This is on Mac OS X and of course this works only for one user and not system wide like Cyril's solution would work. If this is part of the Debian newLISP installation, then the system wide solution may be the better.

TedWalther

#7
The newlisp package can't assume vim is installed.  Rather than split out newlisp.vim into a separate debian package, it would be nicer to get it folded upstream.  Is that a possibility?



For now, Lutz, your method looks like the best one.  Maybe I should document it in the README.Debian.



For even more robust file matching, is there a way in vim to tell it that a file that begins with #!-blahblahblah-/newlisp is a newlisp file?



Ted
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

TedWalther

#8
Here is my current .vimrc:


Quote
autocmd! filetypedetect BufNewFile,BufRead *.lsp set filetype=newlisp autoindent lisp lispwords=define,define-macro,set,setf,setq,lambda,lambda-macro,fn,if,if-not,when,unless,case,begin,let,letex,letn,doargs,dolist,dotimes,dostring,while,until,do-while,do-until

autocmd! Syntax newlisp source /usr/share/newlisp-10.2.7/util/newlisp.vim


It does someone correct indenting of the code, but it doesn't yet equal the nicety of GNU Emacs indenting for lisp.  In emacs, you can tell it how many "significant" arguments should be given extra indentation, before reverting to the regular indentation.  For instance, a "while" symbol, if you hit Enter, the expression to be evaluated should get extra indentation, then the body of the while loop should only have regular indentation.
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

TedWalther

#9
I was putting together a HOWTO to properly integrate newlisp with vim, and ran into a snag.  vim already hardwires .lsp files to a lisp syntax hilighter; therefore a .lsp file doesn't fall through to the code that grovels through the file itself and sees the #!/usr/bin/newlisp line.  I can edit files without the .lsp suffix and syntax hilighting works just fine.  I could patch this, but I'm not sure how to do it in a way that lets newlisp syntax hilighting coexist with Common Lisp syntax hilighting.



The relevant file is /usr/share/vim/vim72/filetype.vim.



Oh, wait, the ftdetect/ subdirectory might be relevant to override the erroneous detection of .lsp files.  More on this tomorrow.
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

Tim Johnson

#10
I have the following
" .vimrc
autocmd BufNewFile,BufRead *.lsp set filetype=newlisp
autocmd BufRead,BufNewFile *.lsp setlocal shiftwidth=2 tabstop=2

I put newlisp.vim in my ~/.vim/syntax directory

I also put my own auxiliary newlisp.vim in ~/.vim/after/syntax

In there I put stuff like highlighting for my own user-defined "standard library"



I have not had to tweak filetype.vim at all.



On my slackware system, since I have installed vim via compilation filetype.vim is at

/usr/local/share/vim/vim72.



BTW: I only use vim for ad hoc editing (launched from MC). I primarily use emacs

with the newlisp mode that I wrote for it several years ago. I don't care for emacs

default indentation schema, so I modified that.
Programmer since 1987. Unix environment.