kevinoid / vim-jsonc Goto Github PK
View Code? Open in Web Editor NEW⚠️Deprecated⚠️: Vim syntax highlighting plugin for JSON with C-style line (//) and block (/* */) comments.
License: MIT License
⚠️Deprecated⚠️: Vim syntax highlighting plugin for JSON with C-style line (//) and block (/* */) comments.
License: MIT License
Error detected while processing function <SNR>3_LoadFTPlugin:
line 2:
E492: Not an editor command: commentstring< comments<
The error goes away if I comment out the loading of the plugin in my /etc/xdg/nvim/sysinit.vim
:
" Plug 'kevinoid/vim-jsonc'
It would be useful to add the option to apply this for *.json
files as well, or at least document how to in the Readme.
I did it via including this in my init.vim
as suggested here:
autocmd BufRead,BufNewFile *.json set filetype=jsonc
vim-json
does not set commentstring
and comments
properly for coc-settings.json
(they are blank) on NVIM v0.4.3
. vim-json
installed with vim-plug
and gets listed by scriptnames
.
This is a great package. One issues stands out to me for the example below:
{
"protocol": "gRPC", // communication protocol
"cut": { // cut instruction set
"to": {
"USER_ID": ".response.body.id.value" // write instruction
}
},
"request": { // request payload
"body": {
"email": "[email protected]"
},
"uri": "user_api.User/CreateUser" // request uri
},
"response": { // response payload
"body": "created user: ${USER_ID}",
"status": 0 // response status code
}
}
It seems that any alphanumberic character in a string value that is preceded by a period gets highlighted with the jsonNoQuotes
tag.
So for "USER_ID": ".response.body.id.value" // write instruction
: response, body, id, and value are all highlighted with an error tag
EDIT: it looks like the jsonStringMatch
is not matching on those two lines. Perhaps a lookahead is needed for the comment section?
Eslint allows linting via the eslint-plugin-jsonc plugin.
I've tested it with ALE and it works fine, we just need to add the following linter configuration:
https://github.com/jpesce/vim-jsonc/blob/master/ale_linters/jsonc/eslint.vim
call ale#linter#Define('jsonc', {
\ 'name': 'eslint',
\ 'output_stream': 'both',
\ 'executable': function('ale#handlers#eslint#GetExecutable'),
\ 'cwd': function('ale#handlers#eslint#GetCwd'),
\ 'command': function('ale#handlers#eslint#GetCommand'),
\ 'callback': 'ale#handlers#eslint#HandleJSON',
\})
To make it easier, if you want I can make the pull request.
vim-jsonc
shows error: "modules-left": [
//"custom/name",
"sway/workspaces",
"custom/weather",
"sway/mode"
//"custom/right-arrow-dark"
],
vim-jsonc
does NOT shows error "modules-left": [
//"custom/name",
"sway/workspaces",
"custom/weather",
//"custom/right-arrow-dark"
"sway/mode"
],
I am using NeoVIM: NVIM v0.4.4
on Debian
Let me know if more info is needed
From https://github.com/komkom/jsonc:
Jsonc is a simplified json format which allows comments and unquoted values delimited by whitespace.
As it is vim-jsonc
doesn't allow unquoted values. Any plans for allowing them?
How it currently looks like (red means error):
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.