Skip to content

Changing options at runtime has no effect #33

@tuurep

Description

@tuurep

In #31 I noticed:

While testing this I noticed that it's not possible to use these to modify the behavior at runtime like:

  • I have a viewer open
  • I do :let g:vivify_auto_scroll = 0
  • Would expect that viewer to stop auto-scrolling, but this didn't work

The settings would be much more useful if they could be used to programmatically change the viewer behavior, in my opinion.

At first I thought it would be easy to change like this:

diff --git a/plugin/vivify.vim b/plugin/vivify.vim
index f9fb6c7..d4e7fac 100644
--- a/plugin/vivify.vim
+++ b/plugin/vivify.vim
@@ -3,9 +3,6 @@ if exists("g:loaded_vivify")
 endif
 let g:loaded_vivify = 1

-let s:vivify_instant_refresh = get(g:, "vivify_instant_refresh", 1)
-let s:vivify_auto_scroll = get(g:, "vivify_auto_scroll", 1)
-
 let s:filetype_match_str = 'markdown'
 if exists("g:vivify_filetypes")
     call add(g:vivify_filetypes, s:filetype_match_str)
@@ -19,14 +16,14 @@ endfunction
 function! s:init()
     augroup vivify_sync
         autocmd!
-        if s:vivify_instant_refresh
+        if get(g:, "vivify_instant_refresh", 1)
             autocmd TextChanged,TextChangedI *
                 \ if s:is_vivify_filetype(&filetype) | call vivify#sync_content() | endif
         else
             autocmd CursorHold,CursorHoldI *
                 \ if s:is_vivify_filetype(&filetype) | call vivify#sync_content() | endif
         endif
-        if s:vivify_auto_scroll
+        if get(g:, "vivify_auto_scroll", 1)
             autocmd CursorMoved,CursorMovedI *
                 \ if s:is_vivify_filetype(&filetype) | call vivify#sync_cursor() | endif
         endif

But surprised to see it didn't work. Maybe it has to do with it being inside an autocmd?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions