Threads for alexdzyoba

  1. 19

    This article is insanely good: easy to ready, actual examples & situations. Please write some more :)

    1. 12

      Thanks, that means a lot for me as an author.

    1. 17

      One note with the “Passing request to Consul services” section: when you use a DNS name in proxy_pass, that name is only ever resolved at startup. If the IP address the domain name points to could ever change you should define an upstream. Nginx only does normal DNS TTL / refresh in upstreams.

      1. 6

        This is rarely mentioned and you learn it the hard way. @alexdzyoba I think it’s a good thing to add to your great article :)

        1. 4

          I have previously documented a workaround for this (although, really the open source version should just support this):

          1. 1

            Ah yes, I had seen the variable hack once before! Both the variable hack and upstreams need the resolver set, so both will do the trick.

          2. 2

            Thanks, everyone! I’ve updated my post. Put the link to this thread and the post by Tenzer.

            1. 2

              Thanks for pointing out! But what about “valid” option in resolver directive? It should control the TTL for DNS cache.

              1. 2

                It does, but proxy_pass doesn’t use DNS TTL, it only ever resolves once, unless you use a variable or an upstream. The Nginx docs aren’t very clear, but the resolver setting says it’s used for upstreams.

            1. 6

              For over 10 years I’ve been a very ardent (some would say zealous) supporter of (n(eo))vim, carefully tweaking and updating my configuration to be as barebones or as feature-full as I needed and desired, and spreading the gospel of Vim to all those that would listen.

              About 6 months ago I tried out the vimagit plugin, which I found immediately useful. I then realized that this plugin was based off of the emacs magit package, which intrigued me further, and that sent me down a rabbit hole of trying out emacs with evil-mode (gasp! horror!).

              I’ve been a (spac)emacs+evil user since that day. It combines all of the muscle memory that I know and love (complex word motions, edit sequences, etc.) from vim, and gives me a TUI-based editor that has all all of the project/IDE based functionality that I had always spent far too much time configuring and fighting against in vim. I just don’t have the energy for that anymore.

              If you’re like me and love vim, and are looking to “revamp” your setup like the post describes, give Spacemacs a try. There are others, too (e.g. doom-emacs), and there are of course the DIY build-it-yourself setups that you can tinker with endlessly, but I was completely astounded by how intuitive and how short of a learning curve spacemacs with evil mode was.

              1. 2

                Yes, I saw magit from my colleague and that’s how I discovered vimagit. I’ve heard good things about evil mode but I’m not ready to try yet, though you’re sound convincing.

                1. 1

                  The emacs magit package was the primary reason I tried the switch. After watching a few instructional videos & reading some documentation, I had to try it out. It’s every bit as good as I had hoped for.

                  Using emacs+evil with some project-level plugins like helm for autocompletion and projectile for navigation has been fantastic. It took me a few days to get used to some of the different key combinations to navigate around, but that was quite minimal in the grand scheme of things.

                2. 2

                  One of these days I’m gonna bite the bullet and try out emacs. I have so much invested into my vim environment that it scares me to leave….

                1. 12

                  Are we talking vim trix? Oh my god I love talking vim trix.

                  • Neovim has an integrated terminal. One thing I like doing is making an autocommand that, whenever I save the file, runs a specific test suite in the terminal. It’s like a lightweight test runner.

                  • Another Neovim thing: set inccommand=nosplit. This shows you realtime what an :s command will do, and they’re working on extending it to normal and g.

                  • One thing you might not have realized about the undo: it’s not a list of changes, it’s a tree. You can navigate it both chronologically and changewise and jump between different branches. I use the mbbill//undotree plugin to visualize it. Absolutely fantastic.

                  • kshenoy/vim-signature shows marks on the sidebar and lets you add marks like ! or ? to your file.

                  I’ve been doing some weird exobrain experiments too, but those aren’t anywhere near ready to share yet =)

                  1. 3

                    I haven’t found a good use for embedded terminal but I think that’s because I use i3 and terminals everywhere.

                    Could you elaborate on your terminal case? Maybe share the autocommand?

                  1. 10

                    Good article; I have a few nitpicks :-)

                    autocmd FileType yaml set tabstop=2 shiftwidth=2

                    you should never use set from an autocmd, as that will affect all buffers, not just the YAML one, so if you have a YAML and Python buffer open then both will be affected; yikes!

                    Always use setlocal (or setl for short) if you want to set something specific to the bufer.

                    In addition, it’s good practice to keep autocommands in an augroup:

                    augroup my-yaml
                        autocmd FileType yaml set tabstop=2 shiftwidth=2
                    augroup end

                    otherwise reloading the file means set will get run twice (try it: :source ~/.vim/vimrc | au FileType yaml) For this set (or setl) command it’s not a huge deal, but for other stuff there’s a large performance penalty. Also see: Why should I use augroup?.

                     source ~/.vimrc

                    You can use ~/.vim/vimrc as well; that has worked since Vim 7.3.something (a long time). This way all your vim files are in one directory.

                    I agree the undo history is very useful, but it’s annoying that it it’s easy to accidentally use it. I wrote a little plugin which, IMHO, improves the UX of it a lot:

                    you also need to create that undodir manually, otherwise it won’t work. This is what I have:

                    set backupdir=$HOME/.vim/tmp/backup    " Set/create directory to keep backup, swap, and undo files.
                    set directory=$HOME/.vim/tmp/swap
                    set viewdir=$HOME/.vim/tmp/view
                    set undodir=$HOME/.vim/tmp/undo
                    if !isdirectory(&backupdir) | call mkdir(&backupdir, 'p', 0700) | endif
                    if !isdirectory(&directory) | call mkdir(&directory, 'p', 0700) | endif
                    if !isdirectory(&viewdir)   | call mkdir(&viewdir, 'p', 0700)   | endif
                    if !isdirectory(&undodir)   | call mkdir(&undodir, 'p', 0700)   | endif

                    Newer Vim versions won’t error out if the directory already exists, so I suppose this can be a little simplified now.

                    For Insert mode completion I think the future is Language Server Protocol (LSP); this way we’ll have one LSP client for Vim that will work for everything (provided there is a lsp). I am currently using vim-lsc, and it works very well. There are many more options (ALE also includes an LSP client, for example).

                    At any rate, here’s my ~/.vim directory, in case you’re interested:

                    1. 3

                      you also need to create that undodir manually, otherwise it won’t work.

                      No, the article is about Neovim, which automatically creates ‘undodir’ and ‘directory’ (swapfile directory) if needed. But not ‘backupdir’.

                      if !isdirectory(&directory) | call mkdir(&directory, ‘p’, 0700) | endif

                      mkdir(&directory) (and mkdir(&undodir), etc.) isn’t advisable for most users, because those options are comma-separated lists.

                      1. 2

                        I didn’t want to emphasize on Neovim and I believe most of the things I use can be applied to Vim.

                        P.S. Thanks for Neovim!

                      2. 2

                        Thanks for the nitpicks, I’ll definitely check augroup and setlocal.

                      1. 3

                        IMO, Vim help is the most underestimated feature of Vim

                        I have been using vi/vim since .. 1999(?) and it took me a looong time to get beyond beginner. The fact that we still have to learn vim tips by sharing configs and articles speaks to how poorly the documentation is presented. My primary sources for going beyond beginner were vimcasts and more recently greg hurrell’s screencasts.

                        It’s fine that help is built in for powerusers, but in a typical terminal window, :help gets half the width or height. Good luck reading new material like that while trying it out. I have never been able to find an up-to-date vim documentation in HTML format. I just now discovered that neovim has documentation available in browsable HTML format.

                        Also, I cannot find Vim changelogs anywhere. I learned about packs and async by accident. I still don’t know how to use async. Looking at, I see the latest news is from 2017, so I assume nothing worthwhile has happened since then.

                        1. 5

                          Looking at, I see the latest news is from 2017, so I assume nothing worthwhile has happened since then.

                          Plenty has happened. Newsletter is coming soon.

                          There’s also a releases page that makes it pretty clear that several major releases have occurred, not to mention the pulse page.

                          1. 4


                            You will probably want to include releases with changelogs under the news headline. For example, on, it only takes one click from the front page to get a list of changes in the most recent release.

                          2. 4

                            I agree that Vim documentation is hard for newcomers. But for me it was invaluable.

                            Also, I’ve used as up-to-date online doc. Currently it’s built for Vim 8.1.

                            1. 2

                              Also, I cannot find Vim changelogs anywhere. I learned about packs and async by accident.

                              The Vim changelogs are within its help system, linked from within the Versions section in the top-level help. The most recent file describing changes is at :help version8.txt – it describes packages, async I/O, and more in its New Features section. (Note that Vim’s async implementation works differently from NeoVim’s.)

                            1. 1

                              I like the article but a lot of the screenshots are broken :(

                              1. 2

                                Forgot to commit them, it’s fixed now. Thanks for pointing!

                              1. 4

                                Nice article.

                                Beware that InstrumentHandler is deprecated, and the functions in are the recommend replacement.

                                Splitting out latency with a success/failure label is also not recommended as a) if you have only successes or only failures, your queries break and b) users tend to create graphs of only success latency and miss all those slow failing requests. Separate success and failure metrics are better, and also easier to work with in PromQL.

                                1. 3

                                  Thanks for the suggestions Brian! promhttp package contains even more nice things like in flight requests. Maybe we should explicitly say ok in docs that InstrumentHandler is deprecated in favor of promhttp types? I don’t mind making a PR in docs