diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-05-04 08:44:50 +0200 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-05-06 16:43:16 +0200 |
| commit | 0bc002288b984d8ec8123c135456570c78a22da3 (patch) | |
| tree | 020ed3f6a7f28a081687a3e46ea190e3aa724f7c /.config/nvim/after/ftplugin/lua.lua | |
| download | dotfiles-0bc002288b984d8ec8123c135456570c78a22da3.tar.gz dotfiles-0bc002288b984d8ec8123c135456570c78a22da3.zip | |
feat: initial setup
- `dotfiles` (this project's CLI)
- foot configuration
- tmux configuration
- bash configuration
- nvim (as a git submodule) + configuration
- ranger configuration
- fzf configuration
- KDE global shortcuts
- Other miscellaneous dependencies
Diffstat (limited to '.config/nvim/after/ftplugin/lua.lua')
| -rw-r--r-- | .config/nvim/after/ftplugin/lua.lua | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/.config/nvim/after/ftplugin/lua.lua b/.config/nvim/after/ftplugin/lua.lua new file mode 100644 index 0000000..784915e --- /dev/null +++ b/.config/nvim/after/ftplugin/lua.lua @@ -0,0 +1,36 @@ +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 tempname = vim.fn.tempname() + local tempfile = assert(io.open(tempname, "w"), "Could not open temporary file") + tempfile:write(buf_str) + tempfile:close() + local r_check = vim.system({ "stylua", "--check", tempname }):wait() + if r_check.code == 0 then + return + elseif r_check.code ~= 1 then + vim.notify("stylua failed (" .. r_check.code .. "):\n" .. r_check.stderr) + end + local r_format = vim.system({ "stylua", tempname }):wait() + if r_format.code ~= 0 then + vim.notify("stylua failed (" .. r_format.code .. "):\n" .. r_format.stderr) + end + local formatted_lines = {} + for line in io.lines(tempname) do + formatted_lines[#formatted_lines + 1] = line + end + vim.api.nvim_buf_set_lines(0, 0, -1, false, formatted_lines) + vim.fn.winrestview(view) +end + +vim.opt_local.textwidth = 120 -- gw wraps at this value +vim.opt_local.colorcolumn = "+1" -- Highlight one column after +vim.opt_local.complete = { + "o", -- 'omnifunc' +} + +vim.b.autoformat = true +vim.b.format_func = format |
