Commit Graph

95 Commits

Author SHA1 Message Date
lethal-guitar
a7009a9688 Correctly remove newline at end of file on Windows
The code for removing a newline at the end of a file was assuming that each
`eol` in `possible_eols` would be 1 character in length. This assumption
doesn't hold on Windows, where a newline is 2 characters long (`\r\n`). As a
result, auto-formatting files that have a Windows-style line ending would
result in the file's last line being terminated by `\r` (the full EOL cut in
half, essentially).

With this patch, we not only check that the last character of `stdoutdata`
matches the candidate `eol`, but instead check the full sequence of
characters depending on the length of `eol`.
2019-07-08 20:57:07 +02:00
Chiel ten Brinke
c203080645 Fix code flow issue in python 2 code path. 2018-12-10 10:13:07 +01:00
Chiel ten Brinke
8da4de80fb Inspect returncode of formatters as well. 2018-10-22 09:23:41 +02:00
Chiel ten Brinke
fc01fdf90f Simplify code. 2018-10-22 09:07:54 +02:00
Mattias
3c06476e73 #253 Fix formatterpath seperator char on windows 2018-10-21 17:05:45 +02:00
Chiel ten Brinke
f749df790c Write and read from the viminfo before and after formatting.
This should preserve the marks. Fixes #96.
2018-10-10 18:57:12 +02:00
Sergey Alexandrov
bde5b4ff63
Use normal! to autointent code
... otherwise might not work as expected if the user mapped any of the commands used. See [here](http://learnvimscriptthehardway.stevelosh.com/chapters/29.html) about `normal!`.
2018-05-13 14:31:43 -04:00
Chiel ten Brinke
a4b3c40e8c Solve #128. 2017-10-20 14:45:24 +02:00
Chiel ten Brinke
3e26966412 Add simple random number function. 2017-08-30 15:14:56 +02:00
Chiel ten Brinke
f65c4c88af Fix #189. 2017-06-26 09:29:22 +02:00
Chiel ten Brinke
129f17d807 Fix an uncaught BrokenPipeError for the python 3 case. 2017-03-06 18:33:02 +01:00
Chiel ten Brinke
c9c7103b79 Merge branch 'add_formatters_formatdef_overrides' of https://github.com/jpmv27/vim-autoformat into jpmv27-add_formatters_formatdef_overrides 2016-09-09 18:57:19 +02:00
Fredrik Hansson
635d2f2a90 fixed invalid syntax with python 2.6.6 2016-09-07 10:49:52 +02:00
Martin Vuille
9cf57b6a9b Add b:formatters_<filetype> and b:formatdef_<identifier> overrides 2016-09-01 19:59:23 -04:00
Chiel ten Brinke
b9f566b514 Improve documentation about debugging and add PutMessages. 2016-06-15 10:00:58 +02:00
kayw
857d5e7a29 fix: do not treat following "|" and strings as arguments in Autoformat command
related issue: https://github.com/Chiel92/vim-autoformat/issues/124
copy from this code: https://github.com/rhysd/vim-crystal/blob/master/ftplugin/crystal.vim#L51
2016-06-13 20:40:11 +08:00
Chiel ten Brinke
81f5e989c2 Add bufferlocal variants for all options. 2016-03-30 10:01:56 +02:00
Chiel ten Brinke
2d2d200c06 Fix crash related to environment variables containing unicode.
Also use Python 3 instead of 2 when both are available.
2016-03-21 15:46:29 +01:00
Chiel ten Brinke
383fbdb716 Fix vim-autoformat hanging when auto indenting. 2016-03-17 11:23:30 +01:00
Chiel ten Brinke
978e4ece4f Add more default fallback features.
Add removing whitespace and retabbing.
2016-03-11 18:09:05 +01:00
Chiel ten Brinke
4ef9e937c0 Don't touch &formatprg.
Makes sure that gq can always be used in its default fashion.
2016-03-10 17:18:15 +01:00
Chiel ten Brinke
e3542648f1 Fix some verbosity issues. 2016-02-18 10:13:07 +01:00
Chiel ten Brinke
f78c47c34b Merge branch 'master' of https://github.com/sbdchd/vim-autoformat into sbdchd-master 2016-02-17 17:01:00 +01:00
Chiel ten Brinke
b939719fe6 Fix IndexError for when stdout and stderr of formatter are empty. 2016-02-15 09:50:41 +01:00
Steve Dignam
cb4f717fbe minor changes & formatting changes 2016-02-11 11:20:59 -05:00
Chiel ten Brinke
f9cc5ff1b3 Merge branch 'master' into dev 2015-12-23 17:01:37 +01:00
Chiel ten Brinke
7902a12391 Cleanup and update README. 2015-12-15 13:15:05 +01:00
MeLody
37a6b7f979 add swith to default gg=G 2015-12-14 16:41:01 +08:00
frtmelody
b01c85e8f7 Update autoformat.vim
disable gg=G
2015-12-13 16:59:33 +08:00
Chiel ten Brinke
d704fd1647 Add config file detection for clang-format.
Also
 - add CurrentFormatter command.
 - more verbosity.
 - update readme.
2015-12-04 09:59:23 +01:00
Chiel ten Brinke
67222e2a2f Substitute \n with os.linesep. Cleanup change log. 2015-11-12 11:30:59 +01:00
Chiel ten Brinke
289c66899f Append newline to text before sending to formatter. 2015-11-11 18:21:35 +01:00
Chiel ten Brinke
1243463143 Also take different eols into account for removing last empty line 2015-10-29 17:25:39 +01:00
Chiel ten Brinke
735d709e84 Fix python3 support. 2015-10-29 12:22:48 +01:00
Chiel ten Brinke
e6ecfff004 Merge master. 2015-10-28 13:59:03 +01:00
Chiel ten Brinke
10e80a996c Merge branch 'master' into dev 2015-10-28 13:57:45 +01:00
Chiel ten Brinke
8a740ab186 Try all possible new line characters to split on. 2015-10-28 13:57:22 +01:00
Chris Coe
27abe69588 quick fix for both if and else conditions 2015-10-10 07:41:51 -04:00
Chris Coe
62554bd2b0 fix endline in python3 2015-10-08 17:06:58 -04:00
Chiel92
e1e082a970 attempt crossplatform line endings 2015-08-31 21:11:15 +02:00
Chiel92
0ea8377eaa Cleanup 2015-08-08 14:37:21 +02:00
Fredrik Hansson
9545f0cfcf fix for using the default gg=G on files without formatting definitions at all 2015-08-08 14:01:26 +02:00
Chiel92
a5b99fa608 Remove pendent newline from formatter output. Fix #61. 2015-08-01 05:57:54 +02:00
Chiel92
509f982da6 Update readme 2015-06-22 09:18:49 +02:00
Chiel92
47bd95f672 Ugly hack to support +python3 2015-06-19 23:17:31 +02:00
Chiel92
9107b620f4 Fix previous commit 2015-06-19 13:58:09 +02:00
Chiel92
977500d769 Allow vim with +python3 as well. 2015-06-19 13:38:20 +02:00
Chiel92
f7e872f15a Move window state recall outside TryFormatter 2015-06-12 14:29:33 +02:00
Chiel92
ba12dfc1b7 Add note about python support in README. Related to #54. 2015-06-11 09:51:51 +02:00
Sergiy Borodych
716813ee2d add check if vim has no support for python
it is necessary to verify the custom formatter
if no support show a notional warning message
2015-06-11 10:23:20 +03:00