davidgranstrom / scnvim

Neovim frontend for SuperCollider.
GNU General Public License v3.0
204 stars 28 forks source link

[FR] Wrap text in post window #29

Open madskjeldgaard opened 5 years ago

madskjeldgaard commented 5 years ago

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!

davidgranstrom commented 5 years ago

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 commented 5 years ago

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

madskjeldgaard commented 5 years ago

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

madskjeldgaard commented 5 years ago

Okay I tried 1 and it worked perfectly!

kflak commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

madskjeldgaard commented 2 years ago

This seems to be an issue again

davidgranstrom commented 2 years ago

@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)
kflak commented 2 years ago

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