clojure vim shebang

12 views
Skip to first unread message

John Ky

unread,
Nov 11, 2009, 6:21:32 PM11/11/09
to clo...@googlegroups.com
Hi all,

Does anyone know why if the first character in my *.clj file is '#', then when I open it in VIM, ClojureVIM fails to recognise it as a Clojure file?

Thanks

-John

MarkSwanson

unread,
Nov 11, 2009, 6:47:31 PM11/11/09
to Clojure
> Does anyone know why if the first character in my *.clj file is '#', then
> when I open it in VIM, ClojureVIM fails to recognise it as a Clojure file?

I don't know why, but I can provide this data point:
It does not do that for me.
Vim 7.2, vimclojure 2.1.2, java 6.0.14

John Ky

unread,
Nov 11, 2009, 7:30:02 PM11/11/09
to clo...@googlegroups.com
Mine is almost the same:

Vim 7.2, vimclojure 2.1.2, java 1.6.0_10


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

David Brown

unread,
Nov 12, 2009, 3:09:26 AM11/12/09
to clo...@googlegroups.com
On Thu, Nov 12, 2009 at 10:21:32AM +1100, John Ky wrote:

>Does anyone know why if the first character in my *.clj file is '#', then
>when I open it in VIM, ClojureVIM fails to recognise it as a Clojure file?

Vim runs the type detectors that examine the file before the ones
based on filename. The vimclojure name-based autodetector uses
'setfiletype' which only sets the filetype if it hasn't been detected
already.

The simplest fix is to change the 'setfiletype' in the
ftdetect/clojure.vim file to 'filetype'. This tells it to force the
filetype to clojure when it ends in '.clj' no matter what it was
detected as.

You can also make line 2 of the file be something like:
; vim: set filetype=clojure :

and just override it on an individual basis.

David

David Brown

unread,
Nov 12, 2009, 3:10:43 AM11/12/09
to clo...@googlegroups.com
Speaking of vimclojure, has anyone else encountered situations where
the vimclojure indent decides that the indentation of top-level
constructs should be two spaces over? I haven't been able to figure
out a pattern, and sometimes I can even fix it by just scrolling up
and back.

David

Jeff Rose

unread,
Nov 12, 2009, 4:38:44 AM11/12/09
to Clojure
Yes, I also have the same issue. Sometimes if I re-indent the file it
goes away, and other times I re-indent the file and all of a sudden
half of the functions are 2 spaces over. (2 spaces is my tab width
though, so I'm not sure if it's a tab or always 2 spaces...)

-Jeff

Michael Wood

unread,
Nov 12, 2009, 5:30:03 AM11/12/09
to clo...@googlegroups.com
2009/11/12 Jeff Rose <ros...@gmail.com>:
> Yes, I also have the same issue.  Sometimes if I re-indent the file it
> goes away, and other times I re-indent the file and all of a sudden
> half of the functions are 2 spaces over.  (2 spaces is my tab width
> though, so I'm not sure if it's a tab or always 2 spaces...)

See if this makes a difference:
syntax sync fromstart

(although I've been having trouble making that work from .vimrc or
similar. It seems to be ignored and I haven't yet managed to track
down why or where it's overridden.)

> On Nov 12, 9:10 am, David Brown <cloj...@davidb.org> wrote:
>> Speaking of vimclojure, has anyone else encountered situations where
>> the vimclojure indent decides that the indentation of top-level
>> constructs should be two spaces over?  I haven't been able to figure
>> out a pattern, and sometimes I can even fix it by just scrolling up
>> and back.

--
Michael Wood <esio...@gmail.com>

Meikel Brandmeyer

unread,
Nov 12, 2009, 12:33:44 AM11/12/09
to clo...@googlegroups.com, vimcl...@googlegroups.com
Hi,

Am 12.11.2009 um 00:21 schrieb John Ky:

> Does anyone know why if the first character in my *.clj file is '#',
> then when I open it in VIM, ClojureVIM fails to recognise it as a
> Clojure file?

What does ":echo &ft" say? I have the general symptom, that Vim
sometimes does not recognise the filetype correctly for self-defined
types.

Please consider to ask these questions on the vimclojure group.

Sincerely
Meikel

Meikel Brandmeyer

unread,
Nov 12, 2009, 1:49:56 AM11/12/09
to Clojure
Hi,

On Nov 12, 12:21 am, John Ky <newho...@gmail.com> wrote:

> Does anyone know why if the first character in my *.clj file is '#', then
> when I open it in VIM, ClojureVIM fails to recognise it as a Clojure file?

Ok. I could reproduce the issue and also found the solution. The
culprit is setfiletype in ftdetect/clojure.vim. As a quick fix change
the following line there:

au BufNewFile,BufRead *.clj setfiletype clojure

into

au BufNewFile,BufRead *.clj set filetype=clojure

I will also patch this for the next release. Thanks for the report.

Sincerely
Meikel

Meikel Brandmeyer

unread,
Nov 12, 2009, 3:33:09 AM11/12/09
to Clojure
Hi,

On Nov 12, 9:10 am, David Brown <cloj...@davidb.org> wrote:
I encountered this also from time to time. (Actually, I can reproduce
it with certain files.) But unfortunately, I haven't found out, yet,
what the reason is.

You might want to try: ":syn syn fromstart" to see if this helps. But
this is only a guess. The indenting relies on the highlighting, which
only syncs back a certain amount. So if scrolling helps, maybe the
highlighting was "fixed" (re-syncronised), which then in turn also
fixes the indenting problem. But as I said: just a guess. I'll try to
track this down.

Sincerely
Meikel

Meikel Brandmeyer

unread,
Nov 12, 2009, 6:58:52 AM11/12/09
to Clojure
Hi,

On Nov 12, 11:30 am, Michael Wood <esiot...@gmail.com> wrote:

> See if this makes a difference:
> syntax sync fromstart
>
> (although I've been having trouble making that work from .vimrc or
> similar.  It seems to be ignored and I haven't yet managed to track
> down why or where it's overridden.)

It may be set be syntax plugins. Try putting it in .vim/after/syntax/
clojure.vim.

Sincerely
Meikel

PS: For windows: .vim == vimfiles

Michael Wood

unread,
Nov 12, 2009, 10:16:19 AM11/12/09
to clo...@googlegroups.com
2009/11/12 Meikel Brandmeyer <m...@kotka.de>:
> Hi,
>
> On Nov 12, 11:30 am, Michael Wood <esiot...@gmail.com> wrote:
>
>> See if this makes a difference:
>> syntax sync fromstart
>>
>> (although I've been having trouble making that work from .vimrc or
>> similar.  It seems to be ignored and I haven't yet managed to track
>> down why or where it's overridden.)
>
> It may be set be syntax plugins. Try putting it in .vim/after/syntax/
> clojure.vim.

Thanks, that seems to have fixed it.

--
Michael Wood <esio...@gmail.com>

MarkSwanson

unread,
Nov 12, 2009, 11:01:45 AM11/12/09
to Clojure
> >> See if this makes a difference:
> >> syntax sync fromstart

I think one of the primary objectives of vimclojure should be to
consistently render correctly - and it can only do that with 'syntax
sync fromstart'.

Meikel Brandmeyer

unread,
Nov 12, 2009, 11:48:24 AM11/12/09
to Clojure
Hi,
Once upon a time, sync fromstart was very slow. With today's computers
it should not be a problem anymore. However, people are obsessed about
speed, so I chose the safe setup, which also works on large files. But
obviously it does have its problems on certain constellations.

I think I asked for feedback in a previous thread, if someone has
problems with sync fromstart. So far I got no response. So I will most
likely switch to sync fromstart for the next release.

Sincerely
Meikel
Reply all
Reply to author
Forward
0 new messages