From b0c825af3abc6c8158ade7b4106a2e0da4f7aa8d Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 3 Oct 2022 20:22:04 -0700 Subject: [PATCH] Handle files with no extensions --- lua/hflip.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lua/hflip.lua b/lua/hflip.lua index 9786d2e..dd77e87 100644 --- a/lua/hflip.lua +++ b/lua/hflip.lua @@ -36,17 +36,19 @@ local function hflip() local path = vim.api.nvim_buf_get_name(index) local name, ext = split_ext(path) - ext = ext:lower() + if ext ~= nil then + local ext_lower = ext:lower() - local flip_path - if header_exts[ext] then - flip_path = locate_flip_path(name, source_exts) - elseif source_exts[ext] then - flip_path = locate_flip_path(name, header_exts) - end + local flip_path + if header_exts[ext_lower] then + flip_path = locate_flip_path(name, source_exts) + elseif source_exts[ext_lower] then + flip_path = locate_flip_path(name, header_exts) + end - if flip_path then - vim.cmd(string.format('e %s', flip_path)) + if flip_path then + vim.cmd(string.format('e %s', flip_path)) + end end end