scnvim icon indicating copy to clipboard operation
scnvim copied to clipboard

[FR] Wrap text in post window

Open madskjeldgaard opened this issue 6 years ago • 10 comments

Text in the post window goes beyond the window, making it a bit hard to read, without resizing. This is a common problem in the SCIDE as well. It would be nice if there was a way to make this text wrap automatically according to screen size. Maybe this is already possible via som nvim magic that I didn't notice? I dunno, otherwise it's an idea for a feature!

madskjeldgaard avatar May 11 '19 15:05 madskjeldgaard

Yes, this is possible. The post window actually have its own filetype called scnvim. So you could make this happen by:

  1. Creating an autocmd in you vimrc/init.vim autocmd FileType scnvim setlocal wrap
  2. Create a file in your runtimepath (usually .config/nvim) nvim/after/ftplugin/scnvim.vim and add your settings in that file e.g. setlocal wrap

davidgranstrom avatar May 12 '19 12:05 davidgranstrom

This is also something that we should add to the scnvim (vim) documentation. Maybe we could have a "FAQ" section in the docs?

davidgranstrom avatar May 12 '19 12:05 davidgranstrom

Sounds perfect. I'll try your idea out – it looks like the stuff!

madskjeldgaard avatar May 12 '19 12:05 madskjeldgaard

Okay I tried 1 and it worked perfectly!

madskjeldgaard avatar May 12 '19 12:05 madskjeldgaard

Reopening this, as I can't seem to make it work any longer. At some point in the not too distant past, none of the two proposed solutions take any effect. Could there be some runtime voodoo that has changed at some point in the last few months? I have tried both of the above strategies, and none of them work. The output of :verbose setlocal wrap? is

nowrap
        Last set from ~/.local/share/nvim/site/pack/packer/start/scnvim/ftplugin/scnvim.vim line 5

Edit: I'm on nvim 0.5

kflak avatar Nov 26 '21 22:11 kflak

OK, it seems this might be connected with packer and how this loads stuff. If I follow the lead of @madskjeldgaard and do this:

        use {
            'davidgranstrom/scnvim',
            config = function()
               vim.cmd[[autocmd filetype scnvim setlocal wrap]]
            end,
        }

things work as they should.

kflak avatar Nov 27 '21 11:11 kflak

This approach seems no longer to work. Can't quite pinpoint when it stopped working...

kflak avatar Jul 22 '22 14:07 kflak

This seems to be an issue again

madskjeldgaard avatar Jul 27 '22 13:07 madskjeldgaard

@kflak @madskjeldgaard Got a chance to take a look at this just now. I've found the reason, but I don't have a clear solution just yet. The bug was introduced when I added the on_open action to the post window, the action will be applied after the autocmd is triggered so in effect it will overwrite the value of setlocal wrap in the autocmd. I need some more time to investigate, but you can use the built-in actions as a work around for now:

require('scnvim.postwin').on_open:append(function()
  vim.opt_local.wrap = true
end)

davidgranstrom avatar Aug 03 '22 14:08 davidgranstrom

Works beautifully! Thanks for the (albeit temporary) fix.

kflak avatar Aug 03 '22 15:08 kflak