slugbyte / unruly-worker.nvim

a ridiculously fun neovim plugin for the workman keyboard layout
MIT License
36 stars 2 forks source link

Help adding this to LazyVim and Which-Key #8

Closed descendingnerdliness closed 1 month ago

descendingnerdliness commented 1 month ago

I am new to actually trying to use nvim, which I need to learn clojure with conjure. I have settled on the LazyVim setup. As I need the workman layout, things could be much better. I am very impressed by what I see in Unruly Worker. It seems very well designed and I would like to incorporate all of the options into LazyVim, including Which-Key. Alas, I am a novice at all of it and would appreciate the benefit of your wisdom.

descendingnerdliness commented 1 month ago

I found what may be an issue in the text in the keymap.lua file.

name = "easy_scroll",
        keymap = {
            m = {
                ["<End>"] = spec.map("9<C-E>", "scroll down fast"),
                ["<PageDown>"] = spec.map("3<C-E>", "scroll down"),
                ["<PageUp>"] = spec.map("3<C-Y>", "scroll up"),
                ["<Home>"] = spec.map("9<C-Y>", "scroll down fast"),
            },
        },

"Scroll down fast" appears twice.

slugbyte commented 1 month ago

Hey @descendingnerdliness! I'd be happy to help :)

Are you able to get any of unruly-worker's keymaps working on your setup?

heres a few links to my own configuation for unruly-worker and which-key :)

The main thing I do to setup which-key is create groups, so that leader groups show up nicely, other than that keymaps all have there own doc strings so should be supported by whichkey out of the box :)

do you have an up to date dotfiles repository where I can see how your configuration is setup?

clojure is one of my favorite languages! sadly I haven't gotten to work with it in the last year or so I don't exactly have any specific advice for you related to unruly-worker for clojure/lisp

Have you setup a paredit style plugin for helping you edit lisp code? If not I would highly recommend finding one :)

slugbyte commented 1 month ago

I found what may be an issue in the text in the keymap.lua file.

name = "easy_scroll",
        keymap = {
            m = {
                ["<End>"] = spec.map("9<C-E>", "scroll down fast"),
                ["<PageDown>"] = spec.map("3<C-E>", "scroll down"),
                ["<PageUp>"] = spec.map("3<C-Y>", "scroll up"),
                ["<Home>"] = spec.map("9<C-Y>", "scroll down fast"),
            },
        },

"Scroll down fast" appears twice.

Thanks for pointing this out!

slugbyte commented 1 month ago

I just patched the easy_scroll documentation issue :)

descendingnerdliness commented 1 month ago

hey. I managed to get unruly worker loaded using the config in the readme.md and a simple return statement in a plugin file, along with your which-key file, but h, j, k,l were not remapped and it does not seem to overcome the LazyVim configs. They are very extensive and provide directories for plugins and configs, if you have not looked. The unruly-worker link above fails to load due to missing references: config = function() local util = require("slugbyte.util") local unruly_worker = require("unruly-worker")

descendingnerdliness commented 1 month ago

I do have conjure working, thanks.

descendingnerdliness commented 1 month ago

According to the lazyvim control panel, unruly-worker is at the "start" condition and it shows a mythical directory. I did copy the three lines that are supposed to make it a must to run. It looks like I will have to delve into the depths of LazyVim to get unruly-worker to function.

slugbyte commented 1 month ago

Sorry for the confusion, I wasn't intending for you to copy my config, just use it as a reference, slugbyte.util is just my own personal package thats probly what broke your ability for unruly worker to load when that got loaded.

I just peeked at the LazyVim docs and it seems like you need to add a file in your plugins dir like lua/plugins/unruly-worker.lua and add the folllowing code

-- added example bleow in a later comment

you should be able to enable/disable any of the unruly keymap modules by just setting them to true or false :)

descendingnerdliness commented 1 month ago

This is in my config file:

-- This is from the repo. .dn-cSp.
-- Use this setup config if you want to follow the keymap above

local unruly_worker = require('unruly-worker')

-- to setup with the defaults you can simply put
unruly_worker.setup()

-- example setup with the default settings
unruly_worker.setup({
  -- you can use the skip_list = {} to stop unruly from creating certain mappings
  -- skip_list = { "z", "Z", "<C-z>"},  skip z related mappings
  skip_list = {},
  unruly_options = {
    -- set default unruly kopy register must be [a-z] [A-Z] 0 +
    kopy_reg = "+",
    -- set default unruly macro register must be [a-z] [A-Z]
    macro_reg = "q",
    -- set default unruly seek mode, must be unruly_worker.seek_mode.(buffer|loclist|quickfix)
    seek_mode = unruly_worker.seek_mode.buffer,
    -- set unruly mark mode to global or local
    mark_mode_is_global = false
  },
  -- boosters allow you to op-in to extra keymaps
  -- or opt-out of the default keymaps if you want that for some reason
  booster = {
    default                     = true,
    -- easy stuff are just additional opt in keymaps
    easy_swap                   = true,
    easy_search = true,
    easy_line                   = true,
    easy_spellcheck             = true,
    easy_incrament              = true,
    easy_hlsearch               = true,
    easy_focus                  = true,
    easy_window                 = true,
    easy_jumplist               = true,
    easy_scroll                 = true,
    easy_source                 = true,
    easy_lsp                    = true,
    easy_lsp_leader             = true,
    easy_diagnostic             = true,
    easy_diagnostic_leader      = true,
    -- unruly stuff change neovim's normal behavior
    unruly_seek                 = true,
    unruly_mark                 = true,
    unruly_macro                = true,
    unruly_kopy                 = true,
    unruly_quit                 = true,
    -- plugin stuff have external dependencies
    plugin_navigator            = true,
    plugin_comment              = true,
    plugin_luasnip              = true,
    plugin_textobject           = true,
    plugin_telescope_leader     = true,
    plugin_telescope_lsp_leader = true,
    plugin_telescope_easy_jump  = true,
    plugin_telescope_easy_paste = true,
    plugin_telescope_diagnostic_leader = true,
  },
    keymap("<HOME>", "2gk", "Scroll Up Fast")
    keymap("<PageUp>", "4gk", "Move Up Fast")
    keymap("<END>", "2gj", "Scroll Down Fast")
    keymap("<PageDown>", "4gj", "Move Down Fast")
    keymap("<leader>d", unruly_worker.boost.telescope.diagnostics, "[D]iagnostic Search")

})

and I finally got the syntax so this runs in my plugin file:

return {
    "slugbyte/unruly-worker",
        lazy = false,
        dev = true,
        priority = 9000, -- make sure to load this before all the other start plugins

}

I will add this line

    -- event = 'VimEnter', -- if its still not working try uncomenting this line 

But should I move the other from the config to the plugin?

descendingnerdliness commented 1 month ago

Thank you @slugbyte.

This is what I have in the control panel:

● unruly-worker 0.15ms  start
        dir   /home/patrick/projects/unruly-worker
        url   https://github.com/slugbyte/unruly-worker
        event  VimEnter 

For comparison

● which-key.nvim 10.96ms  VimEnter
        dir    /home/patrick/.local/share/nvim/lazy/which-key.nvim
        url    https://github.com/folke/which-key.nvim
        branch main
        commit bfec3d6
        readme README.md
        help   |which-key.nvim.txt|
        event   VimEnter  VeryLazy 
        keys    <leader>?  <c-w><space> 

Note the dir entry for unruly-worker does not exist.

This is with the following in the plugin file

return {
    "slugbyte/unruly-worker",
        lazy = false,
        dev = true,
        priority = 9000, -- make sure to load this before all the other start plugins
        event = 'VimEnter', -- if its still not working try uncomenting this line 

}
slugbyte commented 1 month ago

The code you pasted above under this is my config file is not valid lua and has a lot of issues and the plugin file config should not have dev = true, thats specifically for my setup.

I would try deleting the config file code above and replacing the code you have in your plugin file with the plugin config I provided below :)

return {
    "slugbyte/unruly-worker.nvim",
    main = "unruly-worker",
    lazy = false,
    priority = 1000,
    -- event = 'VimEnter', -- if its still not working try uncomenting this line
    opts = {
        booster = {
            -- default enables the basic unruly-worker keymaps :)
            default = true,

            -- easy stuff are just additional opt in keymaps
            easy_diagnostic = false,
            easy_focus = false,
            easy_hlsearch = false,
            easy_incrament = false,
            easy_jumplist = false,
            easy_line = false,
            easy_lsp = false,
            easy_lsp_leader = false,
            easy_scroll = false,
            easy_search = false,
            easy_source = false,
            easy_swap = false,
            easy_window = false,
            easy_diagnostic_leader = false,
            easy_spellcheck = false,

            -- unruly stuff change neovim's normal behavior
            unruly_seek = false,
            unruly_mark = false,
            unruly_macro = false,
            unruly_kopy = false,
            unruly_quit = false,

            -- plugin stuff have external dependencies
            plugin_navigator = false,
            plugin_comment = false,
            plugin_luasnip = false,
            plugin_telescope_leader = false,
            plugin_telescope_lsp_leader = false,
            plugin_telescope_easy_jump = false,
            plugin_textobject = false,
        },
    },
}

you should not have any additional unruly-worker related configuration other than what is in the plugin config above :)

you should not ever require('unruly-worker') or call unruly_worker.setup(...your_config) yourself, the value assigned to opts = {... config above... } should auto magicly be passed into the unruly_worker.setup function by LazyVim :)

descendingnerdliness commented 1 month ago

OK, with just the plugin file above, with the event line uncommented, I get the following complaint:

Lua module not found for config of unruly-worker. Please use a `config()` function instead

You are right, I am stumbling around in the dark trying to get things to work. I looked at the conjure plugin file and it has a line addressing a config function (and it works :) ):


return {

{
  "PaterJason/cmp-conjure",
},

{ "PaterJason/nvim-treesitter-sexp", opts = {}, event = "LazyFile" },
{
  "m00qek/baleia.nvim",
  opts = {
    line_starts_at = 3,
  },
  config = function(_, opts)
    vim.g.conjure_baleia = require("baleia").setup(opts)

    vim.api.nvim_create_user_command("BaleiaColorize", function()
      vim.g.conjure_baleia.once(vim.api.nvim_get_current_buf())
    end, { bang = true })

    vim.api.nvim_create_user_command("BaleiaLogs", vim.g.conjure_baleia.logger.show, { bang = true })
  end,
},

I added three other related plugins to that file. One has the "config = function(_," line and the other does not. I'm sure you understand. I do not.

slugbyte commented 1 month ago

try this instead

return {
    "slugbyte/unruly-worker.nvim",
    lazy = false,
    priority = 1000,
    -- event = 'VimEnter', -- if its still not working try uncomenting this line
    config = function()
        require("unruly-worker").setup({
            booster = {
                -- default enables the basic unruly-worker keymaps :)
                default = true,

                -- easy stuff are just additional opt in keymaps
                easy_diagnostic = false,
                easy_focus = false,
                easy_hlsearch = false,
                easy_incrament = false,
                easy_jumplist = false,
                easy_line = false,
                easy_lsp = false,
                easy_lsp_leader = false,
                easy_scroll = false,
                easy_search = false,
                easy_source = false,
                easy_swap = false,
                easy_window = false,
                easy_diagnostic_leader = false,
                easy_spellcheck = false,

                -- unruly stuff change neovim's normal behavior
                unruly_seek = false,
                unruly_mark = false,
                unruly_macro = false,
                unruly_kopy = false,
                unruly_quit = false,

                -- plugin stuff have external dependencies
                plugin_navigator = false,
                plugin_comment = false,
                plugin_luasnip = false,
                plugin_telescope_leader = false,
                plugin_telescope_lsp_leader = false,
                plugin_telescope_easy_jump = false,
                plugin_textobject = false,
            },
        })
    end,
}
slugbyte commented 1 month ago

I'm off to bed and will potentially be AFK over the weekend, So I may not be able to help you debug until monday or tuesday.

I would recommend reading the lazy.nvim plugin configuration docs which is what LazyVim uses under the hood for loading plugins :)... lazy.nvim is what LazyVim uses for plugin management

It will explain the difference between config = function() ... end and opts = {} and stuff like that

Best of luck!

descendingnerdliness commented 1 month ago

IT Worked


  Installed (1)
    ● unruly-worker 36.49ms  start
        dir    /home/patrick/.local/share/nvim/lazy/unruly-worker
        url    https://github.com/slugbyte/unruly-worker
        branch main
        commit a77ddc5
        readme README.md

      ✔ [task] clone 3178.73ms
        Cloning into '/home/patrick/.local/share/nvim/lazy/unruly-worker'...
        remote: Enumerating objects: 867, done.        
        remote: Counting objects: 100% (206/206), done.        
        remote: Compressing objects: 100% (109/109), done.        
        remote: Total 867 (delta 102), reused 156 (delta 61), pack-reused 661 (from 1)        
        Receiving objects: 100% (867/867), 219.63 KiB | 596.00 KiB/s, done.
        Resolving deltas: 100% (320/320), done.
        Updating files: 100% (41/41), done.
      ✔ [task] checkout 5.26ms
      ✔ [task] docs 0.04ms
      ✔ [task] log 99.28ms

Thanks much

slugbyte commented 1 month ago

Whooohoo, Happy to help :)