-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathoptions.lua
100 lines (92 loc) · 2.3 KB
/
options.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
local options = {
-- choose default mode (valid term, tab, float, toggle, vimux)
mode = "term",
-- add hot reload (Experimental)
hot_reload = false,
-- Focus on runner window(only works on term and tab mode)
focus = true,
-- startinsert (see ':h inserting-ex')
startinsert = false,
insert_prefix = "",
term = {
-- Position to open the terminal, this option is ignored if mode ~= term
position = "bot",
-- window size, this option is ignored if mode == tab
size = 12,
},
float = {
close_key = "<ESC>",
-- Window border (see ':h nvim_open_win')
border = "none",
-- Num from `0 - 1` for measurements
height = 0.8,
width = 0.8,
x = 0.5,
y = 0.5,
-- Highlight group for floating window/border (see ':h winhl')
border_hl = "FloatBorder",
float_hl = "Normal",
-- Transparency (see ':h winblend')
blend = 0,
},
better_term = { -- Toggle mode replacement
clean = false, -- Clean terminal before launch
number = 10, -- Use nil for dynamic number and set init
init = nil,
},
filetype_path = "",
-- Execute before executing a file
before_run_filetype = function() end,
filetype = {
javascript = "node",
java = {
"cd $dir &&",
"javac $fileName &&",
"java $fileNameWithoutExt",
},
c = {
"cd $dir &&",
"gcc $fileName",
"-o $fileNameWithoutExt &&",
"$dir/$fileNameWithoutExt",
},
cpp = {
"cd $dir &&",
"g++ $fileName",
"-o $fileNameWithoutExt &&",
"$dir/$fileNameWithoutExt",
},
python = "python -u",
sh = "bash",
ruby = "ruby",
rust = {
"cd $dir &&",
"rustc $fileName &&",
"$dir/$fileNameWithoutExt",
},
},
project_path = "",
project = {},
prefix = "",
}
local M = {}
local function concat(v)
if type(v) == "table" then
return table.concat(v, " ")
end
return v
end
-- set user config
---@param user_options table
M.set = function(user_options)
if user_options.startinsert then
user_options.insert_prefix = "startinsert"
end
options = vim.tbl_deep_extend("force", options, user_options)
options.filetype = vim.tbl_map(concat, options.filetype)
options.prefix = string.format("%s %d new", options.term.position, options.term.size)
end
M.get = function()
return options
end
return M