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

Add an example of how to configure the plugin in lua #54

Closed
Andrew15-5 opened this issue Nov 11, 2023 · 6 comments
Closed

Add an example of how to configure the plugin in lua #54

Andrew15-5 opened this issue Nov 11, 2023 · 6 comments

Comments

@Andrew15-5
Copy link

Andrew15-5 commented Nov 11, 2023

Everything is great so far. But some keymap are either don't work or just a bad UX for me, so I tried to customize stuff. Unfortunately nothing works. And the most annoying part, that I think I did everything right, but there is no example that I can compare to or copy+paste to see if/how it works. There are only each and every part of a configuration spread across the readme file. That's why I spend about an hour trying many different way to configure the plugin through lazy.nvim opts or config and it just doesn't work.

And I'm supposed to be a "smart" guy after knowing how to do stuff in Lua, how lazy.nvim config spec works, configuring NvChad and generally feeling pretty good (not great) about knowing how to configure Neovim things in Lua. Sometimes I do skip something from the doc which has a plain answer, but I don't think this is the case (I hope so).

Here is what I consider the almost 100% correct config:

lazy.nvim
  {
    "mikesmithgh/kitty-scrollback.nvim",
    enabled = true,
    lazy = true,
    cmd = { "KittyScrollbackGenerateKittens", "KittyScrollbackCheckHealth" },
    event = { "User KittyScrollbackLaunch" },
    version = "^2.0.0",
    config = function()
      require("kitty-scrollback").setup {
        custom = function()
          return {
            callbacks = {
              after_ready = function()
                vim.keymap.set("n", "q", ":q<CR>")
                vim.cmd [[quit]]
              end,
            },
          }
        end,
      }
    end,
  },
kitty.conf
allow_remote_control yes
listen_on unix:/tmp/kitty
shell_integration enabled
action_alias kitty_scrollback_nvim kitten ~/.local/share/nvim/lazy/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py
map kitty_mod+h kitty_scrollback_nvim --config custom
map kitty_mod+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output
mouse_map kitty_mod+right press ungrabbed combine : mouse_select_command_output : kitty_scrollback_nvim --config ksb_builtin_last_visited_cmd_output

This config should both add q keymap and exit nvim. Neither is done after Ctrl+Shift+h.

@mikesmithgh
Copy link
Owner

Hey thanks for the feedback, I am wondering if you may need to use the flag --no-nvim-args. I recently answered something similar here #48. I just gave this a quick read since I am away at the moment, I'll circle back and review with more details. I agree it is a lot of config and not quite obvious, I am trying to improve on that 👍

@Andrew15-5
Copy link
Author

Yes, this did help. Thanks. But I again had to build my simple config like a constructor.

Now, the problem is that all the plugins and all the custom Lua configs are enabled. By default, it's all disabled. I would assume that there is a switch of some sort or a way of pasting some more configuration to disable other plugins or something. I didn't see this in the doc either.

So there should be 2 examples (or if they are similar, then only a small comment or note about the differences):

  • example how to make and apply/use custom config that will expand the default kitty-scrollback.nvim behavior
  • as above, but that will expand the configured nvim behavior (all custom settings/plugins enabled).

To give an idea, I want to add a couple of additional keymap to the default kitty-scrollback.nvim behavior + override/remove already set keymaps + I want to at least have move/jump plugins enabled (leap.nvim).

@mikesmithgh
Copy link
Owner

@Andrew15-5 gotcha, I have #52 as well which sounds similar.

Right now, I am thinking of two approaches that could let you use a custom config specific to kitty-scrollback.nvim

--nvim-args -u .lua

action_alias kitty_scrollback_nvim kitten /Users/mike/gitrepos/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --nvim-args -u /Users/mike/.config/nvim/ksb-init.lua
  • add you config to /Users/mike/.config/nvim/ksb-init.lua
  • this will only load what is defined in nvim/ksb-init.lua

or

NVIM_APPNAME

action_alias kitty_scrollback_nvim kitten /Users/mike/gitrepos/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --env NVIM_APPNAME=nvim-ksb --no-nvim-args
  • add you config to /Users/mike/.config/nvim-ksb/init.lua
  • this will only load what is defined in nvim-ksb/init.lua

This way you can keep your kitty-scrollback.nvim separate from your normal nvim config.

I think this covers your first bullet.

example how to make and apply/use custom config that will expand the default kitty-scrollback.nvim behavior

For the second bullet,

as above, but that will expand the configured nvim behavior (all custom settings/plugins enabled

It would be something like

action_alias kitty_scrollback_nvim kitten /Users/mike/gitrepos/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --config custom --no-nvim-args

and it would use the custom config defined in your setup like

return {
  {
    'mikesmithgh/kitty-scrollback.nvim',
    enabled = true,
    lazy = true,
    cmd = { 'KittyScrollbackGenerateKittens', 'KittyScrollbackCheckHealth', 'KittyScrollbackTest' },
    event = { 'User KittyScrollbackLaunch' },
    dev = true,
    -- version = '*', -- latest stable version, may have breaking changes if major version changed
    -- version = '^1.0.0', -- pin major version, include fixes and features that do not have breaking changes
    config = function()
      vim.g.mapleader = ' '
      vim.g.maplocalleader = ','
      require('kitty-scrollback').setup({
        custom = function()
          vim.print('customstuff')
        end,
      })
    end,
  },
}

Have you checked out the Advanced Configuration section on the Wiki? There is a lot of good stuff there, it just doesn't have a written explanation on each config yet.

@mikesmithgh
Copy link
Owner

@Andrew15-5
I keep having a recurring question that is getting asked around configuration. I think it is due to me defaulting to using --clean --noplugin -n which doesn't load any configurations.

So, when someone wants to use a config, they won't see any updates reflected until they override the Kitten with --no-nvim-args or --nvim-args. But, then that loads everything which may not be desired as well.

From you perspective, do you think it makes more sense to

  1. by default, kitty-scrollback.nvim loads your default nvim config?
  2. by default, kitty-scrollback.nvim does not load anything? ( current state - .e.g, passes --clean --noplugin -n)

I have gone back and forth about this, I am not sure which one makes the most sense to be honest because I can see both sides.

Also, do you prefer kitty-scrollback.nvim to basically be the same as your default nvim or more of slimmed down version where you pick what config/plugins get loaded?

I am not really happy with the --no-nvim-args flag right now because I think it is confusing for users.

@Andrew15-5
Copy link
Author

Yeah, --no-nvim-args is super confusing. Like, why do I care if "some"/"any" args are passed to nvim or not (I just need everything to work, nothing else). If the args are invalid, then I would see an error. But since using or not using --no-nvim-args doesn't cause any error, then what's the point of it? At the very least, the naming is bad. Maybe if a user could understand immediately what it does and how to use it, then maybe it's fine. The amount of places where user need to add many different options (flags and/or configs) is honestly overwhelming. I'm amazed that in the end everything does work. I think I could help you with some documentation as a non-author user of the plugin.

I'll answer your questions later.

@mikesmithgh
Copy link
Owner

closed in favor of #69

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