Skip to content

Commit 3f75f87

Browse files
committed
made prettier
Signed-off-by: Antti Pohjola <[email protected]>
1 parent eac6c79 commit 3f75f87

File tree

4 files changed

+2425
-2433
lines changed

4 files changed

+2425
-2433
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
test:
22
nvim --headless -c 'PlenaryBustedDirectory tests/'
33
lint:
4-
luacheck lua/:
4+
luacheck lua/

lua/html-entities.lua

+42-42
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,57 @@
1-
local htmlEntities = require("html-entities.htmlEntities")
1+
local htmlEntities = require('html-entities.htmlEntities')
22

33
local he = {}
44

55
-- This function is supposed to be called explicitly by users to configure this
66
-- plugin
77
function he.setup()
8-
-- avoid setting global values outside of this function. Global state
9-
-- mutations are hard to debug and test, so having them in a single
10-
-- function/module makes it easier to reason about all possible changes
11-
-- he.options = with_defaults(options)
12-
13-
-- do here any startup your plugin needs, like creating commands and
14-
-- mappings that depend on values passed in options
15-
vim.api.nvim_create_user_command("HtmlEncode", he.encode, {})
16-
vim.api.nvim_create_user_command("HtmlDecode", he.decode, {})
8+
-- avoid setting global values outside of this function. Global state
9+
-- mutations are hard to debug and test, so having them in a single
10+
-- function/module makes it easier to reason about all possible changes
11+
-- he.options = with_defaults(options)
12+
13+
-- do here any startup your plugin needs, like creating commands and
14+
-- mappings that depend on values passed in options
15+
vim.api.nvim_create_user_command('HtmlEncode', he.encode, {})
16+
vim.api.nvim_create_user_command('HtmlDecode', he.decode, {})
1717
end
1818

1919
function he.encode()
20-
local buf = vim.api.nvim_buf_get_lines(0, 0, -1, false)
21-
22-
local encodedBuf = {}
23-
local eob = 0;
24-
for n,line in pairs(buf) do
25-
--encode
26-
if (line ~= nil and line ~= '' and line ~='\n') then
27-
local encodedLine = htmlEntities.encode(line)
28-
encodedBuf[n] = encodedLine
29-
else
30-
encodedBuf[n] = ''
31-
end
32-
eob = n
33-
end
34-
--update the buffer
35-
vim.api.nvim_buf_set_lines(0, 0, eob, false, encodedBuf)
20+
local buf = vim.api.nvim_buf_get_lines(0, 0, -1, false)
21+
22+
local encodedBuf = {}
23+
local eob = 0
24+
for n, line in pairs(buf) do
25+
--encode
26+
if line ~= nil and line ~= '' and line ~= '\n' then
27+
local encodedLine = htmlEntities.encode(line)
28+
encodedBuf[n] = encodedLine
29+
else
30+
encodedBuf[n] = ''
31+
end
32+
eob = n
33+
end
34+
--update the buffer
35+
vim.api.nvim_buf_set_lines(0, 0, eob, false, encodedBuf)
3636
end
3737

3838
function he.decode()
39-
local buf = vim.api.nvim_buf_get_lines(0, 0, -1, false)
40-
41-
local decodedBuf = {}
42-
local eob = 0;
43-
for n,line in pairs(buf) do
44-
--decode
45-
if (line ~= nil and line ~= '' and line ~='\n') then
46-
local decodedLine = htmlEntities.decode(line)
47-
decodedBuf[n] = decodedLine
48-
else
49-
decodedBuf[n] = ''
50-
end
51-
eob = n
52-
end
53-
--update the buffer
54-
vim.api.nvim_buf_set_lines(0, 0, eob, false, decodedBuf)
39+
local buf = vim.api.nvim_buf_get_lines(0, 0, -1, false)
40+
41+
local decodedBuf = {}
42+
local eob = 0
43+
for n, line in pairs(buf) do
44+
--decode
45+
if line ~= nil and line ~= '' and line ~= '\n' then
46+
local decodedLine = htmlEntities.decode(line)
47+
decodedBuf[n] = decodedLine
48+
else
49+
decodedBuf[n] = ''
50+
end
51+
eob = n
52+
end
53+
--update the buffer
54+
vim.api.nvim_buf_set_lines(0, 0, eob, false, decodedBuf)
5555
end
5656

5757
he.options = nil

0 commit comments

Comments
 (0)