Merge from main

This commit is contained in:
MarcHamamji
2023-04-03 19:12:16 +03:00
4 changed files with 55 additions and 6 deletions

17
lua/runner/config.lua Normal file
View File

@@ -0,0 +1,17 @@
local M = {}
local defaults = {
position = 'right', -- options: top, left, right, bottom
width = 80, -- width of window when position is left or right
height = 10, -- height of window when position is top or bottom
}
M.options = {}
M.setup = function(options)
M.options = vim.tbl_deep_extend('force', {}, defaults, options or {})
end
M.setup()
return M;

View File

@@ -1,5 +1,7 @@
local M = {}
local config = require('runner.config')
M._buffer = nil
M._window = nil
@@ -21,7 +23,16 @@ M.create_window = function()
return M._window
end
vim.cmd([[ vsplit ]])
if config.options.position == 'right' then
vim.cmd('botright ' .. config.options.width .. ' vsplit')
elseif config.options.position == 'left' then
vim.cmd('topleft ' .. config.options.width .. ' vsplit')
elseif config.options.position == 'bottom' then
vim.cmd('botright ' .. config.options.height .. 'split')
elseif config.options.position == 'top' then
vim.cmd('topleft ' .. config.options.height .. 'split')
end
local window = vim.api.nvim_get_current_win()
local window_opts = {

View File

@@ -1,9 +1,14 @@
local handlers = require('runner.handlers')
local config = require('runner.config')
local M = {}
M._handlers = handlers
M.setup = function(options)
config.setup(options)
end
M.set_handler = function(filetype, handler)
M._handlers[filetype] = handler
end