elzr / vim-json

A better JSON for Vim: distinct highlighting of keywords vs values, JSON-specific (non-JS) warnings, quote concealing. Pathogen-friendly.
Other
1.23k stars 111 forks source link

How to install #52

Closed aisthesis closed 9 years ago

aisthesis commented 9 years ago

This looks like exactly what I want--if only I didn't have to scrape the web to figure out how to install it.

karambita commented 9 years ago

Just copy everything under ~/.vim open the file with json extension $ vim test.json That's it!

aisthesis commented 9 years ago

Are you saying this:

$ cd ~/.vim
$ git clone git@github.com:elzr/vim-json.git
$ ls -a
.otherstuff      vim-json

Now just use vim, and the configuration gets picked up when you use a file with .json extension? How about it my .vimrc has filetype specifications? Do I need to comment them out? Or will the above override the configurations in my .vimrc?

karambita commented 9 years ago

~$ mkdir -p ~/.vim/autoload ~/.vim/bundle; ~$ curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim

~$ sudo gedit ~/.vimrc just copy paste the below data into the file and save the file

" contents of minimal .vimrc execute pathogen#infect() syntax on filetype plugin indent on

~$ cd ~/.vim/bundle ~$ git clone git@github.com:elzr/vim-json.git

mrquincle commented 9 years ago

@karambita Thanks. Would be great if added to the README. :+1:

elzr commented 9 years ago

Added link to here in the README for the manual install instructions. Thanks @karambita! :)

aisthesis commented 9 years ago

Looking through the README.md, I didn't see the link. It in any case should be in a much more prominent spot--like right at the first. As is, the README is nice advertising, but it's very mysterious as to how to actually get the product.

elzr commented 9 years ago

This is the first time in the almost 3 years that this script has been online that this issue has come up. Mysteriousness is not at all deliberate, Pathogen is an inmensely popular installation method. ;) The link back to here was added in the 3rd paragraph in the README: "(Or install it manually.)"

sprive commented 9 years ago

Note that to get to the link for "manual install" instructions in the README, the user has already read past the Pathogen option. By clicking manual install link, they're expressing a clear request for manual installation instructions.

SO, is @karambita's post the "manual install" method? Isn't it calling for installation of Pathogen? Is there a way to manually install without Pathogen?

...As for folks never mentioning the problem before now, there was no issue posted - so nothing to point at and question. It's human nature that when people are alone with a problem, sometimes they may feel like giving up rather than persisting.

sprive commented 9 years ago

Based on the endorsement of Pathogen (and not having any way to install vim-json without it) I went ahead with Pathogen.

Eventually I got Pathogen working, and vim-json after that was a piece of cake.

My comment to newbies: IGNORE all Pathogen instructions you find in Google results or at vim-scripts site, unless it matches what you see in the Pathogen README. I think some blog posts are out of date (they instruct you to to 'call' pathogen functions in your .vimrc which will fail).

The README for the current release of Pathogen is is clear what you need to do; it's just 3 lines in your .vimrc. Then use git to grab the code (or unzip the download) in your bundle dir.

zvrablik commented 8 years ago

small typo in the git clone

there should be https://github.com/elzr/vim-json.git

gcbw commented 8 years ago

if I simply copy this syntax/json.vim to my ~/.vim/syntax/json.vim should it work? (i only need the colors, no fancy indent or syntax occlusion)

and obviously, i've already tested and it did not :) that's why i'm throwing it here to know if i it should work and i screwed something somewhere, or to know if i am missing something else and it was supposed not to work...

ghost commented 8 years ago

@gcbw You also need to cp ftplugin/json.vim to ~/.vim/ftplugin/json.vim. works for me.

davaya commented 6 years ago

The pathogen documentation notes its own demise - Vim 8 includes native support for package management. See https://shapeshed.com/vim-packages/.

And thanks for creating vim-json - it's exactly what we need.

ghost commented 3 years ago

Issues are not really documentation. It would be nice to have proper instructions in the README. Just because only one person has spoken up about the problem it doesn't mean they're the only person who has the problem.

ruffin-- commented 2 years ago

Okay, I'd agree that this was a little discombobulated.

Manual installation instructions (20220121)

This is one version that works.

  1. Download the repo as a zip file (current link).
  2. Access its contents somehow (unzip it, use an app to view contents, whatever)
  3. Find the folder of your VIm install and note it.
    • eg, on Windows, it might be: C:\Program Files (x86)\Vim\vim81\
  4. Copy json.vim from vim-json-master\syntax to your VIm install's syntax folder, which is found in the root level of your install. (hat tip)
  5. Copy json.vim from vim-json-master\ftplugin to your VIm install's ftplugin folder, which is also found in the root level of your install. (hat tip)
  6. Close and reopen your *.json file if it was already open.

For 4. and 5., if you already had a json.vim file, you can replace it with the one you're moving from the repo zip's contents.

If you see errors like the below, you likely have completed step 4. but haven't completed step 5.

lots of vim errors in vim on opening a file


BONUS POINTS:

In the interest of brevity, quotes in your JSON for key names and string values are removed ("concealed") until you put your cursor on a row of json. That makes it very difficult to, eg, distinguish when a numeric value is an number or a string.

{ 
    IsThisAnInt: 15,
    OrIsItAString: 15
}

(One of those is a string.)

To remedy this, add the following line to your .vimrc file:

let g:vim_json_syntax_conceal = 0

This requires VIm 7.3+, apparently. NOTE: If you need help finding your .vimrc, see this.

Now you will see the "full" text, but still with better coloring than the default:

{ 
    "IsThisAnInt": 15,
    "OrIsItAString": "15"
}

Fin


PS: Yes, karambita's instructions, though they might appear to be manual instructions, use Pathogen (grabbing it with curl), which is now apparently obsolete.

chrisco23 commented 10 months ago

I'm using vim for decades (but with minimal customization) and now trying out neovim, so I want it for both for now. I'm running Arch Linux with sway and waybar, both of whose config files do not have a ".json" extension. Should that matter?

I have copied json.vim now to these folders:

/usr/share/vim/vim91/syntax/ /usr/share/vim/vim91/ftplugin/ /usr/share/nvim/runtime/syntax/ /usr/share/nvim/runtime/ftplugin/

Still getting wall of white text. What am I doing wrong?

I am making many small quick changes to sway and waybar config and it's insane to be running vscodium for this.

ZsBT commented 1 month ago

Any news on this subject? Readme still does not describe how to install. Things described here does not help. (Other plugins, e.g. NERDtree works by simply copying to .vim/pack/vendor/start/nerdtree)