rhysd / vim-fixjson

Vim plugin for fixjson; a JSON fixer for Humans
https://github.com/rhysd/fixjson
25 stars 1 forks source link

Use system fixjson if available #1

Closed Kamilcuk closed 3 years ago

Kamilcuk commented 3 years ago

On a distribution it may be possible to install fixjson to native system paths using native system package manager. On these distribution there's no need to call npm.. Just use the native tool.

Please add:

--- i/autoload/fixjson/npm.vim
+++ w/autoload/fixjson/npm.vim
@@ -4,6 +4,9 @@ let s:pathsep = s:is_windows ? '\' : '/'
 let s:cmd_path = join([s:root_dir, 'node_modules', '.bin', 'fixjson'], s:pathsep) 

 function! fixjson#npm#local_command() abort
+       if executable('fixjson')
+               return 'fixjson'
+       endif
     if !filereadable(s:cmd_path)
         call fixjson#npm#install()
     endif

This is just enough so that local command picks fixjson from /usr/bin/fixjson without calling npm.

rhysd commented 3 years ago

Please use g:fixjson_executable in your vimrc:

let g:fixjson_executable = 'fixjson'

If you want to use system-installed fixjson only when it is available:

if executable('fixjson')
  let g:fixjson_executable = 'fixjson'
endif
rhysd commented 3 years ago

BTW, vim-fixjson already prefers global fixjson command:

https://github.com/rhysd/vim-fixjson/blob/95452089fb38152a9081d0229ef3071525ba340d/autoload/fixjson.vim#L20-L22

Kamilcuk commented 3 years ago

Thank you! I am sorry, I totally overlooked that - I missed that in code (I should get more sleep (or more coffee!)). Thank you! Och, I believe it would be great to add even a super short documentation with the list of available g:options, it would help a lot.