Я достаю из широких штанин
дубликатом бесценного груза.
Читайте, завидуйте, я - гражданин
Советского Союза.
В.В.Маяковский. Стихотворения, поэмы, пьесы. Минск, Изд-во БГУ им. В.И.Ленина, 1977.
vim plugin which formated javascript files by js-beautify
Я достаю из широких штанин
дубликатом бесценного груза.
Читайте, завидуйте, я - гражданин
Советского Союза.
В.В.Маяковский. Стихотворения, поэмы, пьесы. Минск, Изд-во БГУ им. В.И.Ленина, 1977.
I had try to run vim-jsbeautify with v8 (d8)
and got error
/home/bor/.vim/bundle/vim-jsbeautify/plugin/beautify.min.js:1: ReferenceError: arguments is not defined
ath)}).apply(this,typeof process=="object"&&process.argv.splice(3)||arguments)
^
ReferenceError: arguments is not defined
at /home/bor/.vim/bundle/vim-jsbeautify/plugin/beautify.min.js:1:1311
setup
".editorconfig
root = true
[**.js]
bin=d8
indent_style = space
indent_size = 4
$ d8
V8 version 3.14.5.3 [console: dumb]
Please help me to solve this issue.
/Users/jojoyuji/dotfiles/vim/bundle/vim-jsbeautify/plugin/beautify-min.js:1
tf-8")}}();(function(a,c,d){var e={indent_size:4,indent_char:" "},a=f(a),c=c&&
^
TypeError: undefined is not a function
at /Users/jojoyuji/dotfiles/vim/bundle/vim-jsbeautify/plugin/beautify-min.js:1:810
at Object. (/Users/jojoyuji/dotfiles/vim/bundle/vim-jsbeautify/plugin/beautify-min.js:1:865)
at Object. (/Users/jojoyuji/dotfiles/vim/bundle/vim-jsbeautify/plugin/beautify-min.js:1:875)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
It was working so far... What's going on?
I may be overlooking it, but is there currently a way to load options from a project specific .jsbeautifyrc
config file?
I set set sw=4
in .vimrc and indent_size=2
in .editorconfig. why does the 4
achieve? How to solve the conflict properly?
the prettified result is not so satisfying, in which the most annoying is there are spaces between html tags, like this:
< html >
wonder how to configure this or is this a bug?
not sure if i'm alone, but i don't use plugin managers and simply drop the .vim file in ~/.vim/plugin/
but this one merrits some install instructions as you have extra files that are non-obvious, such the js file and the options one.
I've followed the installation instructions exactly (using Pathogen) about 5 times now, and simply can't get the plugin to work. When I run ":call JsBeautify()", it does nothing (also returns no error).
Could you give me some tips for debugging what might be wrong?
When i run the command ':call JsBeautify' in vim, i got the following error message:
module.js:340
throw err;
^
Error: Cannot find module '/Users/ares/vim-ide/.vim/bundle/vim-jsbeautify/plugin/lib/js/lib/beautify.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at load (/Users/ares/vim-ide/.vim/bundle/vim-jsbeautify/plugin/beautify.min.js:1:1164)
at /Users/ares/vim-ide/.vim/bundle/vim-jsbeautify/plugin/beautify.min.js:1:1509
at Object. (/Users/ares/vim-ide/.vim/bundle/vim-jsbeautify/plugin/beautify.min.js:1:1756)
at Object. (/Users/ares/vim-ide/.vim/bundle/vim-jsbeautify/plugin/beautify.min.js:1:1785)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
I don't have the 'lib/js/lib/beautify.js' on my file system. When i clone your git repo, the lib folder is not included.
try this json:
http://help.apple.com/icloud/English.lproj/content.json
Not sure how many people fall into this bucket, but I had some trouble getting this to work in Cygwin because the Windows node.exe doesn't like the paths. I stuck some lines in
~/.vim/bundle/vim-jsbeautify/plugin/beautifier.vim (starting after line 403)
let beautify_absolute_path_windows = fnameescape(system("cygpath -w ".s:plugin_Root_directory."/beautify.min.js"))
let tmp_file_Beautifier_arg_windows = fnameescape(system("cygpath -w ".tmp_file_Beautifier_arg))
let path_Beautifier_arg_windows = fnameescape(system("cygpath -w ".path_Beautifier_arg))
let result = system(engine." ".beautify_absolute_path_windows." --js_arguments ".tmp_file_Beautifier_arg_windows." ".opts_Beautifier_arg." ".path_Beautifier_arg_windows)
That worked for me. Not sure how to test within the script if this is the scenario, but just in case there's some other Cygwin Vim user with the Windows NodeJS, there you go.
js-lint complains Expected exactly one space between 'function' and '('
Seems that the indent_size value in .editorconfig is not respected when running JSBeautify. It always defaults to 4. Node 1.10.14 and jsbeautify 1.4.0
When I run
:HtmlBeautify()
i got
Error: ENOENT, no such file or directory '/home//.vim/bundle/js-beautify/beautify-html.js'
Installed with vundle
Say I have this CSS:
<style type="text/css" media="screen">
p { margin:10px 0; } .hide { display:none; }
</style>
line 1
line 2
line 3
line 4
line 5
If I visually select inside the tag and do :call CSSBeautify("'<","'>")
it out puts this:
<style type="text/css" media="screen">
p {
margin:10px 0;
}
.polarity {
display:none;
}
line 5
If I visually select the whole tag, this is the output:
<style type="text/css" media="screen"> p {
margin:10px 0;
}
.polarity {
display:none;
}
</style>
line 5
It shouldn't destroy lines 1-4. It also does this with <script> tags. I will be looking into this issue myself when I have the time. Will send PR if I find anything.
I use nodejs for jsbeautify, but in some Linux os, such as my ubuntu 14.04, node is another software instead of nodejs, I can link nodejs as node, but add nodejs for default maybe a better solution. like:
let engine = get(opts, 'bin', 'node')
" Some Linux has node(not nodejs)
" so apt-get install will get nodejs
if !executable(engine)
let engine = get(opts, 'bin', 'nodejs')
endif
This is probably a newbie question, but when I follow the installation instructions and try to run beautiful I get the message
E117: Unknown function: JsBeautify
This is my .vimrc
1 set number
2 set expandtab
3 set tabstop=4
4 set shiftwidth=4
5 syntax on
6
7 ".vimrc
8
9 " map <c-f> :call JsBeautify()<cr>
10 " or
11 autocmd FileType javascript noremap <buffer> <c-f> :call JsBeautify()<cr>
12 " for html
13 autocmd FileType html noremap <buffer> <c-f> :call HtmlBeautify()<cr>
14 " for css or scss
15 autocmd FileType css noremap <buffer> <c-f> :call CSSBeautify()<cr>
and the bundle is here:
/Users/<me>/.vim/bundle/vim-jsbeautify
Any help would be appreciated...
I tried installing via Vundle:
Here is what is in my .vimrc:
Bundle 'maksimr/vim-jsbeautify'
Bundle 'einars/js-beautify'
" set path to js-beautify file
let s:rootDir = fnamemodify(expand("<sfile>"), ":h")
let g:jsbeautify_file = fnameescape(s:rootDir."/bundle/js-beautify/beautify.js")
let g:htmlbeautify_file = fnameescape(s:rootDir."/bundle/js-beautify/beautify-html.js")
let g:cssbeautify_file = fnameescape(s:rootDir."/bundle/js-beautify/beautify-css.js")
When I :call JsBeautify(), I get the wrong path to beautify.js:
Error: ENOENT, no such file or directory '/home/shaun/bundle/js-beautify/beautify.js'
My guess is that s:rootDir isn't expanding to the right place?
Setting it manually to let s:rootDir = "/home/shaun/.vim"
works.
Hi,
I would like to have tabstop=softtabstop=shiftwidth=4 and run this plugin to format my JavaScript file. The .editorconfig settings to achieve that should be:
[**.js]
indent_style = tab
tab_width=4
indent_size = tab
However in this case the plugin uses 4 tabs for every level of indentation. I expect it to use only 1.
With this .editorconfig:
[**.js]
indent_style = tab
tab_width=4
indent_size = 1
It works properly, uses only 1 tab for indentation and sets tabstop=4, however in this case shiftwidth and softtabstop are both set to 1.
My understanding is that the ts, st, sw values are managed by the editorconfig plugin and this plugin does the formatting. That means that the first setting should work and the plugin shouldn't multiply the tabs.
Can I use .jsbeautifyrc file instead of .editorconfig file ?
Good Afternoon!
I am new vim plugins and was excited to discover a JS beautify plugin. I have set it up but cannot configure it to use tabs.
I have installed the plugin, and can launch it as follows:
This works.
It is presently formatting the javascript using spaces. I would like to format using tabs. I tried creating an .editorconfig file inside my home directory but it isn't being picked up. The editor config file looks like this:
[**.js]
indent_style = tab
[**.css]
indent_style = tab
[**.html]
indent_style = tab
max_char = 78
brace_style = expand
Any hints on how to debug this? Would really like to get this working with tabs.
Thanks,
Jake
Env Info:
Windows Running Git Bash
Vim 7.4
Installed vim-jsbeautify using pathogen
Nice, that you added options in the new version! But is there an option for js to put the content of arrays into a new line?
So instead of:
['a', 'b', 'c', 'd']
New line each:
[
'a',
'b',
'c',
'd'
]
Thanks!
When i try to hit HtmlBeautify [:call HtmlBeautify()], i get the following error in vim:
https://gist.github.com/visualisierte/5742929
When i open gvim, an unknown function detected on the startup
Error detected while processing ~/.vim/bundle/vim-jsbeautify/plugin/beautifier.vim:
line 326:
E117: Unknown function: editorconfig#AddNewHook
Did I missing something?
*I installed your plugin using vundle
The current js-beautify
submodule is locked to a version of nov 2013. Please update this dependency more often.
I switch between different projects (root directories). I also make them my cwd when switching. How do I instruct vim-jsbeautify to reload editorconfig ?
They can go through the same beautification as .js
files, but need to be read from either [*]
or [*.json]
section in the editorconfig
I set "let g:config_Beautifier='D:\Vim\vim-config.editorconfig'" in _vimrc, but not work.
Do I need to install any node module in order to use this plugin?
I got the follow error when i format the code:
module.js:340
throw err;
^
Error: Cannot find module 'C:\Users\Gilbert'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)
My "home" should be 'C:\Users\Gilbert Wong' instead.
And I've tried to symlink to just 'Gilbert' but didn't work.
BTW, in the source it seems "vimfiles/" is not one of the places the ".editorconfig" will be looked for. Any plan to support this?
Please help. Thanks.
I noticed that false values in editorconfig files are treated as 'false' not boolean false.
Since 'false' is evaluated as true in javascript, js-beautify treat them as true values.
I'm using
https://github.com/kchmck/vim-coffee-script.git
and want to apply vim-jsbeautify to the scratch compile buffer
from my vimrc:
augroup CoffeeBufNew
au!
autocmd User CoffeeCompile,CoffeeWatch call JsBeautify()
augroup END
When i type ":CoffeeCompile" i get the following error:
Error detected while processing function JsBeautify..Beautifier:
line 54:
E684: list index out of range: 0
E116: Invalid arguments for function setline
Error detected while processing function JsBeautify..Beautifier..<SNR>92_setNumberOfNonSpaceCharactersBeforeCursor:
line 2:
E121: Undefined variable: line
E116: Invalid arguments for function setpos
It seems like the plugin tries to save the cursor position but there is none.
Any help appreciated!
There does not appear to be a way to set the indentation style to tabs using .editorconfig
.
Get error if we have file with first blank line
, set position cursor on first line and call JsBeautify()
Error detected while processing function JsBeautify..Beautifier..<SNR>63_setNumberOfNonSpaceCharactersBeforeCursor:
Related:
#42
Let's say current working directory is /var/lib/project
it should read the following .editorconfig files in order:
giving the highest priority to the current working directory's editor config file.
Thus, whatever is written in /var/lib/project/.editorconfig should override any other editorconfig files for the duplicate options.
This will help localizing different editor config settings for each project.
Hi Maksim,
I found this plugin make vim exit with non-zero exit code which also create the issue below.
http://tooky.co.uk/there-was-a-problem-with-the-editor-vi-git-on-mac-os-x/
It is easy to avoid this issue by setting
git config --global core.editor /usr/bin/vim
It is not an serious issue, but would still hope it can be fixed.
I installed your plugin using pathogen and used the suggested .vimrc
settings listed below.
let g:jsbeautify = {'indent_size': 3, 'indent_char': '\t'}
let g:htmlbeautify = {'indent_size': 3, 'indent_char': ' ', 'max_char': 78, 'brace_style': 'expand', 'unformatted': ['a', 'sub', 'sup', 'b', 'i', 'u']}
let g:cssbeautify = {'indent_size': 3, 'indent_char': ' '}
"map <c-f> :call JsBeautify()<cr>
autocmd FileType javascript noremap <buffer> <c-f> :call JsBeautify()<cr>
autocmd FileType html noremap <buffer> <c-f> :call HtmlBeautify()<cr>
autocmd FileType css noremap <buffer> <c-f> :call CSSBeautify()<cr>
I have Node.js installed under the alias node
. When I hit <c-f>
I get the below error message printed in the buffer:
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
TypeError: undefined is not a function
at CALL_NON_FUNCTION (native)
at ~/.vim/bundle/vim-jsbeautify/plugin/beautify-min.js:1:854
at Object.<anonymous> (~/.vim/bundle/vim-jsbeautify/plugin/beautify-min.js:1:960)
at Object.<anonymous> (~/.vim/bundle/vim-jsbeautify/plugin/beautify-min.js:1:971)
at Module._compile (module.js:402:26)
at Object..js (module.js:408:10)
at Module.load (module.js:334:31)
at Function._load (module.js:293:12)
at Array.<anonymous> (module.js:421:10)
at EventEmitter._tickCallback (node.js:126:26)
If I manually type :call JsBeautify()
I get the same result as above; but typing :call JsBeautify(0,$)
returns no error, but also doesn't load any formatting.
What did I do wrong? Is this error due to my method of installation?
"Download zip file or clone project"
When I copy or clone this project, the folder 'lib' in the folder 'plugin' is not clones.
I need to redefine a path in .editorconfig
Please rewrite your readme.md or make this folder cloneable
Thanks!
What title says.
After the range beautifier commit 89b2ca3, formatting this code produces an error:
1 function() {
2 }
Error detected while processing function JsBeautify..Beautifier:
line 60:
E16: Invalid range: 2,$g/.*/d
It would be great if we had the options we can set documented. I want to be able to set the "Break lines on chained methods" configuration.
when I open some file with Vim at the first time, then format it, it works all right
$ vim index.html
call HtmlBeautify()
But when I open other file like this:
:o main.js
call JsBeautify()
nothing happened, this file cannot format at all.
then I close vim and open the js file with vim, it works all right.
then I open the html file, nothing happened.
It seems that this plugin cannot format the other file in vim, any solution?
It would probably be a good idea to change the jsbeautify configuration to not default to 4 \t indents, so changing it to something like this:
let g:jsbeautify = {'indent_size': 1, 'indent_char': '\t'}
When formatting html files it keeps adding extra newlines at the end of the file.
Calling a format on this input:
1 <html>
2
3 </html>
Produces:
1 <html>
2
3 </html>
4
More calls to the format function will keep increasing the number of extra lines.
I've tried to update to the latest version (my previous version was cloned in the beginning of December). Both these versions has this issue.
I've added the following line to my .vimrc
which runs JsBeautify
every time I save a file:
au BufWritePre *.{js} :call JsBeautify()
Most of the time JsBeautify
doesn't have any effect but replaces the whole content of the file leaving an extra step in the undo history. It should only edit the content of a file if there is a change.
Hi,
I have the following editorconfig:
root = true
[**.js]
;vim:path=~/.vim/bundle/js-beautify/beautify.js
indent_size = 2
jslint_happy = 1
keep_array_indentation = 1
space_before_conditional = 1
break_chained_methods = 1
indent_style = space
[**.css]
;vim:path=~/.vim/bundle/js-beautify/beautify-css.js
indent_style = space
indent_size = 2
[**.html]
;vim:path=~/.vim/bundle/js-beautify/beautify-html.js
unformatted = ['a', 'sub', 'sup', 'b', 'i', 'u']
indent_style = space
indent_size = 2
max_char = 80
brace_style = expand
And the ident_size of 2 is not respected (always set to 4) with the latest version. Any idea why? I have installed /js-beautify as a separated bundle.
I have tried my .editorconfig in both my ~/ dir and ~/.vim/ but it still is ignored. When I invoke :call JsBeautify() it uses 4 spaces instead of 2.
Here is my .editorconfig
root = true
[**.js]
indent_style = space
indent_size = 2
[**.css]
indent_style = space
indent_size = 2
[**.html]
indent_style = space
indent_size = 2
max_char = 78
brace_style = expand
Hi, I have this version of a jsbeautify plugin - https://github.com:ZeusTheTrueGod/vim-format-js.git
It takes settings from your buffer expandtab and tabstopwidth , allows to format while in the insert mode and keeps your cursor position. Any chance to merge our plugins together ?
Bug with indention in new version js-beautify
Expected:
(["foo", "bar"] ).each(function(i) {
return i;
});
Output:
(["foo", "bar"]).each(function(i) {
return i;
});
In my .vimrc I have this line:
call pathogen#helptags()
And when I load vim I am getting this error on startup:
Error detected while processing function pathogen#helptags:
line 4:
E151: No match: /home/kpauli/.vim/bundle/vim-jsbeautify/doc/*
Press ENTER or type command to continue
The doc folder does have contents, though:
kpauli@ubuntu-vm:~$ ls /home/kpauli/.vim/bundle/vim-jsbeautify/doc
en ru
I am new to vim. let me know if there is more information you need.
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.