pwntester / octo.nvim

Edit and review GitHub issues and pull requests from the comfort of your favorite editor
MIT License
2.24k stars 124 forks source link

feat(mappings): add config option to disable default mappings #514

Closed konosubakonoakua closed 3 months ago

konosubakonoakua commented 3 months ago

Describe what this PR does / why we need it

add option to disable default mappings also align colors and mappings code for better vision

Does this pull request fix one issue?

Fixes #507

Describe how you did it

check mappings_disable_default flag before merging user config, if true, set default mappings to {}

Describe how to verify it

  {
    -- TODO: keymapping for 'octo.nvim'
    "konosubakonoakua/octo.nvim",
    -- 'pwntester/octo.nvim',
    dependencies = {
      "nvim-lua/plenary.nvim",
      "nvim-telescope/telescope.nvim",
      -- OR 'ibhagwan/fzf-lua',
      "nvim-tree/nvim-web-devicons",
    },
    config = function()
      require("octo").setup({
        mappings_disable_default = false,
        suppress_missing_scope = {
          projects_v2 = true,
        },
      })
    end,
  },

Special notes for reviews

pwntester commented 3 months ago

@konosubakonoakua Thanks! please document the new config option both in the README and doc/octo.txt

konosubakonoakua commented 3 months ago

@konosubakonoakua Thanks! please document the new config option both in the README and doc/octo.txt

Done~, please review again. 😄

pwntester commented 3 months ago

Thank you!

ckangnz commented 3 months ago

hey thanks @pwntester and @konosubakonoakua

I just tested this and I'm getting errors when the value is set to true

image
konosubakonoakua commented 3 months ago

hey thanks @pwntester and @konosubakonoakua

I just tested this and I'm getting errors when the value is set to true

image

Could you put your config for octo here? I can not reproduce with the config I pasted here

ckangnz commented 3 months ago
  require "octo".setup({
    use_local_fs = false,
    enable_builtin = true,
    default_remote = { "upstream", "origin" },
    default_merge_method = "squash",
    picker = "telescope",
    default_to_projects_v2 = true,
    ui = { use_signcolumn = true },
    issues = {
      order_by = {
        field = "CREATED_AT", -- either COMMENTS, CREATED_AT or UPDATED_AT
        direction = "DESC"    -- either DESC or ASC
      }
    },
    pull_requests = {
      order_by = {
        field = "CREATED_AT",                -- either COMMENTS, CREATED_AT or UPDATED_AT
        direction = "DESC"                   -- either DESC or ASC
      },
      always_select_remote_on_create = false -- always give prompt to select base remote repo when creating PRs
    },
    file_panel = {
      size = 10,
      use_icons = true
    },
    colors = {
      white = Colors.white,
      grey = Colors.light_grey,
      black = Colors.light_black,
      red = Colors.red,
      dark_red = Colors.dark_red,
      green = Colors.green,
      dark_green = Colors.dark_green,
      yellow = Colors.yellow,
      dark_yellow = Colors.brow,
      blue = Colors.blue,
      dark_blue = Colors.dark_blue,
      purple = Colors.dark_magenta,
    },
    mappings_disable_default = false,
    mappings = {},
    comment_icon = "â–Ž", -- comment marker
    outdated_icon = "ó°…’ ", -- outdated indicator
    resolved_icon = " ", -- resolved indicator
    reaction_viewer_hint_icon = "ï‘„ ", -- marker for user reactions
    user_icon = " ", -- user icon
    timeline_marker = "ï‘  ", -- timeline marker
    timeline_indent = "2", -- timeline indentation
    right_bubble_delimiter = "î‚´", -- bubble delimiter
    left_bubble_delimiter = "", -- bubble delimiter
  })

  vim.keymap.set("n", "<leader>O", "<cmd>Octo<cr>", { noremap = true, silent = true })
  vim.keymap.set("v", "<leader>O", "<cmd>Octo<cr>", { noremap = true, silent = true })

  vim.api.nvim_create_autocmd("FileType", {
    pattern = "octo",
    callback = function()
      vim.keymap.set("i", "@", "@<C-x><C-o>", { silent = true, buffer = true })
      vim.keymap.set("i", "#", "#<C-x><C-o>", { silent = true, buffer = true })
    end
  })

This is what i have 🙂 I've set mappings_disable_default = false, because i get an error when its set to true

konosubakonoakua commented 3 months ago

@ckangnz could not reproduce with your config, btw I removed the color setting, are you using the latest version of octo.nvim?

ckangnz commented 3 months ago

@konosubakonoakua Yes i am using the latest version. I can see mappings_disable_default in :help Octo so it must be using the version that consists this change?

konosubakonoakua commented 3 months ago

@konosubakonoakua Yes i am using the latest version. I can see mappings_disable_default in :help Octo so it must be using the version that consists this change?

Strange. could you try konosubakonoakua/octo.nvim ?

pwntester commented 3 months ago

@ckangnz I was able to reproduce your issue and fixed it on https://github.com/pwntester/octo.nvim/commit/72bd42c6e244ef136e387005860a49c7ceb85211 Let me know if it works for you

ckangnz commented 3 months ago

@pwntester hey yes it definitely fixed the issue 🙂 Awesome work! Thank you 🙂