Giter Site home page Giter Site logo

Comments (3)

RaafatTurki avatar RaafatTurki commented on May 25, 2024

The automatic hex dumping feature can be disabled by passing the following config options during setup:

require 'hex'.setup {
  is_file_binary_pre_read = function() return false end,
  is_file_binary_post_read = function() return false end,
}

one can of course implement their own detection logic in there, checkout the README for more info.
Also thanks :)

from hex.nvim.

plokid avatar plokid commented on May 25, 2024

@AadityaGala I am also using LazyVim, but it can't work perfectly. I can use :lua require("hex").toggle(), but :HexToggle not work. Could you please give me your configuration?

from hex.nvim.

AadityaGala avatar AadityaGala commented on May 25, 2024

@plokid

return {
  -- add symbols-outline
  {
    "RaafatTurki/hex.nvim",
    event = "VeryLazy",
    config = function()
      require("hex").setup({
        dump_cmd = "xxd -g 1 -u",
        assemble_cmd = "xxd -r",
        is_file_binary_pre_read = function()
          local binary_ext = { "out", "bin", "png", "jpg", "jpeg", "exe", "dll" }
          local binary_ext_ignore = { "a2l" }
          -- only work on normal buffers
          if vim.bo.ft ~= "" then
            return false
          end
          -- check -b flag
          if vim.bo.bin then
            return true
          end
          -- check ext within binary_ext
          local ext = vim.fn.expand("%:e")
          if vim.tbl_contains(binary_ext_ignore, ext) then
            return false
          elseif vim.tbl_contains(binary_ext, ext) then
            return true
          end
          -- none of the above
          return false
        end,
        is_file_binary_post_read = function()
          local encoding = (vim.bo.fenc ~= "" and vim.bo.fenc) or vim.o.enc
          local binary_ext_ignore = { "a2l" }
          local ext = vim.fn.expand("%:e")
          if vim.tbl_contains(binary_ext_ignore, ext) then
            return false
          end
          if encoding ~= "utf-8" then
            return true
          end
          return false
        end,
      })
    end,
  },
}

from hex.nvim.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.