For example, with packer.nvim:
use('devkvlt/floaty.nvim')
require('floaty').setup()
This sets up Floaty with the following defaults:
config = {
width = 0.5, -- Number between 0 and 1 representing a percentage of the editor's width
height = 0.5, -- Same as above
border = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' }, -- Chars for the window borders
winhl = 'Normal:Normal,FloatBorder:Normal', -- Highlight group for the window and the borders, see `h: winhl`
runners = {}, -- Commands to execute code per (filetype,) see below
}
Example:
require('floaty').setup({
runners = {
c = 'gcc {} && ./a.out',
go = 'go run {}',
html = 'open {}',
javascript = 'node {}',
lua = 'lua {}',
python = 'python3 {}',
rust = 'rustc {} -o a.out && ./a.out',
sh = 'bash {}',
typescript = 'deno run {}',
},
})
{}
expands to the full path to the file to run.
Floaty exposes 3 functions which can be used to create keymaps, for example:
local floaty = require('floaty')
vim.keymap.set({ 'n', 't' }, '<A-\\>', floaty.toggle, { silent = true })
vim.keymap.set('t', '<Esc>', floaty.kill, { silent = true })
vim.keymap.set('n', ' r', floaty.run, { silent = true })