Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sticky scroll doesn't work when not indenting YAML lists #14

Open
k8ieone opened this issue Aug 23, 2024 · 1 comment
Open

Sticky scroll doesn't work when not indenting YAML lists #14

k8ieone opened this issue Aug 23, 2024 · 1 comment

Comments

@k8ieone
Copy link

k8ieone commented Aug 23, 2024

In YAML lists can be optionally indented. In case where the list is indented, the plugin works as expected. When there is no list indent, it ignores the list.

Without indents (doesn't work):

list:
- item1
- item2

With indents (works):

list:
  - item1
  - item2
@jgmdev
Copy link
Member

jgmdev commented Aug 25, 2024

To support this you can add a custom get level function by adding the following to your user module:

core.add_thread(function()

  if config.plugins.sticky_scroll then
    local StickyScroll = require "plugins.sticky_scroll"
    config.plugins.sticky_scroll.filetype_overrides["YAML"] = function(doc, line)
      if string.sub(doc.lines[line], 1, 1) == "-" then
        local _, indent_size = doc:get_indent_info()
        return indent_size
      end
      return StickyScroll.get_level_default(doc, line)
    end
  end

end)

Note

This will not take into account previously badly indented lines, so lines that start with - will always get treated as indented only once.

Not sure if this is material to add on the plugin it self on this list https://github.com/pragtical/plugins/blob/master/plugins/sticky_scroll.lua#L19-L28 If you think so feel free to send a PR with the addition and version bump of plugin on manifest file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants