Audrius wrote:
> I was exploring the possibility to use cindent for JavaScript code
> indentation, because all the indent plugins I've tried so far make me
> unhappy. I've found that it works pretty well (except for array
> literals spanning multiple lines, though I'll try to fix it using
> indentexpr similar to how it's done in indent/java.vim), but I believe
> I've stumbled upon a bug. At least it doesn't work as advertised in
> documentation.
>
> To reproduce the problem you'll need the following files:
>
> $ cat > test.vim <<EOF
> set nocompatible
>
> set tabstop=8
> set softtabstop=4
> set shiftwidth=4
> set expandtab
>
> set nolisp
> set noautoindent
> set nosmartindent
> set indentexpr=
>
> set cindent
> set cinoptions=j1,J1
> EOF
>
> $ cat > test.js <<EOF
> var bar = {
> foo: {
> that: this,
> some: ok,
> },
> "bar": {
> a : 2,
> b: "123abc",
> x: 4,
> "y": 5
> }
> }
> EOF
>
> The code snippet above is taken from :h javascript-indenting
> documentation. But when I run
>
> $ vim -u test.vim --noplugin test.js
>
> and do gg=G, I get the following:
>
> var bar = {
> foo: {
> that: this,
> some: ok,
> },
> "bar": {
> a : 2,
> b: "123abc",
> x: 4,
> "y": 5
> }
> }
>
> Notice that when the name in object literal is string ("bar":), the
> indentation of its value object literal is correct, but if the name is
> identifier (foo:), then the following three lines look wrong.
>
> I went through :h cinoptions-values, but none of them looked like they
> could interfere with cinoptions=J1 in this case. Either I'm missing
> something important here (some settings) or cindent doesn't work how it
> should according to :h javascript-indenting example.
>
> I'm using vim 7.3.094 from slackware-current.
Yes, it looks different from the example for J1.
Hari?
--
If Microsoft would build a car...
... Occasionally, executing a maneuver such as a left turn
would cause your car to shut down and refuse to restart, in
which case you would have to reinstall the engine.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php