Some newbie questions about nvim

Hi internet! :wave: ,

So i’m a newbie to neovim (full disclaimer), I have of course tried to read the friendly manual where it’s simple to do so! Having a blast setting up neovim at the moment, and things are ramping up in speed as I get used to the vim motions. :tada: But I have a few Q’s that don’t seem to have an immediately searchable answer.

Q1

I can see the keymaps currently set with :map (or even more conveniently through Telescope, with telescope.builtin.keymap… BUT… why is this list incomplete?! I want to see all the maps… not just the ones set by me or a plugin, seems like a lot is missing to me from this list, is this correct?

for example, i expect to see basic vim motion keys in the keymap file as well:

Q2

Is there a good way to see a trace of what happened when I launch nvim ? I can put print("hello from file.lua") inside all my different lua files, but is this the best way? (I’m not majorly disappointed in this, it works, and it limits the output to what I print myself… so in some ways it’s great, but is this what more experienced nvimers do when the encounter some tricky behaviour?)

Q3

I’m really enjoying Telescope, but is there a guide on how to customize the file preview for directories? Currently the preview shows me what’s essentially ls -l, and that’s a bit verbose for my liking (for most of my use cases), I have dyslexia, so eye-scanning past all the user groups, file mode/ACL info is a bit taxing when I just want the filenames + maybe the file size. Any pointers for customizing such? :sweat_smile: (maybe I have to make a custom “picker” ? :thinking: )

Update: I have found a thread discussing this exact kind of customization: See just filenames when peeking into folder · Issue #267 · nvim-telescope/telescope-file-browser.nvim · GitHub

For Q2, how about nvim --staruptime out.log?

1 Like

:clap: This is exactly what I want! (for Q2), i realize i should probably not have bundled several Q’s into one, but i’ll mark this one as the “solution” to this.

1 Like

For Q1, it’s not as easy as it should be. The default commands/maps are listed in $VIMRUNTIME/doc/index.txt, but user/plugin stuff is dynamic so it’s only available from :map or :command. I’m currently working on a lighter/dumber/simpler version of telescope.nvim (just factoring out some stuff I have in my init.lua) which has this, for commands:

-- Generate list of (most?) builtin and user/plugin-defined commands.
function list_commands(sep)
    -- sep: string, separator to insert between file names.
    local cmdlist = {}
    for _, line in pairs(fn.readfile(fn.expand("$VIMRUNTIME/doc/index.txt", 1))) do
        local match = line:match("^|:(%w+)|")
        if match then table.insert(cmdlist, match) end
    end

    -- Get user/plugin defined commands from `:command`.
    local com = fn.split(fn.execute("command"), [[\n]])
    for i, line in pairs(com) do
        repeat
            if i == 1 then break end -- First element is 'Name' from :command header.
            local match = line:match("^%W%W%W%W(%w+)%s")
            if match then table.insert(cmdlist, match) end
            break
        until true
    end
    return table.concat(cmdlist, sep)
end

Might be able to do something similar for mappings. I’m with you: I hate that we can’t search in the :map output window.

2 Likes

Well I’ve more or less wrapped it up, at least for the fzf backend. Does everything I need and nothing too much more: GitHub - adigitoleo/quark.nvim: [MIRROR] Fuzzy pickers to open files, switch buffers and execute ex-commands. Doesn’t list all the mappings but does list all commands (including plugin stuff) in the (optional) fuzzy command menu. Anyway, maybe telescope is more of what you want/need.

1 Like

neat! For now I think it’s Telescope I want, at least I already committed some time to it (using the keymap search a lot, along with the file-browser extension + harpoon2 to switch between files quickly :raised_hands: ).

It’s really cool that there’s such a vibrant community of lua script projects just popping up left and right. Feeling the hackability of this vs something like vscode (where I came from).

1 Like