aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/home/.config/nvim
diff options
context:
space:
mode:
authorLibravatar Arnold Sommerfeld <sommerfeld@strisemarx.com>2023-05-17 18:44:48 +0100
committerLibravatar Arnold Sommerfeld <sommerfeld@strisemarx.com>2023-10-18 11:16:43 +0100
commitb487984ecc61c6229cf92550030745c192fd3d0b (patch)
tree937e598c941fc1172467aeeed8ef51cbfceaca62 /home/.config/nvim
downloaddotfiles-b487984ecc61c6229cf92550030745c192fd3d0b.tar.gz
dotfiles-b487984ecc61c6229cf92550030745c192fd3d0b.tar.bz2
dotfiles-b487984ecc61c6229cf92550030745c192fd3d0b.zip
first commit
Diffstat (limited to 'home/.config/nvim')
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
-rw-r--r--home/.config/nvim/filetype.lua7
-rw-r--r--home/.config/nvim/init.lua26
-rw-r--r--home/.config/nvim/lua/cfg/lsp.lua64
-rw-r--r--home/.config/nvim/lua/cfg/options.lua124
-rw-r--r--home/.config/nvim/lua/cfg/utils.lua24
-rw-r--r--home/.config/nvim/lua/custom/plugins/init.lua1117
-rw-r--r--home/.config/nvim/lua/mapper.lua84
24 files changed, 1706 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)
diff --git a/home/.config/nvim/filetype.lua b/home/.config/nvim/filetype.lua
new file mode 100644
index 0000000..b13afe0
--- /dev/null
+++ b/home/.config/nvim/filetype.lua
@@ -0,0 +1,7 @@
+vim.filetype.add({
+ extension = {
+ eml = "mail",
+ inc = "cpp",
+ def = "cpp",
+ },
+})
diff --git a/home/.config/nvim/init.lua b/home/.config/nvim/init.lua
new file mode 100644
index 0000000..8326c43
--- /dev/null
+++ b/home/.config/nvim/init.lua
@@ -0,0 +1,26 @@
+vim.loader.enable()
+
+function docfg(name)
+ dofile(vim.fn.stdpath("config") .. "/lua/cfg/" .. name .. ".lua")
+end
+
+docfg("options")
+
+function P(v)
+ print(vim.inspect(v))
+ return v
+end
+
+local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
+if not vim.loop.fs_stat(lazypath) then
+ vim.fn.system({
+ "git",
+ "clone",
+ "--filter=blob:none",
+ "https://github.com/folke/lazy.nvim.git",
+ "--branch=stable", -- latest stable release
+ lazypath,
+ })
+end
+vim.opt.rtp:prepend(lazypath)
+require("lazy").setup("custom.plugins")
diff --git a/home/.config/nvim/lua/cfg/lsp.lua b/home/.config/nvim/lua/cfg/lsp.lua
new file mode 100644
index 0000000..5767ff6
--- /dev/null
+++ b/home/.config/nvim/lua/cfg/lsp.lua
@@ -0,0 +1,64 @@
+return {
+ on_attach_wrapper = function(client, bufnr, opts)
+ local map = require("mapper")
+ local autocmd = vim.api.nvim_create_autocmd
+
+ opts = vim.tbl_extend("force", { auto_format = false }, opts or {})
+
+ if client.supports_method("textDocument/codeLens") then
+ require("virtualtypes").on_attach(client, bufnr)
+ autocmd(
+ { "CursorHold", "CursorHoldI", "InsertLeave" },
+ { buffer = bufnr, callback = vim.lsp.codelens.refresh }
+ )
+ map.n("gl", vim.lsp.codelens.run, { buffer = bufnr })
+ end
+
+ if client.supports_method("textDocument/definition") then
+ map.n("<c-]>", vim.lsp.buf.definition, { buffer = bufnr })
+ end
+ if client.supports_method("textDocument/declaration") then
+ map.n("gD", vim.lsp.buf.declaration, { buffer = bufnr })
+ end
+ if client.supports_method("textDocument/signatureHelp") then
+ require("lsp_signature").on_attach(client, bufnr)
+ map.n("gs", vim.lsp.buf.signature_help, { buffer = bufnr })
+ end
+ if client.supports_method("textDocument/rename") then
+ map.n("gR", vim.lsp.buf.rename, { buffer = bufnr })
+ end
+ if client.supports_method("textDocument/codeAction") then
+ map.n("ga", vim.lsp.buf.code_action, { buffer = bufnr })
+ map.v("ga", vim.lsp.buf.code_action, { buffer = bufnr })
+ end
+
+ local buf_async_format = function()
+ vim.lsp.buf.format(
+ { bufnr = bufnr, async = true, id = client.id })
+ end
+ local buf_sync_format = function()
+ vim.lsp.buf.format(
+ { bufnr = bufnr, async = false, id = client.id })
+ end
+ local buf_async_format_hunks = function()
+ require("cfg.utils").format_hunks(
+ { bufnr = bufnr, async = true, id = client.id })
+ end
+
+ if client.supports_method("textDocument/formatting") then
+ map.n("<leader>f", buf_async_format, { buffer = bufnr })
+ if opts.auto_format then
+ autocmd(
+ "BufWritePre",
+ { buffer = bufnr, callback = buf_sync_format }
+ )
+ end
+ end
+ if client.supports_method("textDocument/rangeFormatting") then
+ map.v("<leader>f", buf_async_format, { buffer = bufnr })
+ map.n("<leader>hf", buf_async_format_hunks, { buffer = bufnr })
+ end
+
+ require("lsp-inlayhints").on_attach(client, bufnr, false)
+ end
+}
diff --git a/home/.config/nvim/lua/cfg/options.lua b/home/.config/nvim/lua/cfg/options.lua
new file mode 100644
index 0000000..1529121
--- /dev/null
+++ b/home/.config/nvim/lua/cfg/options.lua
@@ -0,0 +1,124 @@
+local opt = vim.opt
+
+opt.undofile = true
+opt.swapfile = false
+vim.opt.shadafile = "NONE"
+vim.g.ts_highlight_lua = true
+vim.g.ts_highlight_c = true
+vim.g.ts_highlight_vim = true
+
+opt.showmode = true
+opt.number = true
+opt.cursorline = true
+opt.signcolumn = "auto:2"
+opt.showtabline = 2
+opt.showmatch = true
+
+opt.expandtab = true
+opt.shiftround = true
+opt.shiftwidth = 0
+opt.softtabstop = -1
+opt.tabstop = 4
+
+opt.foldenable = false
+
+opt.splitbelow = true
+opt.splitright = true
+
+opt.linebreak = true
+opt.breakindent = true
+opt.textwidth = 80
+opt.colorcolumn = "+1"
+opt.formatoptions:remove("t")
+
+opt.spelllang:append({ "pt_pt", "es_es" })
+opt.spellfile = vim.fn.stdpath("config") .. "/spell/en.utf-8.add"
+
+opt.cmdheight = 2
+opt.updatetime = 300
+
+opt.shortmess:append({ a = true })
+
+opt.gdefault = true
+opt.synmaxcol = 500
+
+opt.completeopt = { "menu", "menuone", "noselect" }
+opt.scrolloff = 999
+opt.sidescrolloff = 5
+
+opt.clipboard = "unnamedplus"
+
+opt.wildmode = { "longest", "full" }
+
+opt.cpoptions:remove({ "_" })
+
+opt.listchars = {
+ tab = "> ",
+ trail = "·",
+ extends = ">",
+ precedes = "<",
+ nbsp = "+",
+}
+opt.list = true
+
+opt.virtualedit = "block"
+opt.spelloptions = "camel"
+
+vim.g.is_posix = 1
+vim.g.python_host_prog = 0
+vim.g.python3_host_prog = 0
+vim.g.netrw_home = vim.fn.stdpath("data")
+
+vim.g.loaded_netrw = 1
+vim.g.loaded_netrwPlugin = 1
+vim.g.loaded_netrwSettings = 1
+vim.g.loaded_netrwFileHandlers = 1
+vim.g.loaded_gzip = 1
+vim.g.loaded_zip = 1
+vim.g.loaded_zipPlugin = 1
+vim.g.loaded_tar = 1
+vim.g.loaded_tarPlugin = 1
+vim.g.loaded_zipPlugin = 1
+vim.g.loaded_getscript = 1
+vim.g.loaded_getscriptPlugin = 1
+vim.g.loaded_vimball = 1
+vim.g.loaded_vimballPlugin = 1
+vim.g.loaded_2html_plugin = 1
+vim.g.loaded_logipat = 1
+vim.g.loaded_rrhelper = 1
+vim.g.loaded_matchparen = 1
+vim.g.loaded_spec = 1
+
+opt.diffopt:append({
+ ["indent-heuristic"] = true,
+ hiddenoff = true,
+ iblank = true,
+ iwhiteall = true,
+ algorithm = "histogram",
+})
+
+if vim.fn.executable("rg") then
+ opt.grepprg = "rg\\ --vimgrep"
+ opt.grepformat:append("f:%l:%c:%m")
+end
+
+opt.termguicolors = true
+opt.pumblend = 20
+
+opt.foldmethod = "expr"
+opt.foldexpr = "nvim_treesitter#foldexpr()"
+opt.foldenable = false
+
+opt.laststatus = 2
+vim.g.mapleader = " "
+vim.g.maplocalleader = ","
+
+vim.diagnostic.config({
+ virtual_text = {
+ source = "if_many",
+ severity = vim.diagnostic.severity.ERROR,
+ },
+ signs = true,
+ underline = true,
+ update_in_insert = false,
+})
diff --git a/home/.config/nvim/lua/cfg/utils.lua b/home/.config/nvim/lua/cfg/utils.lua
new file mode 100644
index 0000000..abda35d
--- /dev/null
+++ b/home/.config/nvim/lua/cfg/utils.lua
@@ -0,0 +1,24 @@
+local M = {}
+local gitsigns = require("gitsigns")
+
+function M.format_hunks(options)
+ local hunks = require("gitsigns").get_hunks()
+ if not hunks or vim.tbl_isempty(hunks) then
+ return
+ end
+ for _, hunk in ipairs(hunks) do
+ local added = hunk.added
+ if added then
+ local start_line = added.start
+ local count = added.count
+ if start_line and count and start_line > 0 and count > 0 then
+ local end_line = start_line + added.count - 1
+ local range = { start = { start_line, 0 }, ["end"] = { end_line, 0 } }
+ options = vim.tbl_extend("force", { range = range }, options or {})
+ vim.lsp.buf.format(options)
+ end
+ end
+ end
+end
+
+return M
diff --git a/home/.config/nvim/lua/custom/plugins/init.lua b/home/.config/nvim/lua/custom/plugins/init.lua
new file mode 100644
index 0000000..eb720e6
--- /dev/null
+++ b/home/.config/nvim/lua/custom/plugins/init.lua
@@ -0,0 +1,1117 @@
+local map = require("mapper")
+
+return {
+ { "nvim-lua/plenary.nvim", lazy = true },
+ { "tpope/vim-repeat", event = "VeryLazy" },
+ 'tpope/vim-sleuth',
+ {
+ "numToStr/Comment.nvim",
+ config = true,
+ },
+ {
+ "tpope/vim-unimpaired",
+ keys = { "]", "[", "yo" },
+ },
+ { "folke/which-key.nvim", lazy = true },
+ { "kylechui/nvim-surround", config = true },
+ {
+ "dstein64/vim-startuptime",
+ cmd = "StartupTime",
+ },
+ {
+ "folke/persistence.nvim",
+ config = true,
+ event = "BufReadPre",
+ keys = {
+ {
+ "<leader>qs",
+ require("persistence").load,
+ desc =
+ "Restore Session"
+ },
+ {
+ "<leader>ql",
+ function() require("persistence").load({ last = true }) end,
+ desc =
+ "Restore Last Session"
+ },
+ {
+ "<leader>qd",
+ require("persistence").stop,
+ desc =
+ "Don't Save Current Session"
+ },
+ },
+ },
+ "xiyaowong/nvim-cursorword",
+ {
+ "sainnhe/gruvbox-material",
+ priority = 1000,
+ config = function()
+ vim.g.gruvbox_material_background = "hard"
+ vim.g.gruvbox_material_enable_bold = 1
+ vim.g.gruvbox_material_enable_italic = 1
+ vim.g.gruvbox_material_better_performance = 1
+ vim.g.gruvbox_material_palette = "original"
+
+ vim.cmd([[ colorscheme gruvbox-material]])
+ end
+ },
+ {
+ "aserowy/tmux.nvim",
+ config = true,
+ },
+ {
+ "Julian/vim-textobj-variable-segment",
+ dependencies = { "kana/vim-textobj-user" },
+ },
+ { "mzlogin/vim-markdown-toc", ft = "markdown" },
+ {
+ "norcalli/nvim-colorizer.lua",
+ event = "BufRead",
+ config = true
+ },
+ {
+ "lewis6991/hover.nvim",
+ keys = { { "K", require "hover".hover }, { "gK", require "hover"
+ .hover_select }, { "gh", require "hover".hover },
+ { "gH", require "hover".hover_select } },
+ opts = {
+ init = function()
+ require("hover.providers.lsp")
+ require('hover.providers.gh')
+ require('hover.providers.man')
+ -- require('hover.providers.dictionary')
+ end,
+ },
+ },
+ { 'akinsho/git-conflict.nvim', config = true },
+ {
+ "lukas-reineke/indent-blankline.nvim",
+ config = function()
+ local highlight = {
+ "RainbowRed",
+ "RainbowYellow",
+ "RainbowBlue",
+ "RainbowOrange",
+ "RainbowGreen",
+ "RainbowViolet",
+ "RainbowCyan",
+ }
+ local hooks = require "ibl.hooks"
+ -- create the highlight groups in the highlight setup hook, so they are reset
+ -- every time the colorscheme changes
+ hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
+ vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" })
+ vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" })
+ vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" })
+ vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" })
+ vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" })
+ vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" })
+ vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" })
+ end)
+
+ vim.g.rainbow_delimiters = { highlight = highlight }
+ require("ibl").setup { scope = { highlight = highlight } }
+
+ hooks.register(hooks.type.SCOPE_HIGHLIGHT,
+ hooks.builtin.scope_highlight_from_extmark)
+ end
+ },
+ {
+ "monaqa/dial.nvim",
+ config = function()
+ map.n("]i", require("dial.map").inc_normal())
+ map.n("[i", require("dial.map").dec_normal())
+ map.v("]i", require("dial.map").inc_visual())
+ map.v("[i", require("dial.map").dec_visual())
+ end
+ },
+ {
+ "iamcco/markdown-preview.nvim",
+ build = "cd app && yarn install",
+ ft = "markdown",
+ config = function()
+ vim.api.nvim_command([[
+ function! g:OpenNewWindow(url)
+ silent exec "Start! librewolf --new-window " . a:url
+ endfunction
+ ]])
+ vim.g.mkdp_browserfunc = "g:OpenNewWindow"
+ end,
+ },
+ "gpanders/editorconfig.nvim",
+ {
+ "kwkarlwang/bufresize.nvim",
+ config = true
+ },
+ "kovetskiy/sxhkd-vim",
+ "tmux-plugins/vim-tmux",
+ "chrisbra/csv.vim",
+ "martinda/Jenkinsfile-vim-syntax",
+ "rhysd/vim-llvm",
+ "MTDL9/vim-log-highlighting",
+ "raimon49/requirements.txt.vim",
+ "wgwoods/vim-systemd-syntax",
+ {
+ "NeogitOrg/neogit",
+ dependencies = {
+ "nvim-lua/plenary.nvim",
+ },
+ config = function()
+ require("neogit").setup({
+ disable_commit_confirmation = true,
+ kind = "split",
+ console_timeout = 5000,
+ auto_show_console = false,
+ })
+ map.n("<leader>ng", require "neogit".open)
+ end,
+ },
+ {
+ "ruifm/gitlinker.nvim",
+ keys = {
+ { "<leader>gy", function() require 'gitlinker'.get_buf_range_url("n") end },
+ {
+ "<leader>gy",
+ function()
+ require 'gitlinker'.get_buf_range_url("v")
+ end,
+ mode = "v"
+ },
+ },
+ dependencies = {
+ "nvim-lua/plenary.nvim",
+ },
+ config = function()
+ require "gitlinker".setup({
+ callbacks = {
+ ["personal"] = function(url_data)
+ url_data.host = "github.com"
+ return require "gitlinker.hosts".get_github_type_url(url_data)
+ end,
+ ["work"] = function(url_data)
+ url_data.host = "github.com"
+ return require "gitlinker.hosts".get_github_type_url(url_data)
+ end,
+ ["git.strisemarx.com"] = function(url_data)
+ local url = require "gitlinker.hosts".get_base_https_url(url_data)
+ url = url .. "/tree/" .. url_data.file .. "?id=" .. url_data.rev
+ if url_data.lstart then
+ url = url .. "#n" .. url_data.lstart
+ end
+ return url
+ end
+ },
+ })
+ end,
+ },
+ {
+ "lewis6991/gitsigns.nvim",
+ event = "BufRead",
+ opts = {
+ signs = {
+ change = { show_count = true },
+ delete = { show_count = true },
+ topdelete = { show_count = true },
+ changedelete = { show_count = true },
+ },
+ numhl = true,
+ _extmark_signs = true,
+ _threaded_diff = true,
+ _signs_staged_enable = true,
+ on_attach = function(bufnr)
+ local gs = package.loaded.gitsigns
+
+ -- Navigation
+ map.n(']c', function()
+ if vim.wo.diff then return ']c' end
+ vim.schedule(function() gs.next_hunk() end)
+ return '<Ignore>'
+ end, { expr = true }, bufnr)
+
+ map.n('[c', function()
+ if vim.wo.diff then return '[c' end
+ vim.schedule(function() gs.prev_hunk() end)
+ return '<Ignore>'
+ end, { expr = true }, bufnr)
+
+ -- Actions
+ map.nvcmd('<leader>hs', "Gitsigns stage_hunk", nil, bufnr)
+ map.nvcmd('<leader>hr', "Gitsigns reset_hunk", nil, bufnr)
+ map.n('<leader>hS', gs.stage_buffer, nil, bufnr)
+ map.n('<leader>hu', gs.undo_stage_hunk, nil, bufnr)
+ map.n('<leader>hR', gs.reset_buffer, nil, bufnr)
+ map.n('<leader>hp', gs.preview_hunk, nil, bufnr)
+ map.n('<leader>hb', function() gs.blame_line { full = true } end, nil,
+ bufnr)
+ map.n('<leader>tb', gs.toggle_current_line_blame, nil, bufnr)
+ map.n('<leader>hd', gs.diffthis, nil, bufnr)
+ map.n('<leader>hD', function() gs.diffthis('~') end, nil, bufnr)
+ map.n('<leader>hc', gs.change_base, nil, bufnr)
+ map.n('<leader>hC', function() gs.change_base('~') end, nil, bufnr)
+ map.n('<leader>td', gs.toggle_deleted, nil, bufnr)
+ map.n('<leader>tw', gs.toggle_word_diff, nil, bufnr)
+ map.n('<leader>tl', gs.toggle_linehl, nil, bufnr)
+
+ -- Text object
+ map.map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>', nil, bufnr)
+ end
+ },
+ dependencies = {
+ "nvim-lua/plenary.nvim",
+ },
+ },
+ {
+ "nvim-telescope/telescope.nvim",
+ config = function()
+ local actions = require("telescope.actions")
+ require("telescope").setup({
+ defaults = {
+ sorting_strategy = "ascending",
+ layout_config = {
+ prompt_position = "top",
+ },
+ scroll_strategy = "cycle",
+ selection_strategy = "follow",
+ color_devicons = false,
+ mappings = {
+ i = {
+ ["<c-j>"] = actions.move_selection_next,
+ ["<c-k>"] = actions.move_selection_previous,
+ },
+ },
+ extensions = {
+ fzf = {
+ fuzzy = true, -- false will only do exact matching
+ override_generic_sorter = true, -- override the generic sorter
+ override_file_sorter = true, -- override the file sorter
+ case_mode = "smart_case", -- or "ignore_case" or "respect_case"
+ },
+ ["ui-select"] = {
+ require("telescope.themes").get_dropdown({
+ -- even more opts
+ }),
+ },
+ },
+ },
+ })
+ require("telescope").load_extension("fzf")
+ require("telescope").load_extension("ui-select")
+
+ local b = require("telescope.builtin")
+
+ map.n("<localleader>p", b.planets)
+ map.n("<localleader>B", b.builtin)
+ map.n("<localleader>/", b.live_grep)
+ map.n("<localleader>?", b.grep_string)
+ map.n("<localleader>f", function()
+ b.find_files({
+ find_command = {
+ "fd",
+ "--type",
+ "file",
+ "--follow",
+ "--hidden",
+ "--exclude",
+ ".git",
+ },
+ })
+ end)
+ map.n("<localleader>b", function()
+ b.buffers({ sort_lastused = true, initial_mode = "normal" })
+ end)
+
+ map.n("<localleader>t", b.treesitter)
+
+ map.n("<localleader>c", b.commands)
+ map.n("<localleader>h", b.help_tags)
+ map.n("<localleader>m", b.man_pages)
+ map.n("<localleader>k", b.keymaps)
+ map.n("<localleader>Q", function()
+ b.quickfix({ initial_mode = "normal" })
+ end)
+ map.n("<localleader>L", function()
+ b.loclist({ initial_mode = "normal" })
+ end)
+ map.n("<localleader>R", function()
+ b.registers({ initial_mode = "normal" })
+ end)
+ map.n("<localleader>A", b.autocommands)
+
+ map.n("gd", function()
+ b.lsp_definitions({ initial_mode = "normal" })
+ end)
+ map.n("gvd", function()
+ b.lsp_definitions({ initial_mode = "normal", jump_type = "vsplit" })
+ end)
+ map.n("gxd", function()
+ b.lsp_definitions({ initial_mode = "normal", jump_type = "split" })
+ end)
+ map.n("gtd", function()
+ b.lsp_definitions({ initial_mode = "normal", jump_type = "tab" })
+ end)
+ map.n("gi", function()
+ b.lsp_implementations({ initial_mode = "normal" })
+ end)
+ map.n("gvi", function()
+ b.lsp_implementations({ initial_mode = "normal", jump_type = "vsplit" })
+ end)
+ map.n("gxi", function()
+ b.lsp_implementations({ initial_mode = "normal", jump_type = "split" })
+ end)
+ map.n("gti", function()
+ b.lsp_implementations({ initial_mode = "normal", jump_type = "tab" })
+ end)
+ map.n("go", b.lsp_document_symbols)
+ map.n("gS", b.lsp_dynamic_workspace_symbols)
+ map.n("ge", function()
+ b.lsp_document_diagnostics({ initial_mode = "normal" })
+ end)
+ map.n("gE", function()
+ b.lsp_workspace_diagnostics({ initial_mode = "normal" })
+ end)
+ map.n("gr", function()
+ b.lsp_references({ initial_mode = "normal" })
+ end)
+ map.n("gic", function()
+ b.lsp_incoming_calls({ initial_mode = "normal" })
+ end)
+ map.n("goc", function()
+ b.lsp_outgoing_calls({ initial_mode = "normal" })
+ end)
+ end,
+ dependencies = {
+ "nvim-lua/plenary.nvim",
+ {
+ "nvim-telescope/telescope-fzf-native.nvim",
+ build = "make",
+ },
+ "nvim-telescope/telescope-ui-select.nvim",
+ },
+ },
+ {
+ "mfussenegger/nvim-dap",
+ config = function()
+ local dap = require("dap")
+
+ dap.defaults.fallback.force_external_terminal = true
+ dap.defaults.fallback.external_terminal = {
+ command = "/usr/bin/st",
+ args = { "-e" },
+ }
+
+ dap.defaults.fallback.terminal_win_cmd = "50vsplit new"
+
+ local function get_env_vars()
+ local variables = {}
+ for k, v in pairs(vim.fn.environ()) do
+ table.insert(variables, string.format("%s=%s", k, v))
+ end
+ return variables
+ end
+
+ dap.adapters.lldb = {
+ type = "executable",
+ command = "/usr/bin/lldb-vscode",
+ name = "lldb",
+ }
+
+ local function str_split(inputstr, sep)
+ sep = sep or "%s"
+ local t = {}
+ for str in inputstr:gmatch("([^" .. sep .. "]+)") do
+ table.insert(t, str)
+ end
+ return t
+ end
+
+ local _cmd = nil
+
+ local function get_cmd()
+ if _cmd then
+ return _cmd
+ end
+ local clipboard_cmd = vim.fn.getreg("+")
+ _cmd = vim.fn.input({
+ prompt = "Command to execute: ",
+ default = clipboard_cmd
+ })
+ return _cmd
+ end
+
+ local function get_program()
+ return str_split(get_cmd())[1]
+ end
+
+ local function get_args()
+ local argv = str_split(get_cmd())
+ local args = {}
+
+ if #argv < 2 then
+ return {}
+ end
+
+ for i = 2, #argv do
+ args[#args + 1] = argv[i]
+ end
+
+ return args
+ end
+
+ dap.configurations.cpp = {
+ {
+ name = "Launch",
+ type = "lldb",
+ request = "launch",
+ cwd = "${workspaceFolder}",
+ program = get_program,
+ stopOnEntry = true,
+ args = get_args,
+ env = get_env_vars,
+ runInTerminal = true,
+ },
+ {
+ -- If you get an "Operation not permitted" error using this, try disabling YAMA:
+ -- echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
+ name = "Attach to process",
+ type = "lldb",
+ request = "attach",
+ pid = require('dap.utils').pick_process,
+ },
+ }
+
+ dap.configurations.c = dap.configurations.cpp
+ dap.configurations.rust = dap.configurations.cpp
+
+ local get_python_path = function()
+ local venv_path = os.getenv("VIRTUAL_ENV")
+ if venv_path then
+ return venv_path .. "/bin/python"
+ end
+ return "/usr/bin/python"
+ end
+
+ require("dap-python").setup(get_python_path())
+
+ dap.adapters.nlua = function(callback, config)
+ callback({ type = "server", host = config.host, port = config.port })
+ end
+
+ dap.configurations.lua = {
+ {
+ type = "nlua",
+ request = "attach",
+ name = "Attach to running Neovim instance",
+ host = function()
+ local value = vim.fn.input("Host [127.0.0.1]: ")
+ if value ~= "" then
+ return value
+ end
+ return "127.0.0.1"
+ end,
+ port = function()
+ local val = tonumber(vim.fn.input("Port: "))
+ assert(val, "Please provide a port number")
+ return val
+ end,
+ },
+ }
+
+ dap.repl.commands = vim.tbl_extend("force", dap.repl.commands, {
+ continue = { "continue", "c" },
+ next_ = { "next", "n" },
+ back = { "back", "b" },
+ reverse_continue = { "reverse-continue", "rc" },
+ into = { "into" },
+ into_target = { "into_target" },
+ out = { "out" },
+ scopes = { "scopes" },
+ threads = { "threads" },
+ frames = { "frames" },
+ exit = { "exit", "quit", "q" },
+ up = { "up" },
+ down = { "down" },
+ goto_ = { "goto" },
+ capabilities = { "capabilities", "cap" },
+ -- add your own commands
+ custom_commands = {
+ ["echo"] = function(text)
+ dap.repl.append(text)
+ end,
+ },
+ })
+
+ map.n("<F4>", dap.close)
+ map.n("<F5>", dap.continue)
+ map.n("<F10>", dap.step_over)
+ map.n("<F11>", dap.step_into)
+ map.n("<F12>", dap.step_out)
+ map.n("<leader>b", dap.toggle_breakpoint)
+ map.n("<leader>B", function()
+ dap.set_breakpoint(vim.fn.input("Breakpoint condition: "))
+ end)
+ map.n("<leader>lp", function()
+ dap.set_breakpoint(nil, nil, vim.fn.input("Log point message: "))
+ end)
+ map.n("<leader>dr", dap.repl.open)
+ map.n("<leader>dl", dap.run_last)
+ map.n("<F2>", dap.list_breakpoints)
+
+ local dapui = require("dapui")
+ dap.listeners.after.event_initialized["dapui_config"] = function()
+ dapui.open()
+ end
+ dap.listeners.before.event_terminated["dapui_config"] = function()
+ dapui.close()
+ end
+ dap.listeners.before.event_exited["dapui_config"] = function()
+ dapui.close()
+ end
+ map.n("<leader>du", dapui.toggle)
+ map.v("<leader>de", dapui.eval)
+ end,
+ dependencies = {
+ {
+ "rcarriga/nvim-dap-ui",
+ opts = {
+ icons = { expanded = "-", collapsed = "+", current_frame = "*" },
+ controls = { enabled = false },
+ layouts = {
+ {
+ elements = {
+ -- Elements can be strings or table with id and size keys.
+ "scopes",
+ "breakpoints",
+ "stacks",
+ "watches",
+ },
+ size = 40,
+ position = "left",
+ },
+ {
+ elements = {
+ "repl",
+ },
+ size = 0.25, -- 25% of total lines
+ position = "bottom",
+ },
+ },
+ },
+ },
+ {
+ "mfussenegger/nvim-dap-python",
+ keys = {
+ { "gm", function()
+ require("dap-python").test_method()
+ end },
+ {
+ "g<cr>",
+ function()
+ require("dap-python").debug_selection()
+ end,
+ mode = "v"
+ },
+ },
+ },
+ "jbyuki/one-small-step-for-vimkind",
+ {
+ "theHamsta/nvim-dap-virtual-text",
+ config = true,
+ dependencies = { "nvim-treesitter/nvim-treesitter" }
+ }
+ },
+ },
+ {
+ 'nvim-treesitter/nvim-treesitter',
+ dependencies = {
+ 'nvim-treesitter/nvim-treesitter-textobjects',
+ "nvim-treesitter/nvim-treesitter-refactor",
+ "RRethy/nvim-treesitter-textsubjects",
+ "theHamsta/nvim-treesitter-pairs",
+ "RRethy/nvim-treesitter-endwise",
+ },
+ build = ":TSUpdate",
+ config = function()
+ require("nvim-treesitter.configs").setup({
+ ensure_installed = {
+ "bash",
+ "c",
+ "cmake",
+ "comment",
+ "cpp",
+ "css",
+ "cuda",
+ "diff",
+ "dockerfile",
+ "fortran",
+ "git_rebase",
+ "gitattributes",
+ "gitcommit",
+ "gitignore",
+ "go",
+ "html",
+ "javascript",
+ "jsdoc",
+ "json",
+ "llvm",
+ "lua",
+ "make",
+ "markdown",
+ "markdown_inline",
+ "ninja",
+ "python",
+ "regex",
+ "rust",
+ "sql",
+ "todotxt",
+ "toml",
+ "typescript",
+ "vim",
+ "vimdoc",
+ "yaml"
+ },
+ -- ignore_install = { "phpdoc" },
+ highlight = {
+ enable = true, -- false will disable the whole extension
+ additional_vim_regex_highlighting = false,
+ },
+ incremental_selection = {
+ enable = true,
+ keymaps = {
+ init_selection = "gnn",
+ node_incremental = "grn",
+ scope_incremental = "grc",
+ node_decremental = "grm",
+ },
+ },
+ indent = { enable = true },
+ refactor = {
+ highlight_definitions = { enable = true },
+ highlight_current_scope = { enable = true },
+ smart_rename = { enable = true, keymaps = { smart_rename = "grr" } },
+ navigation = {
+ enable = true,
+ keymaps = {
+ goto_definition = "gnd",
+ list_definitions = "gnD",
+ list_definitions_toc = "gO",
+ goto_next_usage = "<a-*>",
+ goto_previous_usage = "<a-#>",
+ },
+ },
+ },
+ textobjects = {
+ select = {
+ enable = true,
+ -- Automatically jump forward to textobj, similar to targets.vim
+ lookahead = true,
+ keymaps = {
+ -- You can use the capture groups defined in textobjects.scm
+ ["af"] = "@function.outer",
+ ["if"] = "@function.inner",
+ ["ac"] = "@class.outer",
+ ["ic"] = "@class.inner",
+ },
+ },
+ swap = {
+ enable = true,
+ swap_next = { ["<leader>a"] = "@parameter.inner" },
+ swap_previous = { ["<leader>A"] = "@parameter.inner" },
+ },
+ move = {
+ enable = true,
+ set_jumps = true, -- whether to set jumps in the jumplist
+ goto_next_start = {
+ ["]m"] = "@function.outer",
+ ["]]"] = "@class.outer",
+ },
+ goto_next_end = {
+ ["]M"] = "@function.outer",
+ ["]["] = "@class.outer",
+ },
+ goto_previous_start = {
+ ["[m"] = "@function.outer",
+ ["[["] = "@class.outer",
+ },
+ goto_previous_end = {
+ ["[M"] = "@function.outer",
+ ["[]"] = "@class.outer",
+ },
+ },
+ lsp_interop = {
+ enable = true,
+ peek_definition_code = {
+ ["df"] = "@function.outer",
+ ["dF"] = "@class.outer",
+ },
+ },
+ },
+ matchup = {
+ enable = true,
+ },
+ pairs = {
+ enable = true,
+ goto_right_end = false,
+ keymaps = { goto_partner = "%" },
+ },
+ textsubjects = {
+ enable = true,
+ keymaps = { ["."] = "textsubjects-smart", [";"] = "textsubjects-big" },
+ },
+ tree_docs = {
+ enable = true,
+ },
+ endwise = {
+ enable = true,
+ },
+ })
+ end
+ },
+ {
+ "hrsh7th/nvim-cmp",
+ event = "InsertEnter",
+ config = function()
+ local cmp = require("cmp")
+
+ local has_words_before = function()
+ local line, col = unpack(vim.api.nvim_win_get_cursor(0))
+ return col ~= 0
+ and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]
+ :sub(col, col)
+ :match("%s")
+ == nil
+ end
+
+ local luasnip = require("luasnip")
+
+ cmp.setup({
+ snippet = {
+ expand = function(args)
+ require("luasnip").lsp_expand(args.body)
+ end,
+ },
+ mapping = {
+ ["<Tab>"] = cmp.mapping(function(fallback)
+ if cmp.visible() then
+ cmp.select_next_item()
+ elseif luasnip.expand_or_jumpable() then
+ luasnip.expand_or_jump()
+ elseif has_words_before() then
+ cmp.complete()
+ else
+ fallback()
+ end
+ end, {
+ "i",
+ "s",
+ }),
+ ["<S-Tab>"] = cmp.mapping(function(fallback)
+ if cmp.visible() then
+ cmp.select_prev_item()
+ elseif luasnip.jumpable(-1) then
+ luasnip.jump(-1)
+ else
+ fallback()
+ end
+ end, {
+ "i",
+ "s",
+ }),
+ ["<CR>"] = cmp.mapping.confirm({
+ behavior = cmp.ConfirmBehavior.Replace,
+ select = true,
+ }),
+ },
+ formatting = {
+ format = function(entry, vim_item)
+ -- set a name for each source
+ vim_item.menu = ({
+ path = "[Path]",
+ nvim_lsp = "[LSP]",
+ luasnip = "[LuaSnip]",
+ dap = "[dap]",
+ })[entry.source.name]
+ return vim_item
+ end,
+ },
+ sources = {
+ { name = "nvim_lsp" },
+ { name = "luasnip" },
+ { name = "path" },
+ { name = "nvim_lsp_signature_help" },
+ },
+ })
+
+ require "cmp".setup.filetype(
+ { "dap-repl", "dapui_watches", "dapui_hover" }, {
+ sources = {
+ { name = "dap" },
+ },
+ })
+ end,
+ dependencies = {
+ "hrsh7th/cmp-nvim-lsp",
+ "hrsh7th/cmp-path",
+ "hrsh7th/cmp-nvim-lsp-signature-help",
+ "rcarriga/cmp-dap",
+ {
+ "saadparwaiz1/cmp_luasnip",
+ dependencies = {
+ {
+ "L3MON4D3/LuaSnip",
+ event = "InsertCharPre",
+ keys = {
+ { "<c-j>", function() require "luasnip".jump(1) end, mode = "i" },
+ { "<c-k>", function() require "luasnip".jump(-1) end, mode = "i" },
+ },
+ config = function()
+ require("luasnip/loaders/from_vscode").lazy_load()
+ end,
+ dependencies = {
+ "kitagry/vs-snippets",
+ "rafamadriz/friendly-snippets",
+ "kkonghao/snippet-dog",
+ },
+ }
+ },
+ },
+ },
+ },
+ {
+ 'neovim/nvim-lspconfig',
+ config = function()
+ local lspconfig = require("lspconfig")
+ -- Enable (broadcasting) snippet capability for completion
+ local capabilities = vim.lsp.protocol.make_client_capabilities()
+ capabilities.textDocument.completion.completionItem.snippetSupport = true
+ capabilities.workspace.didChangeWatchedFiles.dynamicRegistration = true
+ capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
+
+ lspconfig.util.default_config = vim.tbl_extend(
+ "force",
+ lspconfig.util.default_config,
+ {
+ on_attach = require "cfg.lsp".on_attach_wrapper,
+ capabilities = capabilities,
+ flags = {
+ debounce_text_changes = 150,
+ },
+ }
+ )
+
+ local function switch_source_header_splitcmd(bufnr, splitcmd)
+ bufnr = lspconfig.util.validate_bufnr(bufnr)
+ local clangd_client = lspconfig.util.get_active_client_by_name(
+ bufnr,
+ "clangd"
+ )
+ local params = { uri = vim.uri_from_bufnr(bufnr) }
+ if clangd_client then
+ clangd_client.request(
+ "textDocument/switchSourceHeader",
+ params,
+ function(err, result)
+ if err then
+ error(tostring(err))
+ end
+ if not result then
+ print("Corresponding file cannot be determined")
+ return
+ end
+ vim.api.nvim_command(splitcmd .. " " .. vim.uri_to_fname(result))
+ end,
+ bufnr
+ )
+ else
+ print(
+ "method textDocument/switchSourceHeader is not supported by any servers active on the current buffer"
+ )
+ end
+ end
+
+ local servers = {
+ bashls = {},
+ fortls = {},
+ lua_ls = {
+ on_attach = function(client, bufnr)
+ require("cfg.lsp").on_attach_wrapper(
+ client,
+ bufnr,
+ { auto_format = true }
+ )
+ end,
+ settings = {
+ Lua = {
+ completion = {
+ callSnippet = "Both",
+ displayContext = 1,
+ },
+ hint = {
+ enable = true,
+ }
+ }
+ },
+ },
+ ruff_lsp = {},
+ pyright = {},
+ clangd = {
+ cmd = {
+ "clangd",
+ "--enable-config",
+ "--completion-parse=auto",
+ "--completion-style=bundled",
+ "--header-insertion=iwyu",
+ "--header-insertion-decorators",
+ "--inlay-hints",
+ "--suggest-missing-includes",
+ "--folding-ranges",
+ "--function-arg-placeholders",
+ "--pch-storage=memory",
+ },
+ commands = {
+ ClangdSwitchSourceHeader = {
+ function()
+ switch_source_header_splitcmd(0, "edit")
+ end,
+ description = "Open source/header in current buffer",
+ },
+ ClangdSwitchSourceHeaderVSplit = {
+ function()
+ switch_source_header_splitcmd(0, "vsplit")
+ end,
+ description = "Open source/header in a new vsplit",
+ },
+ ClangdSwitchSourceHeaderSplit = {
+ function()
+ switch_source_header_splitcmd(0, "split")
+ end,
+ description = "Open source/header in a new split",
+ },
+ ClangdSwitchSourceHeaderTab = {
+ function()
+ switch_source_header_splitcmd(0, "tabedit")
+ end,
+ description = "Open source/header in a new tab",
+ },
+ },
+ on_attach = function(client, bufnr)
+ require("cfg.lsp").on_attach_wrapper(client, bufnr)
+ local cmpconfig = require("cmp.config")
+ local compare = require("cmp.config.compare")
+ cmpconfig.set_buffer({
+ sorting = {
+ comparators = {
+ compare.offset,
+ compare.exact,
+ -- compare.scopes,
+ require("clangd_extensions.cmp_scores"),
+ compare.recently_used,
+ compare.locality,
+ compare.kind,
+ compare.sort_text,
+ compare.length,
+ compare.order,
+ },
+ },
+ }, bufnr)
+ vim.api.nvim_create_augroup("clang-format", {})
+ vim.api.nvim_create_autocmd("BufWritePre", {
+ group = "clang-format",
+ buffer = bufnr,
+ callback = function()
+ if vim.fn.expand('%:p:h'):find("test") then
+ return
+ end
+ require("cfg.utils").format_hunks({
+ bufnr = bufnr,
+ async = false,
+ id = client.id
+ })
+ end,
+ })
+ map.ncmd("gH", "ClangdSwitchSourceHeader")
+ map.ncmd("gvH", "ClangdSwitchSourceHeaderVSplit")
+ map.ncmd("gxH", "ClangdSwitchSourceHeaderSplit")
+ map.ncmd("gtH", "ClangdSwitchSourceHeaderSplit")
+
+ require("clangd_extensions.inlay_hints").setup_autocmd()
+ require("clangd_extensions.inlay_hints").set_inlay_hints()
+ end,
+ init_options = {
+ usePlaceholders = true,
+ completeUnimported = true,
+ clangdFileStatus = true,
+ },
+ },
+ }
+
+ for server, config in pairs(servers) do
+ local default_config = lspconfig[server].default_config or
+ lspconfig[server].document_config.default_config
+ local cmd = config.cmd or default_config.cmd
+ if vim.fn.executable(cmd[1]) == 1 then lspconfig[server].setup(config) end
+ end
+ end,
+ dependencies = {
+ "hrsh7th/cmp-nvim-lsp",
+ "ray-x/lsp_signature.nvim",
+ "jubnzv/virtual-types.nvim",
+ { 'folke/neodev.nvim', opts = {} },
+ { "lvimuser/lsp-inlayhints.nvim", config = true },
+ {
+ "p00f/clangd_extensions.nvim",
+ config = function()
+ require("clangd_extensions").setup({
+ })
+ end
+ },
+ },
+ },
+ {
+ 'nvim-lualine/lualine.nvim',
+ opts = {
+ options = {
+ icons_enabled = false,
+ theme = 'gruvbox_dark',
+ component_separators = '',
+ section_separators = '|',
+ },
+ sections = {
+ lualine_a = { 'filetype', { 'filename', path = 1 } },
+ lualine_b = { '%l/%L:%c:%o' },
+ lualine_c = { 'diff' },
+ lualine_x = { 'searchcount, selectioncount' },
+ lualine_y = {},
+ lualine_z = { 'diagnostics' }
+ },
+ inactive_sections = {
+ lualine_a = { 'filename' },
+ lualine_b = {},
+ lualine_c = {},
+ lualine_x = {},
+ lualine_y = {},
+ lualine_z = {}
+ },
+ },
+ },
+ {
+ "nvimtools/none-ls.nvim",
+ config = function()
+ local nls = require("null-ls")
+ nls.setup({
+ on_attach = function(client, bufnr)
+ require("cfg.lsp").on_attach_wrapper(
+ client,
+ bufnr,
+ { auto_format = true }
+ )
+ end,
+ sources = {
+ nls.builtins.formatting.black,
+ }
+ })
+ end,
+ },
+ "https://gitlab.com/HiPhish/rainbow-delimiters.nvim",
+}
diff --git a/home/.config/nvim/lua/mapper.lua b/home/.config/nvim/lua/mapper.lua
new file mode 100644
index 0000000..c31aeca
--- /dev/null
+++ b/home/.config/nvim/lua/mapper.lua
@@ -0,0 +1,84 @@
+local M = {}
+
+M.map = function(mode, keys, action, opts, bufnr)
+ opts = vim.tbl_extend("force", { silent = true, buffer = bufnr }, opts or {})
+ vim.keymap.set(mode, keys, action, opts)
+end
+
+M.cmdi = function(mode, keys, action, opts, bufnr)
+ opts = vim.tbl_extend("force", { silent = false }, opts or {})
+ M.map(mode, keys, ":" .. action, opts, bufnr)
+end
+
+M.cmd = function(mode, keys, action, opts, bufnr)
+ M.map(mode, keys, "<cmd>" .. action .. "<cr>", opts, bufnr)
+end
+
+M.plug = function(mode, keys, action, opts, bufnr)
+ M.map(mode, keys, "<Plug>" .. action, opts, bufnr)
+end
+
+M.n = function(keys, action, opts, bufnr)
+ M.map("n", keys, action, opts, bufnr)
+end
+M.ncmdi = function(keys, action, opts, bufnr)
+ M.cmdi("n", keys, action, opts, bufnr)
+end
+M.ncmd = function(keys, action, opts, bufnr)
+ M.cmd("n", keys, action, opts, bufnr)
+end
+M.nplug = function(keys, action, opts, bufnr)
+ M.plug("n", keys, "(" .. action .. ")", opts, bufnr)
+end
+
+M.v = function(keys, action, opts, bufnr)
+ M.map("v", keys, action, opts, bufnr)
+end
+M.vcmdi = function(keys, action, opts, bufnr)
+ opts = vim.tbl_extend("force", { silent = false }, opts or {})
+ M.v(keys, ":" .. action, opts, bufnr)
+end
+M.vcmd = function(keys, action, opts, bufnr)
+ M.vcmdi(keys, action .. "<cr>", opts, bufnr)
+end
+M.vplug = function(keys, action, opts, bufnr)
+ M.plug("v", keys, "(" .. action .. ")", opts, bufnr)
+end
+
+M.nv = function(keys, action, opts, bufnr)
+ M.map({ "n", "v" }, keys, action, opts, bufnr)
+end
+M.nvcmdi = function(keys, action, opts, bufnr)
+ M.ncmdi(keys, action, opts, bufnr)
+ M.vcmdi(keys, action, opts, bufnr)
+end
+M.nvcmd = function(keys, action, opts, bufnr)
+ M.ncmd(keys, action, opts, bufnr)
+ M.vcmd(keys, action, opts, bufnr)
+end
+M.nvplug = function(keys, action, opts, bufnr)
+ M.plug({ "n", "v" }, keys, "(" .. action .. ")", opts, bufnr)
+end
+
+M.i = function(keys, action, opts, bufnr)
+ M.map("i", keys, action, opts, bufnr)
+end
+M.iplug = function(keys, action, opts, bufnr)
+ opts = vim.tbl_extend("force", { silent = false }, opts or {})
+ M.plug("i", keys, action, opts, bufnr)
+end
+
+M.t = function(keys, action, opts, bufnr)
+ M.map("t", keys, action, opts, bufnr)
+end
+M.tcmdi = function(keys, action, opts, bufnr)
+ M.cmdi("t", keys, action, opts, bufnr)
+end
+M.tcmd = function(keys, action, opts, bufnr)
+ M.cmd("t", keys, action, opts, bufnr)
+end
+M.tplug = function(keys, action, opts, bufnr)
+ M.plug("t", keys, action, opts, bufnr)
+end
+
+return M