1 day ago · Tech · hide · 0 comments

It took me a minute to find a good example, so I’ll post this in case it helps anyone else. For you Vimmers out there, here’s an example of how to make your own custom picker using Neovim and mini.pick, part of the very popular mini.nvim plugin. In this case, I’m adding a picker to set the active buffer’s filetype. local function pick_filetype() -- Grab the current buffer before firing the picker -- so we can update it later when we're inside -- the picker's buffer. local current_buf = vim.api.nvim_get_current_buf() -- Get the choices for the picker. In this case, -- all available filetypes. local filetypes = vim.fn.getcompletion('', 'filetype') -- Launch the picker with our custom choices and -- handler. require('mini.pick').start({ source = { name = 'Filetypes', items = filetypes, choose = function(item) -- Handle the user's choice. vim.bo[current_buf].filetype = item -- (Optional) Pop a notification to help us -- know it's working. vim.notify("Set filetype to " .. item) end, }, })…

No comments yet. Log in to reply on the Fediverse. Comments will appear here.