summaryrefslogtreecommitdiffstats
path: root/.config/nvim/after
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-05-18 21:53:27 +0200
committerThomas Vanbesien <tvanbesi@proton.me>2026-05-18 21:53:27 +0200
commitb05ae88a8ba96abdc055d298875a49fe6fd5f0a3 (patch)
tree2fa1253eef8208cd69945166346955918f646e2e /.config/nvim/after
parentcb83d4749c9f740df2977d1bb7630afd165459b2 (diff)
downloaddotfiles-b05ae88a8ba96abdc055d298875a49fe6fd5f0a3.tar.gz
dotfiles-b05ae88a8ba96abdc055d298875a49fe6fd5f0a3.zip
fix(nvim): replace O(n²) loop concat with table.concat
Diffstat (limited to '.config/nvim/after')
-rw-r--r--.config/nvim/after/ftplugin/lua.lua5
-rw-r--r--.config/nvim/after/ftplugin/markdown.lua5
2 files changed, 2 insertions, 8 deletions
diff --git a/.config/nvim/after/ftplugin/lua.lua b/.config/nvim/after/ftplugin/lua.lua
index 2ffd62c..756026e 100644
--- a/.config/nvim/after/ftplugin/lua.lua
+++ b/.config/nvim/after/ftplugin/lua.lua
@@ -1,9 +1,6 @@
local function format()
local view = vim.fn.winsaveview()
- local buf_str = ""
- for _, v in ipairs(vim.api.nvim_buf_get_lines(0, 0, -1, false)) do
- buf_str = buf_str .. v .. "\n"
- end
+ local buf_str = table.concat(vim.api.nvim_buf_get_lines(0, 0, -1, false), "\n") .. "\n"
local tempname = vim.fn.tempname()
local tempfile = assert(io.open(tempname, "w"), "Could not open temporary file")
tempfile:write(buf_str)
diff --git a/.config/nvim/after/ftplugin/markdown.lua b/.config/nvim/after/ftplugin/markdown.lua
index befabfa..6946216 100644
--- a/.config/nvim/after/ftplugin/markdown.lua
+++ b/.config/nvim/after/ftplugin/markdown.lua
@@ -1,9 +1,6 @@
local function format(callback)
local view = vim.fn.winsaveview()
- local buf_str = ""
- for _, v in ipairs(vim.api.nvim_buf_get_lines(0, 0, -1, false)) do
- buf_str = buf_str .. v .. "\n"
- end
+ local buf_str = table.concat(vim.api.nvim_buf_get_lines(0, 0, -1, false), "\n") .. "\n"
local tempname = vim.fn.tempname()
local tempfile = assert(io.open(tempname, "w"), "Could not open temporary file")
tempfile:write(buf_str)