indentLine
indentLine copied to clipboard
json syntax file conflicts?
I don't install vim-json, but json file syntax seems to be affected.
when indentLine is loaded:
when not loaded:

Need help.
+1
can not reproduce. Maybe you have installed other plugin.

I've test for it in VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jul 24 2015 02:23:23), and NVIM v0.1.0-155-g78e7c40 (compiled Dec 2 2015 20:44:32), use this config:
call plug#begin('~/.config/nvim/plugged')
" basic plugins
Plug 'Yggdroot/indentLine'
call plug#end()
neovim still have the problem:

here is the raw format json:
{
"haha": "xixi",
"this": "that"
}
This issue is caused by the builtin json.vim which also uses the conceal feature.
see here for some related discussion.
I use these settings to walk around.
autocmd InsertEnter *.json setlocal concealcursor=
autocmd InsertLeave *.json setlocal concealcursor=inc
Thanks
I prefer the solution suggested in the linked thread from @Fity.
Plugin 'elzr/vim-json'
let g:vim_json_syntax_conceal = 0
let g:vim_json_syntax_conceal = 0 does not work for the vim-json bundled with Ubuntu's vim package. It's an older version and does not have this option yet.
However the vim-json docs suggest:
The specially overeager indentLine, plugin would require yet an additional
let g:indentLine_noConcealCursor=""in your.vimrcas detailed here.
Which does work on Ubuntu 16.04. For me, at least.
EDIT: Actually you need to set let g:indentLine_concealcursor='nc'.
Same issue here on neovim-0.1.5-dev.
@Leandros : you suggestion works, but is really annoying to install an unwanted plugin to get things work
let g:vim_json_syntax_conceal = 0does not work for thevim-jsonbundled with Ubuntu's vim package. It's an older version and does not have this option yet.
Thank you for posting that. I just ran into this issue today on Ubuntu 16.04 and was trying to figure out why the setting wasn't working. I had incorrectly assumed that because the last update to vim-json was in the middle of 2015, Ubuntu 16.04 would have the latest version. Installing the master version of https://github.com/elzr/vim-json fixed it for me.
None of these fixes work anymore, at least not in neovim. I have this in my init.vim:
let g:indentLine_enabled = 1
let g:vim_json_syntax_conceal = 0
let g:indentLine_noConcealCursor='nc'
let g:vim_json_syntax_conceal = 0
No combinations of these variables does anything at all. My only choice is to disable the plugin. I don't have any additional JSON plugins installed.
@mattolenik, @Leandros answer worked for me.
This issue is because the author of json's syntax file thought people like the quotes being concealed. To fix the issue, you can do like this:
- enter vim
:e $VIMRUNTIME/syntax/json.vim:g/if has('conceal')/s//& \&\& 0/:wq
issue solved
This issue is old but just FYI, default json syntax file is updated and after patch 8.1.2060, you can disable json's concealment selectively. :help json.vim It has the same effect as the above solution.
let g:vim_json_syntax_conceal = 0does not work for thevim-jsonbundled with Ubuntu's vim package. It's an older version and does not have this option yet. However thevim-jsondocs suggest:The specially overeager indentLine, plugin would require yet an additional
let g:indentLine_noConcealCursor=""in your.vimrcas detailed here.Which does work on Ubuntu 16.04. For me, at least.
EDIT: Actually you need to set
let g:indentLine_concealcursor='nc'.
The edit line worked for me with Debian. Thank you!
What I did was make a ~/.vim/after/syntax/json.vim and put this in it:
syn region jsonKeyword matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ contained
syn region jsonString oneline matchgroup=jsonQuote start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=jsonEscape contained
You'll note those are the lines in the if statement in $VIMRUNTIME/syntax/json.vim.
I tested these ones and none of them worked
let g:vim_json_conceal = 0
let g:indentLine_concealcursor='nc'
enter vim
:e $VIMRUNTIME/syntax/json.vim
:g/if has('conceal')/s//& \&\& 0/
:wq
This also didn't worked for me
From vimhelporg:
JSON json.vim ft-json-syntax
The json syntax file provides syntax highlighting with conceal support by default. To disable concealment: let g:vim_json_conceal = 0
The setting it in my .vimrc solved the problem on VIM 8.2.24

I tested these ones and none of them worked
let g:vim_json_conceal = 0 let g:indentLine_concealcursor='nc'
@romariolopezc setting the one liner : let g:vim_json_conceal = 0 in your .vimrc file should be enough (are you using VIM 8.2.24 or above ?)
I still cannot get this to work. Running latest stable neovim v0.4.3 on macOS 10.15.4. I think I've tested all mentioned configurations in this post so there's only the final one in my config in this post. Any help would be appreciated!
Configuration
call plug#begin( '~/.local/share/nvim/plugged')
Plug 'Yggdroot/indentLine'
call plug#end()
set shiftwidth=4
let g:vim_json_conceal = 0
let g:indentLine_concealcursor = 'nc' " Also tested with empty ('')
Example JSON file
{
"data": [
{
"hello": "world",
"foo": 1,
"bar": {
"biz": "baz"
}
}
]
}
Result with config above

