Friday, April 2, 2021

Re: How to setup an external command to indent bash script?

On 2021-04-02, Peng Yu wrote:
> On 4/2/21, 'Grant Taylor' via vim_use <vim_use@googlegroups.com> wrote:
> > On 4/2/21 3:52 PM, Peng Yu wrote:
> >> I want to use shfmt to indent bash script in vim instead of using the
> >> default vim indenter. Could anybody show me how to set this up in vim?
> >
> > I would play with the formatprg setting.
> >
> > :help formatprg
> >
> >> shfmt -l -w script.sh
> >
> > Based on my read of the help section, it looks like formatprg expects to
> > read STDIN and write to STDOUT. So you might need some sort of wrapper
> > to read Vim's STDOUT to a file, shfmt said file, then write said file
> > back to Vim's STDIN.
>
> It can take the file from STDIN in this way. The output is to STDOUT.
>
> shfmt /dev/stdin < script.sh
>
> Could you show me the commands (that can be put in ~/.vimrc) to set
> formatprg to `shfmt /dev/stdin` just for a file when it is determined
> as a bash script? I don't want to mess it up for other file types.
>
> >
> > But I suspect that this is eminently doable.

Since you want to indent rather than format, a better choice of
options would be 'equalprg'. See

:help 'equalprg'

The 'equalprg' option is global or local to buffer, so you can set
it locally for the sh filetype and not have to worry about it
affecting other buffers.

You can enable it in your vimrc for sh and bash files like this:

au FileType sh setlocal equalprg=shfmt

Without any arguments, shfmt reads from stdin and writes to stdout,
just what you need here.

This won't automatically indent as you type--you'll have to execute
the = command on a range of lines. See

:help =

For Vim to format automatically as you type, you'd have to use
'indentexpr' and shfmt isn't intended to work in that context.

According to the shfmt project page, https://github.com/mvdan/sh,
someone has written a Vim plugin for shfmt,
https://github.com/z0mbix/vim-shfmt. You may want to check that
out, too.

Regards,
Gary

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20210402234124.GA28724%40phoenix.

Re: How to setup an external command to indent bash script?

On 4/2/21 4:16 PM, Peng Yu wrote:
> It can take the file from STDIN in this way. The output is to STDOUT.

Even better.

> Could you show me the commands...

I don't know as I've not used formatprg in recent memory.

I'd try interactively setting it and testing it with a file.

Quickly poking at things looks like:

:set formatprg=/path/to/shfmt

Give it a try. Please let us know what you find out.



--
Grant. . . .
unix || die

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/8bb7d206-f4c1-0174-56e4-513996070bbd%40spamtrap.tnetconsulting.net.

Re: How to setup an external command to indent bash script?

On 4/2/21, 'Grant Taylor' via vim_use <vim_use@googlegroups.com> wrote:
> On 4/2/21 3:52 PM, Peng Yu wrote:
>> I want to use shfmt to indent bash script in vim instead of using the
>> default vim indenter. Could anybody show me how to set this up in vim?
>
> I would play with the formatprg setting.
>
> :help formatprg
>
>> shfmt -l -w script.sh
>
> Based on my read of the help section, it looks like formatprg expects to
> read STDIN and write to STDOUT. So you might need some sort of wrapper
> to read Vim's STDOUT to a file, shfmt said file, then write said file
> back to Vim's STDIN.

It can take the file from STDIN in this way. The output is to STDOUT.

shfmt /dev/stdin < script.sh

Could you show me the commands (that can be put in ~/.vimrc) to set
formatprg to `shfmt /dev/stdin` just for a file when it is determined
as a bash script? I don't want to mess it up for other file types.

>
> But I suspect that this is eminently doable.
>
>
>
> --
> Grant. . . .
> unix || die
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "vim_use" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/vim_use/D1sH4gr3LZA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> vim_use+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/vim_use/ed861df1-0a61-cae5-dfd9-8c576d664e92%40spamtrap.tnetconsulting.net.
>


--
Regards,
Peng

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CABrM6w%3DsqwwBBgOavf_Ns7bDfJi%3D2B0CWcovOVE31_Myo_iCYg%40mail.gmail.com.

Re: How to setup an external command to indent bash script?

On 4/2/21 3:52 PM, Peng Yu wrote:
> I want to use shfmt to indent bash script in vim instead of using the
> default vim indenter. Could anybody show me how to set this up in vim?

I would play with the formatprg setting.

:help formatprg

> shfmt -l -w script.sh

Based on my read of the help section, it looks like formatprg expects to
read STDIN and write to STDOUT. So you might need some sort of wrapper
to read Vim's STDOUT to a file, shfmt said file, then write said file
back to Vim's STDIN.

But I suspect that this is eminently doable.



--
Grant. . . .
unix || die

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/ed861df1-0a61-cae5-dfd9-8c576d664e92%40spamtrap.tnetconsulting.net.

How to setup an external command to indent bash script?

I want to use shfmt to indent bash script in vim instead of using the
default vim indenter. Could anybody show me how to set this up in vim?

https://github.com/mvdan/sh#shfmt

shfmt -l -w script.sh

