[patch] Separate filetype for JSON

59 views
Skip to first unread message

David Barnett

unread,
Jul 14, 2014, 5:57:24 PM7/14/14
to vim...@googlegroups.com
This is a patch to create a separate json filetype and use it for *.json files instead of using javascript. It currently just forwards indent and syntax settings to the javascript filetype, but it does define its own ftplugin/json.vim file since most of the settings in ftplugin/javascript.vim don't apply to JSON. I'd like to submit it to be integrated in vim under the Vim license.

My reasons for wanting to do this instead of just using the javascript filetype are:
* JSON is not JavaScript, it's a very small subset of the language. Comments and many other details of JavaScript syntax are completely invalid in a JavaScript file, so it's misleading to treat them as the same filetype.
* Several plugins (syntastic, vim-snippets, vim-addon-manager) refer to a "json" filetype that doesn't actually exist unless you install some third-party plugin to apply it. This leads to vim unexpectedly triggering "javascript" actions on "json" files, and in the case of vim-addon-manager means addon-info.json files aren't syntax highlighted at all (https://github.com/MarcWeber/vim-addon-manager/issues/163).

David

ft.json.patch

David Fishburn

unread,
Jul 15, 2014, 1:34:04 PM7/15/14
to vim_dev

+1

LCD 47

unread,
Jul 15, 2014, 6:03:49 PM7/15/14
to vim...@googlegroups.com
On 14 July 2014, David Barnett <dbar...@google.com> wrote:
> This is a patch to create a separate json filetype and use it for
> *.json files instead of using javascript. It currently just forwards
> indent and syntax settings to the javascript filetype, but it does
> define its own ftplugin/json.vim file since most of the settings in
> ftplugin/javascript.vim don't apply to JSON. I'd like to submit it to
> be integrated in vim under the Vim license.
[...]

How about a complete solution:

https://github.com/elzr/vim-json.git

I've been using this for almost two years now, and never looked
back.

/lcd

David Barnett

unread,
Jul 15, 2014, 6:42:11 PM7/15/14
to vim...@googlegroups.com
Agreed. I'd prefer to have full-fledged JSON support, but I'd also like to get the filetype fixed ASAP. I went with a relatively minimal change for now that's less likely to be controversial.

Has anyone contacted elzr or authors of any other plugins to see if they want to merge their plugin into vim?

David



--
--
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

---
You received this message because you are subscribed to a topic in the Google Groups "vim_dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_dev/TN1NLapzf44/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vim_dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bram Moolenaar

unread,
Jul 16, 2014, 7:39:25 AM7/16/14
to 'David Barnett' via vim_dev

David Barnett wrote:

> Agreed. I'd prefer to have full-fledged JSON support, but I'd also like to
> get the filetype fixed ASAP. I went with a relatively minimal change for
> now that's less likely to be controversial.

Yes, let's first split the filetype, improving the highlighting is a
separate thing and can be done in separate steps.

> Has anyone contacted elzr or authors of any other plugins to see if they
> want to merge their plugin into vim?

I prefer authors to explicitly say it's OK to distribute their work with
Vim. Usually that's by emailing me the code.

--
My Go, this amn keyboar oesn't have a .

/// Bram Moolenaar -- Br...@Moolenaar.net -- 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 ///

Bram Moolenaar

unread,
Jul 16, 2014, 7:39:26 AM7/16/14
to David Barnett, vim...@googlegroups.com
Thanks, I'll include it. I'll remove the checks for pre-Vim 6.0, that's
reeeeally old.

--
Violators can be fined, arrested or jailed for making ugly faces at a dog.
[real standing law in Oklahoma, United States of America]
Reply all
Reply to author
Forward
0 new messages