summaryrefslogtreecommitdiffstats
path: root/.config/nvim/after
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-05-04 08:44:50 +0200
committerThomas Vanbesien <tvanbesi@proton.me>2026-05-06 16:43:16 +0200
commit0bc002288b984d8ec8123c135456570c78a22da3 (patch)
tree020ed3f6a7f28a081687a3e46ea190e3aa724f7c /.config/nvim/after
downloaddotfiles-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')
-rw-r--r--.config/nvim/after/ftplugin/bash.lua17
-rw-r--r--.config/nvim/after/ftplugin/gitcommit.lua27
-rw-r--r--.config/nvim/after/ftplugin/lua.lua36
-rw-r--r--.config/nvim/after/ftplugin/markdown.lua80
-rw-r--r--.config/nvim/after/ftplugin/qf.lua1
-rw-r--r--.config/nvim/after/queries/gitcommit/injections.scm4
6 files changed, 165 insertions, 0 deletions
diff --git a/.config/nvim/after/ftplugin/bash.lua b/.config/nvim/after/ftplugin/bash.lua
new file mode 100644
index 0000000..d46657d
--- /dev/null
+++ b/.config/nvim/after/ftplugin/bash.lua
@@ -0,0 +1,17 @@
+vim.opt_local.textwidth = 80 -- gw wraps at this value
+vim.opt_local.colorcolumn = "+1" -- Highlight one column after 'textwidth'
+vim.opt_local.complete = {
+ "o", -- 'omnifunc'
+}
+
+vim.b.autoformat = true
+vim.b.format_func = function()
+ local ret = vim.system({ "shfmt" }, { stdin = vim.api.nvim_buf_get_lines(0, 0, -1, false) }):wait()
+ if ret.code ~= 0 then
+ vim.notify("shfmt failed (" .. ret.code .. "):\n" .. ret.stderr, vim.log.levels.WARN)
+ return
+ end
+ local view = vim.fn.winsaveview()
+ vim.cmd("%!shfmt")
+ vim.fn.winrestview(view)
+end
diff --git a/.config/nvim/after/ftplugin/gitcommit.lua b/.config/nvim/after/ftplugin/gitcommit.lua
new file mode 100644
index 0000000..e52a2d8
--- /dev/null
+++ b/.config/nvim/after/ftplugin/gitcommit.lua
@@ -0,0 +1,27 @@
+vim.opt_local.colorcolumn = "+1" -- Highlight one column after 'textwidth'
+vim.opt_local.tabstop = 2 -- CommonMark expects two spaces for indentation
+vim.opt_local.shiftwidth = 0
+vim.opt_local.softtabstop = -1
+vim.opt_local.expandtab = true -- Change tabs to spaces
+vim.opt_local.spelllang = "en_us"
+vim.opt_local.complete = {
+ "w", -- other windows
+ ".", -- current buffer
+}
+
+vim.api.nvim_create_autocmd("BufWinEnter", {
+ desc = "Set up gitcommit buffer",
+ group = vim.g.dotfiles.augroup,
+ buffer = 0,
+ callback = function()
+ local gitcommit_window = vim.api.nvim_get_current_win()
+ -- Open cached diff window
+ vim.cmd.DiffGitCached()
+ vim.cmd.wincmd("L")
+ -- Enable English spell check in the original window
+ -- If `'spell'` is set before `:DiffGitChached` it propagates to the cached diff window
+ vim.api.nvim_set_option_value("spell", true, { win = gitcommit_window })
+ -- The current window is the diff window
+ vim.o.filetype = "diff"
+ end,
+})
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
diff --git a/.config/nvim/after/ftplugin/markdown.lua b/.config/nvim/after/ftplugin/markdown.lua
new file mode 100644
index 0000000..755b9aa
--- /dev/null
+++ b/.config/nvim/after/ftplugin/markdown.lua
@@ -0,0 +1,80 @@
+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 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({
+ "mdformat",
+ "--number",
+ "--extensions",
+ "tables",
+ "--extensions",
+ "frontmatter",
+ "--wrap",
+ tostring(vim.bo.textwidth),
+ "--check",
+ tempname,
+ }):wait()
+ if r_check.code == 0 then
+ return
+ elseif r_check.code ~= 1 then
+ vim.notify("mdformat failed (" .. r_check.code .. "):\n" .. r_check.stderr)
+ end
+ local r_format = vim.system({
+ "mdformat",
+ "--number",
+ "--extensions",
+ "tables",
+ "--extensions",
+ "frontmatter",
+ "--wrap",
+ tostring(vim.bo.textwidth),
+ tempname,
+ }):wait()
+ if r_format.code ~= 0 then
+ vim.notify("mdformat 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)
+ if callback then
+ callback()
+ end
+end
+
+vim.opt_local.tabstop = 2 -- CommonMark expects two spaces for indentation
+vim.opt_local.shiftwidth = 0
+vim.opt_local.softtabstop = -1
+vim.opt_local.expandtab = true -- Change tabs to spaces
+-- Nothing in the gutter, except sign columns if necessary
+vim.opt_local.number = false
+vim.opt_local.relativenumber = false
+vim.opt_local.signcolumn = "auto"
+vim.opt_local.foldcolumn = "0"
+--
+vim.opt_local.textwidth = 120 -- gw wraps at this value
+vim.opt_local.colorcolumn = "+1" -- Highlight one column after 'textwidth'
+vim.opt_local.foldlevel = 1
+-- Replace concealed text with a character from `'listchars'`
+-- With `'foldmethod'` set to `expr` and `'foldlevel'` set to 2 fenced code blocks are concealed and completely invisible
+-- I guess that's a TODO for later, find a way to use `'conceallevel'` = 2 but with folded fenced code blocks visible
+vim.opt_local.conceallevel = 1
+vim.opt_local.complete = {
+ "o", -- 'omnifunc'
+ ".", -- current buffer
+}
+-- Visible link labels
+vim.api.nvim_set_hl(0, "@markup.link.label.markdown_inline", { underline = true, update = true })
+
+vim.b.autoformat = true
+vim.b.format_func = format
diff --git a/.config/nvim/after/ftplugin/qf.lua b/.config/nvim/after/ftplugin/qf.lua
new file mode 100644
index 0000000..80aec64
--- /dev/null
+++ b/.config/nvim/after/ftplugin/qf.lua
@@ -0,0 +1 @@
+vim.opt.wrap = false
diff --git a/.config/nvim/after/queries/gitcommit/injections.scm b/.config/nvim/after/queries/gitcommit/injections.scm
new file mode 100644
index 0000000..5996a50
--- /dev/null
+++ b/.config/nvim/after/queries/gitcommit/injections.scm
@@ -0,0 +1,4 @@
+((message) @injection.content
+ (#set! injection.language "markdown_inline"))
+((message_line) @injection.content
+ (#set! injection.language "markdown_inline"))