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

feat: Add Neovim Nerd Font Icon #38

Closed
mikesmithgh opened this issue Oct 25, 2023 · 8 comments · Fixed by #67
Closed

feat: Add Neovim Nerd Font Icon #38

mikesmithgh opened this issue Oct 25, 2023 · 8 comments · Fixed by #67
Labels

Comments

@mikesmithgh
Copy link
Owner

Add an opt-in configuration to use the Neovim icon instead of Vim icon. See ryanoasis/nerd-fonts#1391

Depends on next release of https://github.com/ryanoasis/nerd-fonts potentially v3.1.0

@mikesmithgh mikesmithgh added the good first issue Good for newcomers label Oct 25, 2023
@xfzv
Copy link

xfzv commented Nov 21, 2023

Nerd Fonts 3.1.0 was released today and Neovim icon is now available \o/

image

@mikesmithgh
Copy link
Owner Author

Nerd Fonts 3.1.0 was released today and Neovim icon is now available \o/

image

thanks!

mikesmithgh added a commit that referenced this issue Nov 26, 2023
mikesmithgh pushed a commit that referenced this issue Nov 26, 2023
# [2.3.0](v2.2.0...v2.3.0) (2023-11-26)

### Features

* add neovim nerd font icon ([#67](#67)) ([70bb2ae](70bb2ae)), closes [#38](#38)
@mikesmithgh
Copy link
Owner Author

🎉 This issue has been resolved in version 2.3.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@mikesmithgh
Copy link
Owner Author

Hey @xfzv , I just merged the change to let you use the Neovim icon. The instructions are here https://github.com/mikesmithgh/kitty-scrollback.nvim/tree/main#nerd-fonts. Configuring kitty-scrollback.nvim is odd right now, so I plan to improve the experience but this should work for now. Please let me know if you hit any issues.

@xfzv
Copy link

xfzv commented Nov 26, 2023

Nice!

Configuring kitty-scrollback.nvim is odd right now

I guess it is, at least I can't figure how to use the Neovim icon, I'm still getting the Vim one.
It's not a Nerd Font issue, the Neovim icon works just fine in Lualine or when inserted from nerdy.nvim.

My current setup:

  • ~/.config/nvim/lua/plugins/kitty-scrollback.lua
return {
  "mikesmithgh/kitty-scrollback.nvim",
  cmd = { "KittyScrollbackGenerateKittens", "KittyScrollbackCheckHealth" },
  event = "User KittyScrollbackLaunch",
  config = function()
    require("kitty-scrollback").setup({
      ksb_example_visual_selection_highlight_mode_reverse = function()
        return {
          visual_selection_highlight_mode = "reverse",
        }
      end,
    })
  end,
}
  • ~/.config/kitty/kitty.conf
# kitty-scrollback.nvim Kitten alias
action_alias kitty_scrollback_nvim kitten /home/xfzv/.local/share/nvim/lazy/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py

# Browse scrollback buffer in nvim
map kitty_mod+h kitty_scrollback_nvim --config ksb_example_visual_selection_highlight_mode_reverse

# Browse output of the last shell command in nvim
map kitty_mod+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output

# Show clicked command output in nvim
mouse_map ctrl+shift+right press ungrabbed combine : mouse_select_command_output : kitty_scrollback_nvim --config ksb_builtin_last_visited_cmd_output

> **kitty.conf**
> ```kitty
> action_alias kitty_scrollback_nvim kitten /Users/mike/gitrepos/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --nvim-args -u kitty-scrollback-nvim-kitten-config.lua
> ```

Is a distinct kitty-scrollback-nvim-kitten-config.lua file actually required for this? Can't it just be used in the config function?

I tried this but it doesn't work:

return {
  "mikesmithgh/kitty-scrollback.nvim",
  cmd = { "KittyScrollbackGenerateKittens", "KittyScrollbackCheckHealth" },
  event = "User KittyScrollbackLaunch",
  config = function()
    require("kitty-scrollback").setup({
      {
        ksb_example_visual_selection_highlight_mode_reverse = function()
          return {
            visual_selection_highlight_mode = "reverse",
          }
        end,
      },
      {
        ksb_example_status_win_nvim = function()
          return {
            status_window = {
              icons = {
                nvim = "",
              },
            },
          }
        end,
      },
    })
  end,
}

@mikesmithgh mikesmithgh reopened this Nov 26, 2023
@mikesmithgh
Copy link
Owner Author

@xfzv

Regarding your config function, configurations that are prefixed with ksb_builtin_ or ksb_example_ are reserved.

If it is working as expected, then your configuration with ksb_example_visual_selection_highlight_mode_reverse should not
actually be called. You can just remove that and it will fallback on the example configs in lua/kitty-scrollback/configs/example.lua. The logic for this is here

if config_name:match('^ksb_example_.*') then

The reason your the icon isn't showing up is a couple things,

  • By default kitty-scrollback.nvim passes the arguments --clean --noplugin -n. This means that your ~/.config/nvim is not loaded so your kitty-scrollback.lua is never called. If you would like to have your config loaded, then you have to pass either --no-nvim-args or --nvim-args to your kitten.
    For example:

    action_alias kitty_scrollback_nvim kitten /home/xfzv/.local/share/nvim/lazy/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --no-nvim-args
    

    or

    action_alias kitty_scrollback_nvim kitten /home/xfzv/.local/share/nvim/lazy/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --nvim-args <your args here see nvim --help>
    
  • Even if you do the above, the config ksb_example_status_win_nvim is reserved, so you do not need to explicitly define it in your config.

  • The problem if you are using ksb_example.* is that it will conflict with the other configs --config ksb_example_visual_selection_highlight_mode_reverse, --config ksb_builtin_last_cmd_output, --config ksb_builtin_last_visited_cmd_output. For example, you can't do this:

    map kitty_mod+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output --config ksb_example_status_win_nvim
    

kitty-scrollback.nvim will just take one of those configs and you will not have all the configurations that you expected

As I type this out, I realize how much a mess the config is for kitty-scrolback.nvim 😹. I plan to have a big refactor to try and get rid of these pain points and have it just make sense. But, that is a big lift at the moment.

For now, I suggest you do this:

  • Create the file, /home/xfzv/.config/nvim/lua/kitty-scrollback-nvim-kitten-config.lua

    • You can move this file anywhere and name it whatever you want, this is just an example
  • In your file above kitty-scrollback-nvim-kitten-config.lua, add the following

-- since your entire config isn't loaded, we can just add kitty-scrollback.nvim to neovim runtime path 
-- I see you are using lazy.nvim and know where the file is that is how I am referencing it below
-- it should be /home/xfzv/.local/share/nvim/lazy/kitty-scrollback.nvim
vim.opt.runtimepath:append(vim.fn.stdpath('data') .. '/lazy/kitty-scrollback.nvim')

-- this is where you can configure everything now
require('kitty-scrollback').setup({
  -- global is a special reserved config that will apply to all of your configurations
  -- for example if you pass --config ksb_builtin_last_cmd_output, global will still be loaded
  global = function()
    return {
      visual_selection_highlight_mode = 'reverse',
      status_window = {
        icons = {
          nvim = '',
        },
      },
    }
  end,
  another_config = function() -- this is just an example, you can remove this. But imagine you have a config that is specific to a certain
                              -- map in kitty.conf, you can use this like map f1 kitty_scrollback_nvim --config another_config
                              -- also in this case, whatever you have in the global config will be merged as well
    -- ...
  end
})

Then in your kitty.conf

# kitty-scrollback.nvim Kitten alias
# by default kitty-scrollback.nvim passed --clean --noplugin -n to nvim
# what we are doing here, passing our own args to nvim
# this is passing -u /home/xfzv/.config/nvim/lua/kitty-scrollback-nvim-kitten-config.lua
# -u is that flag that lets you pass a config file to nvim
# nvim --clean --noplugin -n is now nvim -u /home/xfzv/.config/nvim/lua/kitty-scrollback-nvim-kitten-config.lua
# notice --clean --noplugin -n have been removed since we didn't specify them
action_alias kitty_scrollback_nvim kitten /home/xfzv/.local/share/nvim/lazy/kitty-scrollback.nvim/python/kitty_scrollback_nvim.py --nvim-args -u /home/xfzv/.config/nvim/lua/kitty-scrollback-nvim-kitten-config.lua

# Browse scrollback buffer in nvim
# I remove --config ksb_example_visual_selection_highlight_mode_reverse
# because it is now defined the the global config kitty-scrollback-nvim-kitten-config.lua from above
# since global is a special reserve config, it will be merged with all of the mappings to kitty_scrollback_nvim
map kitty_mod+h kitty_scrollback_nvim

# Browse output of the last shell command in nvim
map kitty_mod+g kitty_scrollback_nvim --config ksb_builtin_last_cmd_output

# Show clicked command output in nvim
mouse_map ctrl+shift+right press ungrabbed combine : mouse_select_command_output : kitty_scrollback_nvim --config ksb_builtin_last_visited_cmd_output

Ooof, hopefully this made sense. As I typed it out, I realized how complicated it is. Let me know if it works

@xfzv
Copy link

xfzv commented Nov 26, 2023

Thank you so much for taking the time to write all these detailed instructions, I eventually got it working:
image

I realize that my config was completely wrong, it looks like visual_selection_highlight_mode = "reverse" was only working because of:

# Browse scrollback buffer in nvim
map kitty_mod+h kitty_scrollback_nvim --config ksb_example_visual_selection_highlight_mode_reverse

I'm curious to see how you'll manage to "simplify" the setup. It would be great if we could set all the options directly in opts or in the config function without using an additional file, like what I was trying to do. I'm not a dev by any means so it's just my two cents, maybe it's technically not feasible.

Keep up the good work!

@mikesmithgh
Copy link
Owner Author

@xfzv awesome looking good now 😎.

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

Successfully merging a pull request may close this issue.

2 participants