nvim-neorg / neorg

Modernity meets insane extensibility. The future of organizing your life in Neovim.
GNU General Public License v3.0
6.45k stars 214 forks source link

generate-workspace-summary should ignore hidden directories #1558

Open Anrock opened 2 months ago

Anrock commented 2 months ago

Prerequisites

Neovim Version

NVIM v0.10.0 Build type: Release LuaJIT 2.1.1716656478 Run "nvim -V1 -v" for more info

Neorg setup

require('neorg').setup({
  load = {
    ["core.defaults"] = {},
    ["core.dirman"] = {
      config = {
        workspaces = {
          main = "~/Norg",
        },
        default_workspace = "main",
      },
    },
    ["core.qol.toc"] = {},
    ["core.summary"] = {},
    ["core.completion"] = {
      config = {
        engine = "nvim-cmp",
      },
    },
    ["core.concealer"] = {
      config = {
        icons = {
          todo = {
            done = { icon = "✓" },
            pending = { icon = "▶" },
            uncertain = { icon = "⁇" },
            on_hold = { icon = "⏸" },
            cancelled = { icon = "⏏" },
            undone = { icon = "⏹" },

          },
        },
      },
    },
    ["core.export"] = {},
  }
})

Actual behavior

Running :Neorg generate-workspace-summary includes files from hidden directories

Expected behavior

generate-workspace-summary should not include files from hidden directories or have an option to ignore them.

Steps to reproduce

  1. Create a hidden directory in neorg workspace, for example mkdir .hidden
  2. Execute :Neorg generate-workspace-summary

Potentially conflicting plugins

No response

Other information

I'm using Syncthing to sync my notes with Syncthing option to keep N previous versions of each file which are stored in .stversions directory in root of workspace folder. I guess it's pretty common setup among neorg users.

There are related tickets #953 #972 to allow altering generate-workspace-summary behaviour but they're about richer customization options. While this ticket can be resolved by implementing requested functionality from linked tickets I think that this ticket can be resolved with less effort and still provide benefits for end users.

Help

Yes, but I don't know how to start. I would need guidance (check question below)

Implementation help

Architecture guidance of where the change should be implemented and how to start and code review afterwards.

max397574 commented 2 months ago

for implementation help either you filter the files here https://github.com/nvim-neorg/neorg/blob/09deca2ba5adcf1a729d1e3abf64438d7ce4d7ee/lua/neorg/modules/core/summary/module.lua#L338

or add an option for this to dirman module (which is responsible to get these files) here https://github.com/nvim-neorg/neorg/blob/09deca2ba5adcf1a729d1e3abf64438d7ce4d7ee/lua/neorg/modules/core/dirman/module.lua#L389

second option would perhaps be preferred because it could also be used in different modules in the future

just open a pr in this repo and it will be reviewed by one of the maintainers

Anrock commented 2 months ago

@max397574 I never did nvim plugin development before. What would be a convenient way to plug local copy of neorg into my config so I can hack and test it right in my neovim? I'm using rocks.

benlubas commented 2 months ago

@Anrock I'm not a rocks user myself, I've tried it though. There's a plugin called rocks-dev that will let you provide a path to a local plugin. You can use that to point at a locally cloned version of the neorg repo.

For general workflow I'd recommend keeping the neorg lua files you're working on open in one nvim instance, and then testing your changes in a second instance (using tmux or your terminal emulators tabs/panes makes this really easy to do).

As far as tooling, you'll want the lua language server, and neorg uses nix shells to super charge the language server (it will give you much better completions and type hints if you're in the nix shell). There's a direnv hook, so you can use that, or you can just install nix, enable flakes and the nix command, and run nix develop from the repo root before you start neovim.

and then we use stylua for formatting lua code.

Nix shell is optional though, if you're unfamiliar with it.


another hint/tip. we're using Pathlib.nvim in this project, so file paths are passed around mainly as PathlibPaths and there's a helpful method: PathlibPath:is_hidden()

Anrock commented 2 months ago

Alright, seems like there is a big layer of things to learn before getting to lua hacking. I'll try to tackle it when I have some free time.