--
Regards,
Peng

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CABrM6wnqDpnBdTnThC-Rv9HB2-WzLWqmgPgi3zFHyZ%3D862s_0g%40mail.gmail.com.

Re: VimDIFF - ONLY on the first field of two files ?

rwm,


On 2021-04-03 00:07, rwmit...@gmail.com wrote:
> 'so' would be short for 'source'


Ah . . of course . . thanks!

Phil.


> On Friday, April 2, 2021 at 7:55:16 AM UTC-4 Philip Rhoades wrote:
>
>> Christian,
>>
>> I have installed your plugin, set diffopt in .vimrc and all the
>> tests
>> work and
>>
>> :EnhancedDiff histogram
>>
>> command from your web page works but I can't get
>>
>> EnhancedDiffIgnorePat ^[^;]\+;
>>
>> or
>>
>> EnhancedDiffIgnorePat ;[^;]\+$
>>
>> to work with some manually created files like on your web page.
>>
>> I tried looking at test.sh but I don't understand:
>>
>> -c "if filereadable('vimrc') | so vimrc | endif'"
>>
>> - what is "so"? - and there appears to be an unpaired single quote?
>>
>> Any help appreciated!
>>
>> Thanks,
>>
>> Phil.
>>
>> On 2021-04-02 07:22, 'Philip Rhoades' via vim_use wrote:
>>> Christian, Charles, Bram,
>>>
>>> Thanks so much for your responses! - they are much appreciated!
>>>
>>> Phil.
>>>
>>>
>>> On 2021-04-02 04:01, Christian Brabandt wrote:
>>>> On Do, 01 Apr 2021, 'Philip Rhoades' via vim_use wrote:
>>>>
>>>>> People,
>>>>>
>>>>> I live in vim and therefore use vimdiff most of the time for my
>> needs
>>>>> but I
>>>>> have a use case where I only want to diff on the FIRST field of
>> two
>>>>> files ie
>>>>> the files have lines that look like:
>>>>>
>>>>> [dir|file]name | [D|F] | mtime
>>>>>
>>>>> and I need to be able to have vimdiff only working on the
>>>>> [dir|file]name and
>>>>> ignore the rest of the line - is this possible somehow?
>>>>>
>>>>> Thanks,
>>>>
>>>> Have a look at my plugin:
>>>> https://github.com/chrisbra/vim-diff-enhanced
>>>>
>>>> The README.md has an example of that.
>>>>
>>>> Best,
>>>> Christian
>>>> --
>>>> So kam ich unter die Deutschen. Ich forderte nicht viel und war
>>>> gefaßt noch weniger zu finden.
>>>> -- Johann Christian Friedrich Hölderlin
>>>>
>>>> --
>>>
>>> --
>>> Philip Rhoades
>>>
>>> PO Box 896
>>> Cowra NSW 2794
>>> Australia
>>> E-mail: ph...@pricom.com.au
>>>
>>> --
>>
>> --
>> Philip Rhoades
>>
>> PO Box 896
>> Cowra NSW 2794
>> Australia
>> E-mail: ph...@pricom.com.au
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google
> Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to vim_use+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/vim_use/78f064a0-7f2e-4738-80fb-e55295375889n%40googlegroups.com
> [1].
>
>
> Links:
> ------
> [1]
> https://groups.google.com/d/msgid/vim_use/78f064a0-7f2e-4738-80fb-e55295375889n%40googlegroups.com?utm_medium=email&utm_source=footer

--
Philip Rhoades

PO Box 896
Cowra NSW 2794
Australia
E-mail: phil@pricom.com.au

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/eebed565f17d82ccf26827ad396f4c22%40pricom.com.au.

How to have the spell checker ignoring URLs and acronyms

Dear Vim Experts,
bored to have acronyms and URLs marked as errors in my LaTeX files I have
looked for a solution. Here

http://www.panozzaj.com/blog/2016/03/21/ignore-urls-and-acroynms-while-spell-checking-vim/

Suggests to add

syn match UrlNoSpell '\w\+:\/\/[^[:space:]]\+' contains=@NoSpell
syn match AcronymNoSpell '\<\(\u\|\d\)\{3,}s\?\>' contains=@NoSpell

in ~/.vim/after/tex.vim but it doesn't seem to work.

:scriptnames lists the file correctly loaded

226: /usr/share/vim/vim82/ftplugin/tex.vim
227: /usr/share/vim/vim82/ftplugin/plaintex.vim
228: /usr/share/vim/vim82/ftplugin/initex.vim
229: ~/.vim/bundle/vim-polyglot/after/ftplugin/tex.vim
230: /usr/share/vim/vim82/syntax/tex.vim
231: ~/.vim/bundle/vim-polyglot/after/syntax/tex.vim
232: ~/.vim/after/syntax/tex.vim

But it seems ignored and all my acronyms are still marked as errors.

I've already commented out all the plugins and still they are ignored.

What am I doing wrong?

I'm using Vim 8.2 on a linux box, Vundle is my plugin manager and I've
vim-latex installed.

Any help is welcome. Thank you.

Walter

PS. Note that to add all the acronyms to the list of known words is not a
feasible option.

--

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/4d485454-42cc-50aa-6685-ca8cd94e8c67%40di.unimi.it.