Giter Site home page Giter Site logo

sbdchd / neoformat Goto Github PK

View Code? Open in Web Editor NEW
1.9K 11.0 185.0 487 KB

:sparkles: A (Neo)vim plugin for formatting code.

License: BSD 2-Clause "Simplified" License

Shell 1.31% Makefile 0.05% CSS 0.20% Python 4.83% TypeScript 0.64% C++ 0.01% Vim Script 92.97%
vim neovim formatter plugin

neoformat's Introduction

Neoformat Build Status

A (Neo)vim plugin for formatting code.

Neoformat uses a variety of formatters for many filetypes. Currently, Neoformat will run a formatter using the current buffer data, and on success it will update the current buffer with the formatted text. On a formatter failure, Neoformat will try the next formatter defined for the filetype.

By using getbufline() to read from the current buffer instead of file, Neoformat is able to format your buffer without you having to :w your file first. Also, by using setline(), marks, jumps, etc. are all maintained after formatting.

Neoformat supports both sending buffer data to formatters via stdin, and also writing buffer data to /tmp/ for formatters to read that do not support input via stdin.

Basic Usage

Format the entire buffer, or visual selection of the buffer

:Neoformat

Or specify a certain formatter (must be defined for the current filetype)

:Neoformat jsbeautify

Or format a visual selection of code in a different filetype

Note: you must use a ! and pass the filetype of the selection

:Neoformat! python

You can also pass a formatter to use

:Neoformat! python yapf

Or perhaps run a formatter on save

augroup fmt
  autocmd!
  autocmd BufWritePre * undojoin | Neoformat
augroup END

The undojoin command will put changes made by Neoformat into the same undo-block with the latest preceding change. See Managing Undo History.

Install

The best way to install Neoformat is with your favorite plugin manager for Vim, such as vim-plug:

Plug 'sbdchd/neoformat'

Current Limitation(s)

If a formatter is either not configured to use stdin, or is not able to read from stdin, then buffer data will be written to a file in /tmp/neoformat/, where the formatter will then read from

Config [Optional]

Define custom formatters.

Options:

name description default optional / required
exe the name the formatter executable in the path n/a required
args list of arguments [] optional
replace overwrite the file, instead of updating the buffer 0 optional
stdin send data to the stdin of the formatter 0 optional
stderr capture stderr output from formatter 0 optional
no_append do not append the path of the file to the formatter command, used when the path is in the middle of a command 0 optional
env list of environment variable definitions to be prepended to the formatter command [] optional
valid_exit_codes list of valid exit codes for formatters who do not respect common unix practices [0] optional
try_node_exe attempt to find exe in a node_modules/.bin directory in the current working directory or one of its parents (requires setting g:neoformat_try_node_exe) 0 optional

Example:

let g:neoformat_python_autopep8 = {
            \ 'exe': 'autopep8',
            \ 'args': ['-s 4', '-E'],
            \ 'replace': 1, " replace the file, instead of updating buffer (default: 0)
            \ 'stdin': 1, " send data to stdin of formatter (default: 0)
            \ 'env': ["DEBUG=1"], " prepend environment variables to formatter command
            \ 'valid_exit_codes': [0, 23],
            \ 'no_append': 1,
            \ }

let g:neoformat_enabled_python = ['autopep8']

Configure enabled formatters.

let g:neoformat_enabled_python = ['autopep8', 'yapf', 'docformatter']

Have Neoformat use &formatprg as a formatter

let g:neoformat_try_formatprg = 1

Enable basic formatting when a filetype is not found. Disabled by default.

" Enable alignment
let g:neoformat_basic_format_align = 1

" Enable tab to spaces conversion
let g:neoformat_basic_format_retab = 1

" Enable trimmming of trailing whitespace
let g:neoformat_basic_format_trim = 1

Run all enabled formatters (by default Neoformat stops after the first formatter succeeds)

let g:neoformat_run_all_formatters = 1

Above options can be activated or deactivated per buffer. For example:

    " runs all formatters for current buffer without tab to spaces conversion
    let b:neoformat_run_all_formatters = 1
    let b:neoformat_basic_format_retab = 0

Have Neoformat only msg when there is an error

let g:neoformat_only_msg_on_error = 1

When debugging, you can enable either of following variables for extra logging.

