Skip to content

Commit 024c76c

Browse files
committed
format with stylua
1 parent 241b529 commit 024c76c

4 files changed

Lines changed: 32 additions & 36 deletions

File tree

lua/FTerm.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local t = require("FTerm.terminal"):new()
1+
local t = require('FTerm.terminal'):new()
22

33
local M = {}
44

lua/FTerm/config.lua

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ local U = {}
22

33
local O = {
44
-- Run the default shell in the terminal
5-
cmd = os.getenv("SHELL"),
5+
cmd = os.getenv('SHELL'),
66
-- Neovim's native `nvim_open_win` border config
7-
border = "single",
7+
border = 'single',
88
-- Dimensions are treated as percentage
99
dimensions = {
1010
height = 0.8,
1111
width = 0.8,
1212
x = 0.5,
13-
y = 0.5
14-
}
13+
y = 0.5,
14+
},
1515
}
1616

1717
function U.create_config(opts)
@@ -21,18 +21,15 @@ function U.create_config(opts)
2121

2222
return {
2323
cmd = opts.cmd or O.cmd,
24-
dimensions = opts.dimensions and vim.tbl_extend("keep", opts.dimensions, O.dimensions) or O.dimensions,
25-
border = opts.border or O.border
24+
dimensions = opts.dimensions and vim.tbl_extend('keep', opts.dimensions, O.dimensions) or O.dimensions,
25+
border = opts.border or O.border,
2626
}
2727
end
2828

2929
function U.to_hex(str)
30-
return str:gsub(
31-
".",
32-
function(c)
33-
return string.format("%02X", string.byte(c))
34-
end
35-
)
30+
return str:gsub('.', function(c)
31+
return string.format('%02X', string.byte(c))
32+
end)
3633
end
3734

3835
return U

lua/FTerm/terminal.lua

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
local U = require("FTerm.config")
1+
local U = require('FTerm.config')
22
local api = vim.api
33
local fn = vim.fn
44
local cmd = api.nvim_command
55

66
local Terminal = {
77
au_close = {},
8-
au_resize = {}
8+
au_resize = {},
99
}
1010

1111
-- Init
1212
function Terminal:new()
1313
local state = {
1414
win = nil,
1515
buf = nil,
16-
terminal = nil
16+
terminal = nil,
1717
}
1818

1919
self.__index = self
@@ -84,7 +84,7 @@ function Terminal:win_dim()
8484
width = width,
8585
height = height,
8686
col = col,
87-
row = row
87+
row = row,
8888
}
8989
end
9090

@@ -104,26 +104,21 @@ end
104104
function Terminal:create_win(buf)
105105
local dim = self.dims
106106

107-
local win =
108-
api.nvim_open_win(
109-
buf,
110-
true,
111-
{
112-
border = self.config.border,
113-
relative = "editor",
114-
style = "minimal",
115-
width = dim.width,
116-
height = dim.height,
117-
col = dim.col,
118-
row = dim.row
119-
}
120-
)
121-
122-
api.nvim_win_set_option(win, "winhl", "Normal:Normal")
107+
local win = api.nvim_open_win(buf, true, {
108+
border = self.config.border,
109+
relative = 'editor',
110+
style = 'minimal',
111+
width = dim.width,
112+
height = dim.height,
113+
col = dim.col,
114+
row = dim.row,
115+
})
116+
117+
api.nvim_win_set_option(win, 'winhl', 'Normal:Normal')
123118

124119
-- Setting filetype in `create_win()` instead of `create_buf()` because window options
125120
-- such as `winhl`, `winblend` should be available after the window is created.
126-
api.nvim_buf_set_option(buf, "filetype", "FTerm")
121+
api.nvim_buf_set_option(buf, 'filetype', 'FTerm')
127122

128123
return win
129124
end
@@ -148,7 +143,7 @@ function Terminal:term()
148143
cmd("autocmd! TermClose <buffer> lua require('FTerm.terminal').au_close['" .. self.au_key .. "']()")
149144
end
150145

151-
cmd("startinsert")
146+
cmd('startinsert')
152147
end
153148

154149
-- Terminal:open does all the magic of opening terminal
@@ -179,7 +174,7 @@ function Terminal:close(force)
179174

180175
if force then
181176
if api.nvim_buf_is_loaded(self.buf) then
182-
api.nvim_buf_delete(self.buf, {force = true})
177+
api.nvim_buf_delete(self.buf, { force = true })
183178
end
184179

185180
fn.jobstop(self.terminal)

stylua.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
line_endings = "Unix"
2+
indent_type = "Spaces"
3+
indent_width = 4
4+
quote_style = "AutoPreferSingle"

0 commit comments

Comments
 (0)