Skip to content

Instantly share code, notes, and snippets.

View RaafatTurki's full-sized avatar
🥔
sprouting

Raafat Turki RaafatTurki

🥔
sprouting
  • Iraq
  • 19:31 (UTC +03:00)
View GitHub Profile
@RaafatTurki
RaafatTurki / hex_editor.lua
Last active June 1, 2023 01:55
proper hex editing in neovim
local xxd_dump_cmd = 'xxd -g 1 -u'
local xxd_cur_pos = nil
local function is_binary_file()
local filename = vim.fn.expand('%:t')
-- local basename = string.match(filename, "^[a-z]*$")
local binary_ext = { 'png', 'jpg', 'jpeg', 'out' }
local ext = string.match(filename, "%.([^%.]+)$")
if ext == nil and string.match(filename, '[a-z]+') then return true end
-- vim.g.last_tab_page_handler = nil
-- LastTabPageHandler = nil
function TabSwitch(handler)
local curr_handler = vim.api.nvim_get_current_tabpage()
local next_handler = handler
-- if (handler == curr_handler) then
-- next_handler = LastTabPageHandler
-- LastTabPageHandler = curr_handler
@RaafatTurki
RaafatTurki / lsp_rename.lua
Created March 22, 2022 17:54
neat little lsp rename function
function LspRename()
local curr_name = vim.fn.expand("<cword>")
local value = vim.fn.input("LSP Rename: ", curr_name)
local lsp_params = vim.lsp.util.make_position_params()
if not value or #value == 0 or curr_name == value then return end
-- request lsp rename
lsp_params.newName = value
vim.lsp.buf_request(0, "textDocument/rename", lsp_params, function(_, res, ctx, _)