aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/home/.config/nvim/after
diff options
context:
space:
mode:
Diffstat (limited to 'home/.config/nvim/after')
l---------home/.config/nvim/after/ftplugin/c.lua1
-rw-r--r--home/.config/nvim/after/ftplugin/cfg.lua3
-rw-r--r--home/.config/nvim/after/ftplugin/cpp.lua2
-rw-r--r--home/.config/nvim/after/ftplugin/dosini.lua3
-rw-r--r--home/.config/nvim/after/ftplugin/gitcommit.lua5
-rw-r--r--home/.config/nvim/after/ftplugin/gitrebase.lua20
-rw-r--r--home/.config/nvim/after/ftplugin/help.lua3
-rw-r--r--home/.config/nvim/after/ftplugin/json.lua1
-rw-r--r--home/.config/nvim/after/ftplugin/mail.lua2
-rw-r--r--home/.config/nvim/after/ftplugin/markdown.lua2
-rw-r--r--home/.config/nvim/after/ftplugin/tex.lua4
-rw-r--r--home/.config/nvim/after/ftplugin/text.lua5
-rw-r--r--home/.config/nvim/after/ftplugin/tmux.lua1
-rw-r--r--home/.config/nvim/after/ftplugin/xdefaults.lua9
-rw-r--r--home/.config/nvim/after/ftplugin/xmodmap.lua4
-rw-r--r--home/.config/nvim/after/plugin/autocmds.lua137
-rw-r--r--home/.config/nvim/after/plugin/mappings.lua58
17 files changed, 260 insertions, 0 deletions
diff --git a/home/.config/nvim/after/ftplugin/c.lua b/home/.config/nvim/after/ftplugin/c.lua
new file mode 120000
index 0000000..48a225a
--- /dev/null
+++ b/home/.config/nvim/after/ftplugin/c.lua
@@ -0,0 +1 @@
+cpp.lua \ No newline at end of file
diff --git a/home/.config/nvim/after/ftplugin/cfg.lua b/home/.config/nvim/after/ftplugin/cfg.lua
new file mode 100644
index 0000000..3e79acd
--- /dev/null
+++ b/home/.config/nvim/after/ftplugin/cfg.lua
@@ -0,0 +1,3 @@
+vim.bo.commentstring = "// %s"
+
+vim.b.undo_ftplugin = vim.b.undo_ftplugin .. "| setlocal commentstring<"
diff --git a/home/.config/nvim/after/ftplugin/cpp.lua b/home/.config/nvim/after/ftplugin/cpp.lua
new file mode 100644
index 0000000..e3d3a8c
--- /dev/null
+++ b/home/.config/nvim/after/ftplugin/cpp.lua
@@ -0,0 +1,2 @@
+vim.bo.commentstring = "// %s"
+vim.b.undo_ftplugin = vim.b.undo_ftplugin .. "| setlocal commentstring<"
diff --git a/home/.config/nvim/after/ftplugin/dosini.lua b/home/.config/nvim/after/ftplugin/dosini.lua
new file mode 100644
index 0000000..f6d7437
--- /dev/null
+++ b/home/.config/nvim/after/ftplugin/dosini.lua
@@ -0,0 +1,3 @@
+vim.bo.commentstring = "# %s"
+vim.b.undo_ftplugin = vim.b.undo_ftplugin
+ .. "|setlocal commentstring"
diff --git a/home/.config/nvim/after/ftplugin/gitcommit.lua b/home/.config/nvim/after/ftplugin/gitcommit.lua
new file mode 100644
index 0000000..8525714
--- /dev/null
+++ b/home/.config/nvim/after/ftplugin/gitcommit.lua
@@ -0,0 +1,5 @@
+vim.wo.spell = true
+vim.b.undo_ftplugin = vim.b.undo_ftplugin .. "|setlocal spell<"
+vim.cmd([[match ErrorMsg /\%1l.\%>50v/]])
+local bufnr = vim.api.nvim_buf_get_number(0)
+require("mapper").ncmd("gd", "DiffGitCached", nil, bufnr)
diff --git a/home/.config/nvim/after/ftplugin/gitrebase.lua b/home/.config/nvim/after/ftplugin/gitrebase.lua
new file mode 100644
index 0000000..98fd264
--- /dev/null
+++ b/home/.config/nvim/after/ftplugin/gitrebase.lua
@@ -0,0 +1,20 @@
+local map = require("mapper")
+local ncmd = map.ncmd
+local vcmd = map.vcmd
+local bufnr = vim.api.nvim_buf_get_number(0)
+
+ncmd("gc", "Cycle", nil, bufnr)
+ncmd("gp", "Pick", nil, bufnr)
+ncmd("ge", "Edit", nil, bufnr)
+ncmd("gf", "Fixup", nil, bufnr)
+ncmd("gd", "Drop", nil, bufnr)
+ncmd("gs", "Squash", nil, bufnr)
+ncmd("gr", "Reword", nil, bufnr)
+
+vcmd("gc", "Cycle", nil, bufnr)
+vcmd("gp", "Pick", nil, bufnr)
+vcmd("ge", "Edit", nil, bufnr)
+vcmd("gf", "Fixup", nil, bufnr)
+vcmd("gd", "Drop", nil, bufnr)
+vcmd("gs", "Squash", nil, bufnr)
+vcmd("gr", "Reword", nil, bufnr)
diff --git a/home/.config/nvim/after/ftplugin/help.lua b/home/.config/nvim/after/ftplugin/help.lua
new file mode 100644
index 0000000..63147a6
--- /dev/null
+++ b/home/.config/nvim/after/ftplugin/help.lua
@@ -0,0 +1,3 @@
+vim.keymap.set("n", "q", function()
+ vim.api.nvim_win_close(0, false)
+end, { buffer = true })
diff --git a/home/.config/nvim/after/ftplugin/json.lua b/home/.config/nvim/after/ftplugin/json.lua
new file mode 100644
index 0000000..726acd0
--- /dev/null
+++ b/home/.config/nvim/after/ftplugin/json.lua
@@ -0,0 +1 @@
+vim.cmd([[syntax match Comment +\/\/.\+$+]])
diff --git a/home/.config/nvim/after/ftplugin/mail.lua b/home/.config/nvim/after/ftplugin/mail.lua
new file mode 100644
index 0000000..538c10b
--- /dev/null
+++ b/home/.config/nvim/after/ftplugin/mail.lua
@@ -0,0 +1,2 @@
+vim.wo.spell = true
+vim.b.undo_ftplugin = vim.b.undo_ftplugin .. "|setlocal spell<"
diff --git a/home/.config/nvim/after/ftplugin/markdown.lua b/home/.config/nvim/after/ftplugin/markdown.lua
new file mode 100644
index 0000000..538c10b
--- /dev/null
+++ b/home/.config/nvim/after/ftplugin/markdown.lua
@@ -0,0 +1,2 @@
+vim.wo.spell = true
+vim.b.undo_ftplugin = vim.b.undo_ftplugin .. "|setlocal spell<"
diff --git a/home/.config/nvim/after/ftplugin/tex.lua b/home/.config/nvim/after/ftplugin/tex.lua
new file mode 100644
index 0000000..b1dbce0
--- /dev/null
+++ b/home/.config/nvim/after/ftplugin/tex.lua
@@ -0,0 +1,4 @@
+vim.wo.spell = true
+vim.bo.formatoptions = vim.bo.formatoptions .. "t"
+vim.b.undo_ftplugin = vim.b.undo_ftplugin
+ .. "|setlocal spell< |setlocal formatoptions<"
diff --git a/home/.config/nvim/after/ftplugin/text.lua b/home/.config/nvim/after/ftplugin/text.lua
new file mode 100644
index 0000000..8c72f6f
--- /dev/null
+++ b/home/.config/nvim/after/ftplugin/text.lua
@@ -0,0 +1,5 @@
+vim.wo.spell = true
+vim.bo.formatoptions = vim.bo.formatoptions .. "t"
+vim.bo.commentstring = "# %s"
+vim.b.undo_ftplugin = vim.b.undo_ftplugin
+ .. "|setlocal spell< |setlocal formatoptions< |setlocal commentstring"
diff --git a/home/.config/nvim/after/ftplugin/tmux.lua b/home/.config/nvim/after/ftplugin/tmux.lua
new file mode 100644
index 0000000..590a12e
--- /dev/null
+++ b/home/.config/nvim/after/ftplugin/tmux.lua
@@ -0,0 +1 @@
+vim.api.nvim_create_autocmd("BufWritePost", { buffer = 0, command = "make" })
diff --git a/home/.config/nvim/after/ftplugin/xdefaults.lua b/home/.config/nvim/after/ftplugin/xdefaults.lua
new file mode 100644
index 0000000..0f4ec99
--- /dev/null
+++ b/home/.config/nvim/after/ftplugin/xdefaults.lua
@@ -0,0 +1,9 @@
+vim.bo.commentstring = "! %s"
+vim.api.nvim_create_augroup("xdefaults", {})
+vim.api.nvim_create_autocmd(
+ "BufWritePost",
+ { group = "xdefaults", buffer = 0, command = "!xrdb %" }
+)
+
+vim.b.undo_ftplugin = vim.b.undo_ftplugin
+ .. "| setlocal commentstring<
diff --git a/home/.config/nvim/after/ftplugin/xmodmap.lua b/home/.config/nvim/after/ftplugin/xmodmap.lua
new file mode 100644
index 0000000..75c9f8a
--- /dev/null
+++ b/home/.config/nvim/after/ftplugin/xmodmap.lua
@@ -0,0 +1,4 @@
+vim.api.nvim_create_autocmd(
+ "BufWritePost",
+ { buffer = 0, command = "!xmodmap %" }
+)
diff --git a/home/.config/nvim/after/plugin/autocmds.lua b/home/.config/nvim/after/plugin/autocmds.lua
new file mode 100644
index 0000000..7ab937f
--- /dev/null
+++ b/home/.config/nvim/after/plugin/autocmds.lua
@@ -0,0 +1,137 @@
+local function augroup(name)
+ return vim.api.nvim_create_augroup(name, {})
+end
+
+local autocmd = vim.api.nvim_create_autocmd
+
+-- adapted from https://github.com/ethanholz/nvim-lastplace/blob/main/lua/nvim-lastplace/init.lua
+local ignore_buftype = { "quickfix", "nofile", "help" }
+local ignore_filetype = { "gitcommit", "gitrebase", "svn", "hgcommit" }
+
+local function run()
+ if vim.tbl_contains(ignore_buftype, vim.bo.buftype) then
+ return
+ end
+
+ if vim.tbl_contains(ignore_filetype, vim.bo.filetype) then
+ -- reset cursor to first line
+ vim.cmd [[normal! gg]]
+ return
+ end
+
+ -- If a line has already been specified on the command line, we are done
+ -- nvim file +num
+ if vim.fn.line(".") > 1 then
+ return
+ end
+
+ local last_line = vim.fn.line([['"]])
+ local buff_last_line = vim.fn.line("$")
+
+ -- If the last line is set and the less than the last line in the buffer
+ if last_line > 0 and last_line <= buff_last_line then
+ local win_last_line = vim.fn.line("w$")
+ local win_first_line = vim.fn.line("w0")
+ -- Check if the last line of the buffer is the same as the win
+ if win_last_line == buff_last_line then
+ -- Set line to last line edited
+ vim.cmd [[normal! g`"]]
+ -- Try to center
+ elseif buff_last_line - last_line >
+ ((win_last_line - win_first_line) / 2) - 1 then
+ vim.cmd [[normal! g`"zz]]
+ else
+ vim.cmd [[normal! G'"<c-e>]]
+ end
+ end
+end
+
+augroup("restore position")
+autocmd("BufReadPost", {
+ once = true,
+ group = "restore position",
+ callback = run
+})
+
+augroup("postwrite")
+autocmd("BufWritePost", {
+ group = "postwrite",
+ pattern = ".Xkeymap",
+ command = "!xkbcomp % $DISPLAY",
+})
+autocmd("BufWritePost", {
+ group = "postwrite",
+ pattern = "*bspwmrc",
+ command = "!bspc wm --restart",
+})
+autocmd("BufWritePost", {
+ group = "postwrite",
+ pattern = "*/polybar/config",
+ command = "!polybar-msg cmd restart",
+})
+autocmd("BufWritePost", {
+ group = "postwrite",
+ pattern = "user-dirs.dirs,user-dirs.locale",
+ command = "!xdg-user-dirs-update",
+})
+autocmd("BufWritePost", {
+ group = "postwrite",
+ pattern = "plugins.lua",
+ command = "source % | PackerSync",
+})
+autocmd("BufWritePost", {
+ group = "postwrite",
+ pattern = "dunstrc",
+ command = "!killall -SIGUSR2 dunst",
+})
+autocmd(
+ "BufWritePost",
+ { group = "postwrite", pattern = "fonts.conf", command = "!fc-cache" }
+)
+
+augroup("autocomplete")
+autocmd("CompleteDone", {
+ group = "autocomplete",
+ command = "if pumvisible() == 0 | silent! pclose | endif",
+})
+
+augroup("reload")
+autocmd("CompleteDone", {
+ group = "reload",
+ command = "if getcmdwintype() == '' | checktime | endif",
+})
+
+augroup("highlightyank")
+autocmd(
+ "TextYankPost",
+ { group = "highlightyank", callback = vim.highlight.on_yank }
+)
+
+augroup("quitro")
+autocmd("BufReadPost", {
+ group = "quitro",
+ callback = function()
+ if vim.opt.readonly:get() then
+ vim.keymap.set("n", "q", "<cmd>q<cr>")
+ end
+ end,
+})
+
+augroup("localinit")
+autocmd("VimEnter", {
+ group = "localinit",
+ callback = function()
+ local settings = vim.fn.findfile(".doit.lua", ".;")
+ if settings ~= "" then
+ print("sourcing local config")
+ dofile(settings)
+ end
+ end,
+})
+
+augroup("restore guicursor")
+autocmd("VimLeave", {
+ once = true,
+ group = "restore guicursor",
+ command = 'set guicursor= | call chansend(v:stderr, "\x1b[ q")'
+})
diff --git a/home/.config/nvim/after/plugin/mappings.lua b/home/.config/nvim/after/plugin/mappings.lua
new file mode 100644
index 0000000..7fd0f03
--- /dev/null
+++ b/home/.config/nvim/after/plugin/mappings.lua
@@ -0,0 +1,58 @@
+local map = require("mapper")
+
+map.n("<Space>", "<Nop>")
+
+-- make an accidental ; press also enter command mode
+-- temporarily disabled to to vim-sneak plugin
+map.n(";", ":")
+
+-- highlight last inserted text
+map.n("gV", "`[v`]")
+
+map.n("<down>", "<c-e>")
+map.n("<up>", "<c-y>")
+
+-- go to first non-blank character of current line
+map.n("<c-a>", "^")
+map.v("<c-a>", "^")
+map.n("<c-e>", "$")
+map.v("<c-e>", "$")
+
+-- This extends p in visual mode (note the noremap), so that if you paste from
+-- the unnamed (ie. default) register, that register content is not replaced by
+-- the visual selection you just pasted over–which is the default behavior.
+-- This enables the user to yank some text and paste it over several places in
+-- a row, without using a named register
+-- map.v('p', "p:if v:register == '"'<Bar>let @@=@0<Bar>endif<cr>")
+map.v("p", 'p:let @+=@0<CR>:let @"=@0<CR>')
+
+map.v("<leader>p", '"_dP')
+map.n("<leader>d", '"_d')
+map.n("<leader>D", '"_D')
+map.map("", "<leader>c", '"_c')
+map.map("", "<leader>C", '"_C')
+
+-- Find and Replace binds
+map.ncmdi("<leader>s", "%s/")
+map.vcmdi("<leader>s", "s/")
+map.ncmdi("<leader>gs", '%s/<c-r>"/')
+map.vcmdi("<leader>gs", 's/<c-r>"/')
+map.ncmdi("<Leader>S", "%s/<C-r><C-w>/")
+
+map.ncmd("<leader>x", "wall")
+map.ncmd("<leader>z", "wqall")
+map.ncmd("<leader>q", "quitall")
+map.ncmd("<localleader>x", "update")
+
+map.t("<Esc>", "<c-\\><c-n>", { silent = true, noremap = true, expr = true })
+
+map.n("gw", vim.diagnostic.open_float)
+map.n("gW", vim.diagnostic.setloclist)
+map.n("[w", vim.diagnostic.goto_prev)
+map.n("]w", vim.diagnostic.goto_next)
+map.n("[e", function()
+ vim.diagnostic.goto_prev({ severity = vim.diagnostic.severity.ERROR })
+end)
+map.n("]e", function()
+ vim.diagnostic.goto_next({ severity = vim.diagnostic.severity.ERROR })
+end)