let g:neoformat_verbose = 1 " only affects the verbosity of Neoformat
" Or
let &verbose            = 1 " also increases verbosity of the editor as a whole

Have Neoformat look for a formatter executable in the node_modules/.bin directory in the current working directory or one of its parents (only applies to formatters with try_node_exe set to 1):

let g:neoformat_try_node_exe = 1

Adding a New Formatter

Note: you should replace everything {{ }} accordingly

  1. Create a file in autoload/neoformat/formatters/{{ filetype }}.vim if it does not already exist for your filetype.

  2. Follow the following format

See Config above for options

function! neoformat#formatters#{{ filetype }}#enabled() abort
    return ['{{ formatter name }}', '{{ other formatter name for filetype }}']
endfunction

function! neoformat#formatters#{{ filetype }}#{{ formatter name }}() abort
    return {
        \ 'exe': '{{ formatter name }}',
        \ 'args': ['-s 4', '-q'],
        \ 'stdin': 1
        \ }
endfunction

function! neoformat#formatters#{{ filetype }}#{{ other formatter name }}() abort
  return {'exe': {{ other formatter name }}
endfunction

Managing Undo History

If you use an autocmd to run Neoformat on save, and you have your editor configured to save automatically on CursorHold then you might run into problems reverting changes. Pressing u will undo the last change made by Neoformat instead of the change that you made yourself - and then Neoformat will run again redoing the change that you just reverted. To avoid this problem you can run Neoformat with the Vim undojoin command to put changes made by Neoformat into the same undo-block with the preceding change. For example:

augroup fmt
  autocmd!
  autocmd BufWritePre * undojoin | Neoformat
augroup END

When undojoin is used this way pressing u will "skip over" the Neoformat changes - it will revert both the changes made by Neoformat and the change that caused Neoformat to be invoked.

Supported Filetypes

neoformat's People

Contributors

adrianimboden avatar alok avatar avegancafe avatar avi-d-coder avatar ayazhafiz avatar cdayjr avatar codeinabox avatar deathlyfrantic avatar dm9pzcaq avatar fenuks avatar foxoman avatar ianks avatar jonascarpay avatar jwoudenberg avatar kunish avatar laxtiz avatar lpil avatar nblock avatar philipp-m avatar raviqqe avatar sbdchd avatar sheldonkwok avatar staticrocket avatar stevearc avatar toastal avatar wlemuel avatar xrelkd avatar y9c avatar zachcoyle avatar zeertzjq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

neoformat's Issues

Local node modules

I've been adding some custom formatters, to use local versions of eslint and prettier. Just wondering if there's been discussion about this? Depending on globally installed npm packages is not always a good idea - especially if you have many projects on many different versions of node.

It might be worth adding an option or extra check for a local version first?

EPIPE error

I tried running clang-format on a file that was just comments and got:

E5677: Error writing input to shell-command: EPIPE.

Never seen that before today. Running the latest version of neoformat.

PHP Beautifier configuration

So I've started working on an older php codebase with very inconsistent formatting. I'd like to pass all the files through the php formatter, but it gets rid of all new lines, which in this particular code base makes alot of the code hard to read. How would I go about making php beautifier format it consistently but keep all newlines?

/tmp/neoformat/

+ if get(a:definition, 'replace', 0)
+ let path = !using_stdin ? '/tmp/neoformat/' . fnameescape(filename) : ''
+ else
+ let path = !using_stdin ? tempname() : ''
+ endif

This don't work on windows system,because windows not hava "/tmp" directory.

Make it possible to see error messages from formatters

If I run Neoformat! javascript prettier on a snippet with an syntax error, I get the not so helpful message:

Neoformat: attempted all formatters for current filetype

but the actual error is not visible anywhere. I can see in function! s:neoformat() in neoformat.vim that it does this inside the loop where it tries all the formatters, so if any are outright missing then I understand we of course don't want to see error messages about that. But I would've liked to see the actual reason for the formatting error and that it is in line X...

I've noticed that if there are errors in the input for e.g. vanilla javascript prettier, it prints error information to stderr and then exits with exit code 2:

londo@peter:~> cat /tmp/ost.js 
    if (true) {
    doSomething();
    <%= template().stuff() %>
    }
londo@peter:~> prettier /tmp/ost.js 

/tmp/ost.js: SyntaxError: Unexpected token (3:5)
  1 |     if (true) {
  2 |     doSomething();
> 3 |     <%= template().stuff() %>
    |      ^
  4 |     }
  5 | 
londo@peter:~> echo $?
2

(The actual use-case is a formatting a tiny selection in a larger file, so to actually get the error message, I have to copy the selection to another file, save it, open a terminal, run prettier manually. Not fun.)

Workaround

I noticed that perltidy for perl files just showed any formatting errors inline as a result. That was because perltidy has an exit code of 0 regardless of any errors. (Which definitely could be problematic for other reasons...).

But this led me to create a tiny wrapper script, prettier_noerror:

#!/bin/bash
prettier "$@"
exit 0

And this in .vimrc:

let g:neoformat_javascript_prettier = {
            \ 'exe': '/path/to/prettier_noerror',
            \ 'args': ['--tab-width', '4', '--single-quote'],
            \ 'stdin': 1,
            \ }

Now I can see the errors (but they aren't detected).

Is there a better way?

Add stdout option

I'm trying to get eslint to work with neoformat. Eslint does nether support stdin for formatting nor does it print the result on stdout. The file to be formatted is instead changed in place.

Could you add a stdout option which would ignore the stdout of the formatter and just use the changed temp file?

Thank you.

suggestion: allow formatting ranges in visual mode

as far as i can tell, neoformat currently only works on the whole buffer. One idea is that you could make it take a range in visual mode, and then run that range through the formatters. It will be up to the user to ensure that their formatter actually works with this. This would basically be restricted to formatter that can take STDIN.

This is especially handy for composite file types and code that has other code embedded in it, like markdown.

For example,

some markdown text
blah blah


    ```python
    some python code that needs formatting
    ```

You could then run a formatter over the code inside, rather than copy/pasting from another buffer.

Case-only changes are ignored

When using sqlformat with only --keywords upper (or --keyword-case upper, depending on the version), the changes are not applied, even though I can see them when increasing verbosity. When any option that makes non-case changes is enabled, the casing changes get applied as well.

Config snippet:

  let g:neoformat_enabled_sql = ['sqlformat']
  let g:neoformat_sql_sqlformat = {
        \ 'exe': 'sqlformat',
        \ 'args': ['--keywords upper', '-'],
        \ 'stdin': 1,
        \ }

Use perttier to format css file no work

Hi, I have updated my neoformat and prettier to the latest version, but it seems no work for formatting css files. Please help, thanks.

I use command :Neoformat prettier when editing css files, but it report Neoformat: formatters prettier failed to run. I use the same command and work in js file.

My vimrc file config as follow:

.vimrc

autocmd FileType javascript,css set formatprg=prettier\ --stdin\ --single-quote\ --trailing-comma\ es5

.vimrc.bundle

Bundle 'sbdchd/neoformat'
" Use formatprg when available
let g:neoformat_try_formatprg = 1

TSFMT reading from buffer errors

When reading from buffer instead of files, there seem to be some issues with escaped characters.

Note if you change this to read from file instead, it works great.
I will note that vim-autoformat does not have this issue, so it could need some escaping?

Don't change file on error

For example, this (invalid) Haskell program

foo

becomes

Language.Haskell.Stylish.Parse.parseModule: could not parse <unknown>: ParseFailed (SrcLoc "<unknown>.hs" 2 1) "TemplateHaskell language extension is not enabled. Please add {-# LANGUAGE TemplateHaskell #-} pragma at the top of your module."
foo 

I'm not sure if the formatter writes the error msg to STDERR, but if it does, it may be better to only capture output from STDOUT, and to only put the new text if the formatter exits with error code 0.

Instead of replacing the buffer with an error message, you could do something like echomsg "Formatting failed. Please check that your program doesn't contain syntax errors".

Neoformat manipulates the contents of the yank register

Hi there, thanks for the plugin! It's been really useful to me, but I noticed a slight problem:

If I delete some text, then run :Neoformat, then paste the text, the pasted text is different from what I deleted. I was able to reproduce this using prettier as my formatter on the following Javascript file:

function start() {
require('../lib/launcher')()
}

My steps were:

  1. Delete the second line: jdd
  2. Run :Neoformat
  3. Paste: p

I expected to end up with the following:

function start() {}
require('../lib/launcher')()

but instead I saw this:

function start() {}
function start() {
}

I was able to reproduce this in a clean Docker environment constructed from this Dockerfile:

FROM ubuntu
RUN apt update && apt install -y git vim
RUN apt install -y npm

RUN apt install -y curl
RUN curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
      https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
RUN echo "call plug#begin('~/.vim/plugged')" >> ~/.vimrc
RUN echo "Plug 'sbdchd/neoformat'" >> ~/.vimrc
RUN echo "call plug#end()" >> ~/.vimrc

RUN npm install -g prettier
RUN apt install -y nodejs-legacy

RUN echo "function start() {" >> /file.js
RUN echo "require('../lib/launcher')()" >> /file.js
RUN echo "}" >> /file.js

by running:

docker build . -t neoformat-yank-bug # assuming the above file is saved as ./Dockerfile
docker run -it --rm neoformat-yank-bug
# inside docker container:
vim file.js
# inside vim:
:PlugInstall
:q
jdd
:Neoformat
p

Let me know if there's anything I can do to help track this down or fix it. Thanks!

Format buffer using clang format file

Its possible to add support for clang format using a file?
I tried:

let g:neoformat_c_clangformat = {
            \ 'exe': 'clang-format',
            \ 'args': '-style=file',
            \ }

But doesn't work.

Running multiple formatters is not working

When I configured multiple formatters for the same file type, only the first was applied

For example, for python formatting I set isort and autopep8 as formatters like this:

autocmd! BufWritePre * Neoformat
let g:neoformat_python_isort = {
            \ 'exe': 'isort',
            \ 'args': ['-'],
            \ 'stdin': 1,
            \ }
let g:neoformat_enabled_python = ['isort', 'autopep8']

Only the changes made by isort are applied to the buffer (or the file, if writing to the file). If I put autopep8 first, only the changes made by autopep8 are applied.

isort should order python imports and autopep8 should fix code style problems. In the example below, both should make changes, isort should put the datetime import first and autopep8 should remove the space after arg in the run function.

from os import path
from datetime import datetime


def run(arg ):
    pass

Neoformat prettydiff does not work when editing files

I'm trying to use neoformat's prettydiff module, and while it does work for already written files, editing the buffer and calling Neoformat does not work (it's reverting to the old version).

I'm pretty sure it's because the file is not written yet when calling Neoformat (I'm using BufWritePre), and we specify %:p as the source path (https://github.com/sbdchd/neoformat/blob/master/autoload/neoformat/formatters/css.vim#L27) which expands to the target file, and not the temporary file specified here https://github.com/sbdchd/neoformat/blob/master/autoload/neoformat.vim#L83-L91

My vimscript level is too low to understand how to fix this, so hopefully the fix is easy :)

silent mode

I'd rather neoformat echo nothing unless an error happens. This should probably be put behind a option.

Feature request: more random temporary directory names

Literally :) Temporary directories could look something like this.

then buffer data will be written to a file in /tmp/neoformat/, where the formatter will then read from

Now imagine this scenario: there are multiple users logged in to same machine, and using this plugin. What would be result? A lot of permission denied errors probably.

// tag: enhancement

html-tidy writing unknown options to buffer

I encountered a curious case where "unknown option: wrap125" is being printed to the buffer on save.

HTML Tidy: unknown option: w
HTML Tidy: unknown option: r
HTML Tidy: unknown option: a
HTML Tidy: unknown option: p
HTML Tidy: unknown option: 1
HTML Tidy: unknown option: 2
HTML Tidy: unknown option: 5
<!DOCTYPE html>

<html lang="en">
<head>
  <meta charset="UTF-8">

  <title>
  </title>
</head>

<body>
  <div id="app">
  </div>
</body>
</html>

Debug log:

Neoformat: executable: html-beautify is not an executable
Neoformat: ['<!DOCTYPE html>', '', '<html lang="en">', '<head>', '  <meta charset="UTF-8">', '', '  <title>', '  </title>', '</head>', '', '<body>', '  <div id="app">', '  </div>', '</body>', '</html>']
Neoformat: tidy -quiet --indent auto --indent-spaces 2 --vertical-space yes --tidy-mark no -wrap125 /var/folders/nt/jmjtq3cj43s6jy_l65l0cg940000gn/T/nvimMDh7DX/31
Neoformat: using tmp file
Neoformat: ['HTML Tidy: unknown option: w', 'HTML Tidy: unknown option: r', 'HTML Tidy: unknown option: a', 'HTML Tidy: unknown option: p', 'HTML Tidy: unknown option: 1', 'HTML Tidy: unknown option: 2', 'HTML Tidy: unknown option: 5', '<!DOCTYPE html>', '', '<html lang="en">', '<head>', '  <meta charset="UTF-8">', '', '  <title>', '  </title>', '</head>', '', '<body>', '  <div id="app">', '  </div>', '</body>', '</html>']

My current tidy version is 5.4.0 and it seems to expect -wrap 125 instead of -wrap125.

By making a small tweak to the current formatters/html.vim seems to fix for me.

function! neoformat#formatters#html#tidy() abort
    return {
        \ 'exe': 'tidy',
        \ 'args': ['-quiet',
        \          '--indent auto',
        \          '--indent-spaces ' . shiftwidth(),
        \          '--vertical-space yes',
        \          '--tidy-mark no',
-       \          '-wrap' .&textwidth
+       \          '-wrap ' . &textwidth
        \         ]
        \ }
endfunction

I'm happy to have a PR up for this fix but I'm afraid that it might just be a version issue and it will break previous versions. Please let me know if I can proceed with the PR.

Ability to treat any stderr output as a failure

perltidy appears to always return an exit status of 0, even if it is unable to parse the file correctly. It sends what it could "tidy" to stdout and sends an error message explaining the failure to stderr, which can be quieted with -q. This can result in a tidy that looks superficially ok at first glance but ended up messing up the file due to perltidy misunderstanding the syntax due to the error. Would it be possible to add a flag that allowed any stderr output to be treated as a failure? Is something like this doable currently by other means?

Prettier

Hey,

Found neoformat via prettier and was trying to get it working. After installing Neoformat (via NeoBundle) and installing prettier globally via npm I receive the following error when running :Neoformat prettier on a test js file:

Error detected while processing function neoformat#Neoformat[5]..<SNR>108_neoformat:
line   60:
E739: Cannot create directory: /tmp/neoformat

I receive this both when the test file has been saved already and when it is in an empty buffer. Any pointers on this?

Thanks,
Billy

run formatter in the directory of the file

If neovim is in a different directory than the file being formatted, esformatter cannot find .esformatter in the file's directory because it is being run in the current working directory and thus does not use the correct rules. This is easy to fix, just change the directory that the formatter is run in to be the local directory of the file.

Add config options to define the priority of formatters

How can we define the order of formatters searched/used?

For example, I use js-beautify to format JSON files, but it's also the first formatter listed for Javascript and I prefer to use prettier-eslint for Javascript.

Also, the js-beautify package comes with cssbeautify, which is the first formatter listed for CSS, where I prefer stylefmt, or even prettier.

Basically, there's some toe-stepping going on.

Possible to copy from `formatprg`

Hi there, I'm not sure if this makes sense, but it is possible for Neoformat to autodetect options / config from formatprg?

For example, I have the following in my vimrc:

autocmd FileType javascript setlocal formatprg=prettier\ --stdin\ --flow-parser\ --single-quote\ --trailing-comma\ --bracket-spacing\ false

I basically end up copying these flags for Neoformat.

Thanks for the great plugin!

Format unfolds folds

Hi there! It seems that when a formatter is run, it unfolds any blocks that exist.

neoformat

vs what vim-autoformat does

vim-autoformat

I'd be happy to write a PR for this, just curious as to where you think this would be happening?

piping to sed in pandoc breaks with commit 32fc31

If you run that formatter on a file with pandoc filetype, it runs fine, except that the text is not piped to sed, so any checklists are escaped

- [] a

becomes

-   \[\] a

I ran git bisect and it appears to be commit 32fc31 that broke it.

Breaks TypeScript line endings with tsfmt

Neoformat breaks .ts files line endings while Autoformat does not have this issue. This does not happen for .js files so could be formatter related. Running tsfmt from console using --stdin does not break line endings.

tsfmt

Using neoformat 4d1f13d, typescript-formatter 4.0.1 and typescript 2.1.4 on Windows.

add example for format on save in README

For example If you want all go files to automatically be formatted on save, you can just set

augroup _go
  autocmd!		
  autocmd BufWritePre *.go Neoformat
augroup END

You should add a example like that to the README, I'm sure many people will want this.

Allow buffer local settings

I am using eslint_d executable and config from the project I am in.
Thus, I would like to set the configuration on a per buffer basis.
I couldn't get that to work with the current version.

From my ftplugin/javascript.vim

augroup js_linting
  autocmd!

  let b:neomake_javascript_enabled_makers = []
  let b:neomake_jsx_enabled_makers = []

  let s:eslint_d_exe = nrun#Which('eslint_d')
  if s:eslint_d_exe != "eslint_d not found"
    let b:neomake_javascript_enabled_makers = ['eslint_d']
    let b:neomake_jsx_enabled_makers = ['eslint_d']

    let g:neoformat_enabled_javascript = ['eslint_d']
    let g:neoformat_javascript_eslint_d = neoformat#formatters#javascript#eslint_d()
    let g:neoformat_javascript_eslint_d['exe'] = s:eslint_d_exe

    autocmd BufEnter *.jsx\= let b:neomake_javascript_eslint_d_exe = s:eslint_d_exe
    autocmd BufEnter *.jsx\= let b:neomake_javascript_eslint_d_args = neomake#makers#ft#javascript#eslint()['args'] + ['-c', nrun#Where('.eslintrc.json')]
    autocmd BufWritePre * Neoformat
    autocmd VimLeave * call system(s:eslint_d_exe . ' stop')

  else
    let s:eslint_exe = nrun#Which('eslint')
    if s:eslint_exe != "eslint not found"
      let b:neomake_javascript_enabled_makers = ['eslint']
      let b:neomake_jsx_enabled_makers = ['eslint']
      autocmd BufEnter *.jsx\= let b:neomake_javascript_eslint_exe = s:eslint_exe
    autocmd BufEnter *.jsx\= let b:neomake_javascript_eslint_args = neomake#makers#ft#javascript#eslint()['args'] + ['-c', nrun#Where('.eslintrc.json')]
    endif
  endif

  if len(b:neomake_javascript_enabled_makers) == 1
    autocmd BufWritePost * Neomake
  endif
augroup END

Any chance of adding this? Would be willing to implement given a pointer to where to start.

/tmp/neoformat

Neoformat on windows system don't create directory

/tmp/neomake

Maybe add a tmp path config, it will be solved!

Cannot create directory: /tmp/neoformat

On osx:

Error detected while processing function neoformat#Neoformat[5]..<SNR>115_neoformat:
line   72:
E739: Cannot create directory: /tmp/neoformat

This seems to happen on files with no formatter configured, and simply removing /tmp/neoformat seems to fix the issue until formatting is attempted once again - I'm guessing that the directory creation fails when /tmp/neoformat already exists and results in the error?

Formatting depends on visual selection (clang-format)

Thank you for your great plugin, i'm really enjoying it so far. But I encountered a possible shortcoming. The c++ code below was formatted with clang-format (via normal mode :Neoformat) and the result is perfectly fine.

int main()
{
	int  a = 1;
	bool b = false;
}

But as soon as I try to format a visual selection the formatting is off. Below is the result of only formatting line 3 in visual mode by calling :Neoformat:

int main()
{
int a = 1;
	bool b = false;
}

If line 3 and 4 are selected:

int main()
{
int  a = 1;
bool b = false;
}

If lines 2 to 5 are selected the formatting matches listing 1 ๐Ÿ‘. my guess is that the visual selection is formatted out of any surrounding context which leads to incorrect results.

Advanced exit status handling?

I was looking on how to add support for PHP_CodeSniffer formatting but it uses non zero exit codes for non errors:

  • Exit code 0 is now used to indicate that no fixable errors were found, and so nothing was fixed
  • Exit code 1 is now used to indicate that all fixable errors were fixed correctly
  • Exit code 2 is now used to indicate that PHPCBF failed to fix some of the fixable errors it found
  • Exit code 3 is now used for general script execution errors

https://github.com/squizlabs/PHP_CodeSniffer/releases/tag/3.0.0RC3

I according to this exit codes 1 and 2 should be whitelisted from the neoformat error handling.

json definition is not correct

currently json.vim calls javascript formatters, but it errors out with 'definition not found' for both prettydiff and jsbeautify

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.