Mercurial > dotfiles
comparison dot_config/nvim/plugin/filetypo.lua @ 628:1e6287df57f5
abort filetypo when there are no matches
author | zegervdv <zegervdv@me.com> |
---|---|
date | Thu, 04 Aug 2022 22:39:11 +0200 |
parents | c0cef1aa4ccd |
children |
comparison
equal
deleted
inserted
replaced
627:a2a5862a3bd3 | 628:1e6287df57f5 |
---|---|
3 local filetypo = function() | 3 local filetypo = function() |
4 if vim.fn.filereadable(vim.fn.expand '%') == 1 then return end | 4 if vim.fn.filereadable(vim.fn.expand '%') == 1 then return end |
5 | 5 |
6 local filename = vim.fn.expand '%' | 6 local filename = vim.fn.expand '%' |
7 local matching_files = vim.fn.split(vim.fn.glob(filename .. '*', 0), '\n') | 7 local matching_files = vim.fn.split(vim.fn.glob(filename .. '*', 0), '\n') |
8 if matching_files == nil then matching_files = vim.fn.split(vim.fn.glob(filename .. '*', 1), '\n') end | 8 if matching_files == nil or vim.tbl_isempty(matching_files) then |
9 matching_files = vim.fn.split(vim.fn.glob(filename .. '*', 1), '\n') | |
10 end | |
11 | |
12 if matching_files == nil or vim.tbl_isempty(matching_files) then return end | |
9 | 13 |
10 local buf = vim.api.nvim_get_current_buf() | 14 local buf = vim.api.nvim_get_current_buf() |
11 vim.schedule(function() | 15 vim.schedule(function() |
12 vim.ui.select(matching_files, { prompt = 'Select File:' }, function(choice) | 16 vim.ui.select(matching_files, { prompt = 'Select File:' }, function(choice) |
13 vim.cmd.edit(vim.fn.fnameescape(choice)) | 17 vim.cmd.edit(vim.fn.fnameescape(choice)) |