Result with conceallevel set to 0

@bombsimon setting of let g:vim_json_conceal = 0 should be enough. According to your screenshot it looks like indent lines are disabled. Try to enable it manually by executing :IndentLinesEnable. If there are no difference idk how to help ( I've switched back from neovim to just vim).
@dagolinuxoid Thanks for your reply!
Yeah, the indent lines gets hidden when setting conceallevel=0. Which I knew since it's stated in the readme, it was just to show how to get the quotes to show. The screenshots were taken in the same buffer just toggling conceallevel so the plugin is enabled.
Just setting let g:vim_json_conceal = 0 does not help.
Config
call plug#begin('~/.local/share/nvim/plugged')
Plug 'Yggdroot/indentLine'
call plug#end()
set shiftwidth=4
let g:vim_json_conceal = 0
Result

So basically neovim config doesn't respect the variable whatsoever. There are three solutions:
- wait till someone can solve it for neovim
- switch to vim
- disable indentlines for
jsonfiles - honestly it's not that helpful to have them in json files, at least you can live without them =)
@dagolinuxoid Thanks for your replies and help!
I was just curious since people in the thread, now latest https://github.com/Yggdroot/indentLine/issues/140#issuecomment-596280543, said they got this to work with neovim without any additional plugins. Because of that I felt like I was doing something wrong byt perhaps I'm not(?)
I think number 3 is most appealing. A fourth solution to actually be able to use neovim and indentlines and not conceal data is the solution posted back in 2016, https://github.com/Yggdroot/indentLine/issues/140#issuecomment-173867054. This works as expected. An extra plugin but personally I don't mind that much.
Config
call plug#begin('~/.local/share/nvim/plugged')
Plug 'Yggdroot/indentLine'
Plug 'elzr/vim-json'
call plug#end()
set shiftwidth=4
let g:vim_json_syntax_conceal = 0
Result

I did install nvim (not the lates version though 0.2.2) for testing. My ~/.config/nvim/init.vim has
call plug#begin( '~/.local/share/nvim/plugged')
Plug 'Yggdroot/indentLine'
call plug#end()
set shiftwidth=4
you can totally get rid of let g:vim_json_conceal = 0 because for nvim it doesn't do a damn thing. nvim without any additional plugins ('elzr/vim-json') designed to treat json files like this:
With IndentLinesDisabled - it shows the raw json files with quotes, and with IndentLInesEnable there are no indent lines too but quotes are gone in normal mode. As soon as you're trying to edit a word by pressing ciw (change inner word) quotes show up and disappear while editing - I found the funny behavior as a pretty cool one. It's not 'overwhelm' you with quotes making it looks cleaner - the downside it's a bit confusing.
I'm curious why there are still so many people bothered by this issue, the root cause and the solution have already been posted above.
- If your vim is 8.1.2060+,
let g:vim_json_conceal = 0should be enough. - otherwise,
:e $VIMRUNTIME/syntax/json.vim :g/if has('conceal')/s//& \&\& 0/ :wq - If you are using other syntax plugin for json, please turn to that plugin for help. e.g.
Plugin 'elzr/vim-json' let g:vim_json_syntax_conceal = 0
This behavior is fixed for me in the latest commit. Perhaps we can close this issue and point to the commit where it's fixed? Otherwise I guess it's just https://github.com/Yggdroot/indentLine/commit/43dbd7092801637972b1d9fcecaaeee11f8e00cf
I'm curious why there are still so many people bothered by this issue, the root cause and the solution have already been posted above.
- doesn't appear to work for Neovim users (there are many)
- isn't portable, has to be redone (remembered, looked up)
- requires installing yet another plugin (which has its own issues) to fix a plugin-related issue.
@chrissound Doesn't appear to fix things on Neovim.
1. doesn't appear to work for Neovim users (there are many)
~~NVIM v0.4.2 works well without any settings.~~ NVIM v0.4.2 works well with the following operation:
:e $VIMRUNTIME/syntax/json.vim
:g/if has('conceal')/s//& \&\& 0/
:wq
2. isn't portable, has to be redone (remembered, looked up)
It's the responsibility of json's syntax file.
3. requires installing yet another plugin (which has its own [issues](https://github.com/elzr/vim-json/issues)) to fix a plugin-related issue.
You don't have to.
NVIM v0.4.2 works well without any settings.
If so they've reverted it because like I stated in https://github.com/Yggdroot/indentLine/issues/140#issuecomment-620424114 it's not working with NVIM v0.4.3, can still reproduce with example and config from linked post.
Installing elzr/vim-json plugin and adding let g:vim_json_syntax_conceal = 0 eventually worked for me.
Thanks @Leandros Leandros
My workaround in Neovim: create a json.vim file in ~/.config/nvim/after/ftdetect There I have the following: au! BufAdd,BufRead,BufNew,BufEnter *.json let g:indentLine_conceallevel=1 au! BufLeave,BufUnload,BufDelete,BufHidden *.json let g:indentLine_conceallevel=2
It's working for me!