wrapped some stuff in do-end blocks

This commit is contained in:
Ivar Fatland
2023-06-30 23:57:41 +02:00
parent 99b8865480
commit ab675f82af
+22 -16
View File
@@ -243,6 +243,7 @@ local function packer_startup(use)
}
end
do
local function file_exists(name)
local f = io.open(name,"r")
@@ -281,33 +282,37 @@ vim.api.nvim_create_user_command(
end,
{ nargs = 0 }
)
end
-- local function split_line()
-- local line = vim.api.nvim_get_current_line()
-- local items = vim.split(line, ", *")
-- local indent = string.match(line, "^%s*")
-- local formatted_items = {items[1] .. ','}
-- for i = 2, #items -1 do
-- table.insert(formatted_items, indent .. tab_whitespace .. items[i] .. ',')
-- end
-- table.insert(formatted_items, indent .. tab_whitespace .. items[#items] )
-- local row, _ = unpack(vim.api.nvim_win_get_cursor(0))
-- vim.api.nvim_buf_set_lines(0, row-1, row, false, formatted_items)
-- end
local split_line
do
local tab_whitespace = ''
for _ = 1, tab_width do
tab_whitespace = tab_whitespace .. ' '
end
local function split_line()
local line = vim.api.nvim_get_current_line()
local items = vim.split(line, ", *")
local indent = string.match(line, "^%s*")
local formatted_items = {items[1] .. ','}
for i = 2, #items -1 do
table.insert(formatted_items, indent .. tab_whitespace .. items[i] .. ',')
end
table.insert(formatted_items, indent .. tab_whitespace .. items[#items] )
local row, _ = unpack(vim.api.nvim_win_get_cursor(0))
vim.api.nvim_buf_set_lines(0, row-1, row, false, formatted_items)
end
local BRACKETS = {
['{'] ='}',
['['] = ']',
['('] = ')'
}
local function split_line()
split_line = function()
local line = vim.api.nvim_get_current_line()
local leading_whitespace = string.match(line, "^%s*")
local leading_indented_whitespace = leading_whitespace .. tab_whitespace
@@ -334,6 +339,7 @@ local function split_line()
::continue::
end
end
end
vim.keymap.set('n',