max397574/startup.nvim

Cannot navigate to folded headings with keyboard

enderger opened this issue · 12 comments

Describe the bug
Currently, folded sections cannot be reached using keyboard navigation

Checklist

  • Checked if issue already exists
  • I'm using the latest startup.nvim version

To Reproduce
Steps to reproduce the behavior:

  1. Enable folding on any section
  2. Attempt to navigate to said section using the keyboard
  3. See the problem

Expected behavior
The header of a folded section should be accessible using the keyboard in order to unfold it. This currently requires the mouse.

Additional Info
Config
Relevant section, sorry it's in Fennel. The Lua generated from Hotpot tends to be arcane

; Greet screen & sessions, since they go in tandem

;; Packages
(local {: register-packages} (require :util.packages))
(register-packages
  [:startup-nvim/startup.nvim
   :Shatur/neovim-session-manager])

;; Requires
(local startup (require :startup))
(local sessions (require :session_manager))
(local sessions-config (require :session_manager.config))

;; Startup
(local startup-config
  {:options
   {:mapping_keys true
    :cursor_column 1
    :disable_statuslines false
    :paddings [1 2 1 2 1]}
   
   :mappings
   {:execute_command :<CR>
    :open_file :e
    :open_file_split :E
    :open_section :<TAB>}

    :header
    {:type :text
     :align :center
     :fold_section false
     :highlight :Statement
     :content (. (require :startup.headers) :neovim_logo_header)}

    :commands-header
    {:type :text
     :align :center
     :fold_section false
     :highlight :String
     :content ["Commands"]}

    :commands
    {:type :mapping
     :title "Commands"
     :margin 5
     :align :center
     :fold_section false
     :highlight :String
     :content
     ; TODO keys
     [["\u{e5ff} Goto file" "lua require('lir.float').init()" :\ff]
      ["\u{f15c} New file" "lua require('startup').new_file()" :\fn]
      ["\u{f0e2} Restore session (last)" "SessionManager load_last_session" :\sl]
      ["\u{f0e2} Restore session" "SessionManager load_session" :\ss]]}

   :old-files-header
   {:type :text
    :align :center
    :fold_section false
    :highlight :TSString
    :content ["Old Files"]}

   :old-files
   {:type :oldfiles
    :oldfiles_directory true
    :align :center
    :title "Old Files"
    :fold_section false
    :margin 5
    :highlight :TSString
    :content {}
    :oldfiles_amount 5}

   :parts
   [:header :commands-header :commands :old-files-header :old-files]})

;; Session manager
(local session-config
  {:sessions_dir (.. (vim.fn.stdpath :data) :/sessions)
   :autoload_mode sessions-config.AutoloadMode.Disabled})

;; Setup
(fn setup []
  (sessions.setup session-config)
  (startup.setup startup-config))

{: setup}

Neovim Version
NVIM v0.7.0-dev

could you convert this somehow to lua?
I don't understand fennel and can't tell why this doesn't work for you.
It works for me

Alright, I'll include a minimal example (I am an idiot and apparently forgot that I did a workaround in this config. Sorry about that!)

-- Greet screen & sessions, since they go in tandem
local M = {}

-- Packages
--- This is a paq-based helper module designed to allow packages to be used in multiple files
local packages = require "util.packages"
packages["register-packages"] {
  "startup-nvim/startup.nvim"
}

-- Requires
local startup = require "startup"

-- Startup
local startup_config = {
  section_a = {
    type = "text",
    title = "Try to select me with jk or <C-n>",
    margin = 5,
    align = "center",
    fold_section = true,
    highlight = "String",
    content = {"Lorem ipsum dolor sit amet"},
  },
  parts = {"section_a"},
}

-- Setup
--- My config uses a module system which automatically runs this after syncing packages
function M.setup()
  startup.setup(startup_config)
end

return M

okay I think I found the problem

just pushed a fix
can you confirm it's fixed @enderger ?

just pushed a fix can you confirm it's fixed @enderger ?

Yep, it's working as intended. Thanks!

Actually, it seems that now moving past the last header causes an error.

can you send the error?

and an example

This is the error
image

It appears to happen when using space to navigate downwards (maybe others) over a folded heading.

EDIT: showed correct error

I think I found the problem
let me push a fix rq

this should be fixed now
can you confirm? @enderger

Seems fixed, thanks!