From 0860db73ae6fd9a6f6347219d820bf026a6b8b91 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Sun, 27 Sep 2026 17:38:39 +0200 Subject: * MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automated-commit-by: dots Signed-off-by: Robert Günzler --- .config/nvim/lua/config/autoall.lua | 35 ++++++++++ .config/nvim/lua/config/keymaps.lua | 16 +++-- .config/nvim/lua/config/lsp.lua | 5 +- .config/nvim/lua/config/options.lua | 7 ++ .config/nvim/lua/config/snippets.lua | 84 +++++++++--------------- .config/nvim/lua/config/templates.lua | 53 +++++++++++++++ .config/nvim/lua/mod/gh.lua | 86 +++++++++++++++++++++++++ .config/nvim/lua/mod/git.lua | 23 +++++++ .config/nvim/lua/mod/jobs.lua | 68 ++++++++++++++++++++ .config/nvim/lua/mod/termopen.lua | 102 +++++++++++++++++++++++++++++ .config/nvim/lua/mod/utils.lua | 15 +++++ .config/nvim/lua/mod/win.lua | 110 ++++++++++++++++++++++++++++++++ .config/nvim/lua/plugins/blink.lua | 23 +++++-- .config/nvim/lua/plugins/calcium.lua | 1 + .config/nvim/lua/plugins/colorizer.lua | 5 +- .config/nvim/lua/plugins/colors.lua | 12 ++++ .config/nvim/lua/plugins/diff.lua | 47 ++++++++++++++ .config/nvim/lua/plugins/fzf.lua | 98 +++++++++++++++++++++++----- .config/nvim/lua/plugins/gentoo.lua | 1 + .config/nvim/lua/plugins/git.lua | 7 +- .config/nvim/lua/plugins/haunt.lua | 47 ++++++++++++++ .config/nvim/lua/plugins/icons.lua | 1 + .config/nvim/lua/plugins/indent.lua | 1 + .config/nvim/lua/plugins/lsp.lua | 29 ++++++++- .config/nvim/lua/plugins/markdown.lua | 2 + .config/nvim/lua/plugins/mini.lua | 4 ++ .config/nvim/lua/plugins/minimap.lua | 13 ++++ .config/nvim/lua/plugins/oil.lua | 1 + .config/nvim/lua/plugins/snippets.lua | 1 + .config/nvim/lua/plugins/treesitter.lua | 5 ++ .config/nvim/lua/plugins/whichkey.lua | 10 +++ 31 files changed, 824 insertions(+), 88 deletions(-) create mode 100644 .config/nvim/lua/config/autoall.lua create mode 100644 .config/nvim/lua/config/templates.lua create mode 100644 .config/nvim/lua/mod/gh.lua create mode 100644 .config/nvim/lua/mod/git.lua create mode 100644 .config/nvim/lua/mod/jobs.lua create mode 100644 .config/nvim/lua/mod/termopen.lua create mode 100644 .config/nvim/lua/mod/utils.lua create mode 100644 .config/nvim/lua/mod/win.lua create mode 100644 .config/nvim/lua/plugins/colors.lua create mode 100644 .config/nvim/lua/plugins/diff.lua create mode 100644 .config/nvim/lua/plugins/haunt.lua create mode 100644 .config/nvim/lua/plugins/minimap.lua (limited to '.config/nvim/lua') diff --git a/.config/nvim/lua/config/autoall.lua b/.config/nvim/lua/config/autoall.lua new file mode 100644 index 0000000..6f36182 --- /dev/null +++ b/.config/nvim/lua/config/autoall.lua @@ -0,0 +1,35 @@ +-- Autocommands for all files opened in nvim +local autocmd = vim.api.nvim_create_autocmd +local autogrp = vim.api.nvim_create_augroup + +-- check if the current buffer is empty +local bufempty = function(bufnr) + bufnr = bufnr or 0 + if vim.api.nvim_buf_get_offset(bufnr, 0) <= 0 then + local handle = io.open(vim.api.nvim_buf_get_name(bufnr)) + if handle == nil then + return true + end + local eof = handle:read(0) + handle:close() + if eof == nil then + return true + end + end + return false +end + +local expand_template = function(name) + require('luasnip').snip_expand(require('config.templates')[name]) + require('luasnip').unlink_current() +end + +autocmd({ 'BufEnter', 'BufNewFile' }, { + pattern = 'deb/DEBIAN/changelog_blobs/*.txt', + group = autogrp('DebianChangelogTemplate', { clear = true }), + callback = function(opt) + if bufempty() then + return expand_template('debian-changelog') + end + end, +}) diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua index a93b8fd..3c51041 100644 --- a/.config/nvim/lua/config/keymaps.lua +++ b/.config/nvim/lua/config/keymaps.lua @@ -1,7 +1,12 @@ local map = vim.keymap.set -map('n', 'gb', 'bnext', { desc = 'Buffer next' }) -map('n', 'gB', 'bprevious', { desc = 'Buffer prev' }) +map('n', 'gb', 'bnext', { desc = 'Buf next' }) +map('n', 'gB', 'bprevious', { desc = 'Buf prev' }) + +map('n', '', 'tabprev', { desc = 'Tab prev' }) +map('n', '', 'bprev', { desc = 'Buf prev' }) +map('n', '', 'bnext', { desc = 'Buf next' }) +map('n', '', 'tabnext', { desc = 'Tab next' }) map('n', '', 'cnext', { desc = 'Quickfix next' }) map('n', '', 'cprev', { desc = 'Quickfix prev' }) @@ -21,8 +26,11 @@ map( vim.api.nvim_create_autocmd({ 'BufEnter', 'BufWinEnter' }, { group = vim.api.nvim_create_augroup('bufclose', {}), callback = function() - if vim.list_contains({ 'help', 'nofile', 'quickfix' }, vim.bo.buftype) then - map('', 'q', 'close', { desc = 'Close buffer', buffer = 0 }) + if + (vim.fn.maparg('q', 'n') == '') + and vim.list_contains({ 'help', 'nofile', 'nowrite', 'quickfix' }, vim.bo.buftype) + then + map('n', 'q', 'close', { desc = 'Close buffer', buffer = 0 }) end end, }) diff --git a/.config/nvim/lua/config/lsp.lua b/.config/nvim/lua/config/lsp.lua index b168014..5a2bf79 100644 --- a/.config/nvim/lua/config/lsp.lua +++ b/.config/nvim/lua/config/lsp.lua @@ -6,6 +6,8 @@ local lsp = vim.lsp lsp.enable({ 'bashls', + 'blueprint_ls', + 'buf_ls', 'ccls', 'clangd', 'gopls', @@ -14,6 +16,7 @@ lsp.enable({ 'rust_analyzer', 'superhtml', 'tinymist', + 'vala_ls', 'zk', 'zls', }) @@ -35,7 +38,7 @@ lsp.config('*', { vim.api.nvim_create_autocmd({ 'LspAttach' }, { group = vim.api.nvim_create_augroup('lspattach', {}), callback = function(args) - local client = assert(vim.lsp.get_client_by_id(args.data.client_id)) + local client = vim.lsp.get_client_by_id(args.data.client_id) -- TODO: what does this do? vim.opt_local.omnifunc = 'v:lua.vim.lsp.omnifunc' diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua index 073835f..07a41a3 100644 --- a/.config/nvim/lua/config/options.lua +++ b/.config/nvim/lua/config/options.lua @@ -37,3 +37,10 @@ opt.mousescroll = 'ver:1,hor:6' -- load local vim config (will as to allow it) opt.exrc = true + +-- increase the auto-scroll window +opt.scrolloff = 10 + +-- use osc2 to set terminal title +opt.title = true +opt.titlestring = [[nvim: %t%( %M%)%( (%{expand("%:~:h")})%)%a]] diff --git a/.config/nvim/lua/config/snippets.lua b/.config/nvim/lua/config/snippets.lua index e0c260e..9cd0632 100644 --- a/.config/nvim/lua/config/snippets.lua +++ b/.config/nvim/lua/config/snippets.lua @@ -6,16 +6,24 @@ ls.config.set_config({ enable_autosnippets = true, history = true, updateevents = 'TextChanged,TextChangedI', - override_builtin = true, + exit_roots = false, -- dont exit when reaching last node ext_opts = { [types.choiceNode] = { - active = { - virt_text = { { '◂ 󰬊 ', 'NonText' } }, + passive = { + virt_text = { { '󰬊 ', 'Conceal' } }, + virt_text_pos = 'inline', }, }, [types.insertNode] = { - active = { - virt_text = { { '◂ 󰬐 ', 'NonText' } }, + passive = { + virt_text = { { '󰬐 ', 'Conceal' } }, + virt_text_pos = 'inline', + }, + }, + [types.exitNode] = { + passive = { + virt_text = { { '$', 'Conceal' } }, + virt_text_pos = 'inline', }, }, }, @@ -53,27 +61,6 @@ ls.config.set_config({ require('luasnip.loaders.from_lua').lazy_load() require('luasnip.loaders.from_vscode').lazy_load({ include = {} }) --- keymaps -vim.keymap.set({ 'i', 's' }, '', function() - return vim.snippet.active({ direction = 1 }) and vim.snippet.jump(1) -end, { silent = true, desc = 'snippet: jump next' }) - -vim.keymap.set({ 'i', 's' }, '', function() - return vim.snippet.active({ direction = -1 }) and vim.snippet.jump(-1) -end, { silent = true, desc = 'snippet: jump prev' }) - -vim.keymap.set({ 'i', 's' }, '', function() - if ls.choice_active() then - ls.change_choice(1) - end -end, { silent = true, desc = 'snippet: next choice' }) - -vim.keymap.set({ 'i', 's' }, '', function() - if ls.choice_active() then - ls.change_choice(-1) - end -end, { silent = true, desc = 'snippet: prev choice' }) - -- usercmds vim.api.nvim_create_user_command('EditSnippets', require('luasnip.loaders').edit_snippet_files, {}) @@ -105,36 +92,23 @@ vim.api.nvim_create_user_command('EditSnippets', require('luasnip.loaders').edit vim.api.nvim_create_autocmd('ModeChanged', { pattern = '*', callback = function() - if ((vim.v.event.old_mode == 's' and vim.v.event.new_mode == 'n') or vim.v.event.old_mode == 'i') - and ls.session.current_nodes[vim.api.nvim_get_current_buf()] - and not ls.session.jump_active - and not require("blink.cmp").is_visible() + if + ((vim.v.event.old_mode == 's' or vim.v.event.old_mode == 'i') and vim.v.event.new_mode == 'n') + and ls.session.current_nodes[vim.api.nvim_get_current_buf()] + and not ls.session.jump_active + and not require('blink.cmp').is_visible() then - ls.unlink_current() + vim.schedule(ls.unlink_current) end - end + end, }) --- attach to builtin snippet hooks -vim.snippet.expand = ls.lsp_expand -vim.snippet.active = function(filter) - filter = filter or {} - filter.direction = filter.direction or 1 - if filter.direction == 1 then - return ls.expand_or_jumpable() - else - return ls.jumpable(filter.direction) - end -end -vim.snippet.jump = function(direction) - if direction == 1 then - if ls.expandable() then - return ls.expand_or_jump() - else - return ls.jumpable(1) and ls.jump(1) - end - else - return ls.jumpable(-1) and ls.jump(-1) - end -end -vim.snippet.stop = ls.unlink_current +-- expand/jump keymaps handled by blink + +vim.keymap.set({ 'i', 's' }, '', function() + return ls.choice_active() and ls.change_choice(1) +end, { silent = true, desc = 'luasnip: next choice' }) + +vim.keymap.set({ 'i', 's' }, '', function() + return ls.choice_active() and ls.change_choice(-1) +end, { silent = true, desc = 'luasnip: prev choice' }) diff --git a/.config/nvim/lua/config/templates.lua b/.config/nvim/lua/config/templates.lua new file mode 100644 index 0000000..a01efa1 --- /dev/null +++ b/.config/nvim/lua/config/templates.lua @@ -0,0 +1,53 @@ +-- template snippets +require('luasnip').setup_snip_env() +local templates = {} + +-- check if the current buffer is empty +local bufempty = function(bufnr) + bufnr = bufnr or 0 + if vim.api.nvim_buf_get_offset(bufnr, 0) <= 0 then + local handle = io.open(vim.api.nvim_buf_get_name(bufnr)) + if handle == nil then + return true + end + local eof = handle:read(0) + handle:close() + if eof == nil then + return true + end + end + return false +end + +local register_template = function(pattern, snip) + templates[pattern] = snip + + vim.api.nvim_create_autocmd({ 'BufEnter', 'BufNewFile' }, { + pattern = pattern, + group = vim.api.nvim_create_augroup('Template' .. pattern, { clear = true }), + callback = function(opt) + if bufempty() then + require('luasnip').snip_expand(templates[pattern]) + require('luasnip').unlink_current() + end + end, + }) +end + +register_template( + 'deb/DEBIAN/changelog_blobs/*.txt', + s( + 'debian-changelog', + fmt( + [[ +ukp-agent (${VERSION}) unstable; urgency=medium + + * feat: <> +]], + { i(0) }, + { + delimiters = '<>', + } + ) + ) +) diff --git a/.config/nvim/lua/mod/gh.lua b/.config/nvim/lua/mod/gh.lua new file mode 100644 index 0000000..1f8a267 --- /dev/null +++ b/.config/nvim/lua/mod/gh.lua @@ -0,0 +1,86 @@ +local M = {} + +-- gh api \ +-- --method POST \ +-- -H "Accept: application/vnd.github+json" \ +-- -H "X-GitHub-Api-Version: 2022-11-28" \ +-- /repos/OWNER/REPO/pulls/PULL_NUMBER/comments \ + +function M.pr_comment(repo, pull, commit_id, comment) + vim.print(vim.inspect(comment)) + vim.print(vim.inspect({ + 'gh', + 'api', + '--method', + 'POST', + string.format('/repos/%s/pulls/%d/comments', repo, pull), + '-f', + 'body=' .. comment.body, + '-f', + 'commit_id=' .. commit_id, + '-f', + 'path=' .. comment.path, + '-f', + 'side=RIGHT', + '-f', + 'line=' .. comment.line, + })) +end + +function M.pr_view() + local p = vim + .system({ + 'gh', + 'pr', + 'view', + '--json', + 'number,headRepository,headRefOid', + '--jq', + '{head:.headRefOid,repo:.headRepository.nameWithOwner,pull:.number}', + }) + :wait() + return vim.json.decode(p.stdout) +end + +function M.submit_review() + local gitroot = vim.fs.root(0, { '.git' }) + if not gitroot then + vim.notify('Not a git repository.', vim.log.levels.WARN) + return + end + + local review = { comments = {} } + + local marks = require('haunt.api').get_bookmarks() + for _, mark in ipairs(marks) do + -- nil for bookmarks outside the current repo + local path = vim.fs.relpath(gitroot, mark.file) + if path then + review.comments[#review.comments] = { + path = path, + line = mark.line, + body = mark.note, + } + end + end + + review.pr = M.pr_view() + + vim.print(vim.inspect(review)) + + vim.ui.select({ + 'OK', + 'Cancel', + }, { + prompt = 'Submit review?', + }, function(choice) + vim.print(choice) + if choice == 'OK' then + for _, comment in ipairs(review.comments) do + M.pr_comment(pr.repo, pr.pull, pr.head, comment) + end + end + end) +end + +return M diff --git a/.config/nvim/lua/mod/git.lua b/.config/nvim/lua/mod/git.lua new file mode 100644 index 0000000..3e36e61 --- /dev/null +++ b/.config/nvim/lua/mod/git.lua @@ -0,0 +1,23 @@ +local M = {} + +function M.commit() + local commit = vim.fn.expand('') -- XXX: can we do better? + vim.cmd.DiffviewOpen(commit .. '^!') +end + +function M.log() + local bufnr = vim.api.nvim_create_buf(true, true) + assert(bufnr ~= 0, 'Failed to create buffer') + + vim.bo[bufnr].bufhidden = 'wipe' + vim.bo[bufnr].modifiable = true + vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, content) + vim.bo[bufnr].modifiable = false + + vim.keymap.set('n', 'q', 'quit!', { silent = true, buffer = bufnr }) + vim.keymap.set('n', 'K', M.commit, { silent = true, buffer = bufnr }) + + vim.api.nvim_win_set_buf(0, bufnr) +end + +return M diff --git a/.config/nvim/lua/mod/jobs.lua b/.config/nvim/lua/mod/jobs.lua new file mode 100644 index 0000000..a4dea6f --- /dev/null +++ b/.config/nvim/lua/mod/jobs.lua @@ -0,0 +1,68 @@ +-- this plugin provides an API to register and recall jobs. + +local M = { + _jobs = {}, +} + +local function format_jobcmd(cmd) + if type(cmd) == 'table' then + return table.concat(cmd, ' ') + end + return cmd +end + +local function register(id, cmd) + table.insert(M._jobs, id, cmd) + vim.notify_once(string.format('started job %d (%s)', id, format_jobcmd(M._jobs[id]))) +end + +local function deregister(id) + local cmd = M._jobs[id] + table.insert(M._jobs, id, nil) + vim.notify_once(string.format('stopped job %d (%s)', id, format_jobcmd(cmd))) +end + +function M.start(opts) + local previous_on_exit = opts.on_exit or function() end + opts.on_exit = function(id, exitcode, event) + deregister(id) + return previous_on_exit(id, exitcode, event) + end + + local id = vim.fn.jobstart(opts.cmd, opts) + + register(id, opts.cmd) +end + +function M.select() + if #M._jobs == 0 then + vim.notify('No running jobs', vim.log.levels.WARN) + return + end + + local function provider(cb) + for id, cmd in pairs(M._jobs) do + cb(string.format('[%d] %s', id, format_jobcmd(cmd))) + end + cb(nil) + end + local function parse_jobid(entry) + return tonumber(string.match(entry, '%[([0-9]*)%]')) + end + + require('fzf-lua').fzf_exec(provider, { + prompt = 'Jobs❯', + actions = { + ['ctrl-x'] = { + fn = function(selected) + for _, entry in pairs(selected) do + vim.fn.jobstop(parse_jobid(entry)) + end + end, + reload = true, + }, + }, + }) +end + +return M diff --git a/.config/nvim/lua/mod/termopen.lua b/.config/nvim/lua/mod/termopen.lua new file mode 100644 index 0000000..f8117f1 --- /dev/null +++ b/.config/nvim/lua/mod/termopen.lua @@ -0,0 +1,102 @@ +-- this plugin provides a popup terminal. +local jobs = require('mod.jobs') + +local M = {} + +function M.termopen(opts) + opts = opts or {} + + -- setup the buffer + local buf = vim.api.nvim_create_buf(false, true) + vim.api.nvim_set_option_value('bufhidden', 'wipe', { buf = buf }) + vim.api.nvim_set_option_value('modifiable', false, { buf = buf }) + + -- setup keymappings + vim.keymap.set('n', 'q', 'close', { buffer = buf }) + vim.keymap.set('n', '', 'close', { buffer = buf }) + + -- setup the window + -- local w = math.ceil(vim.o.columns * 1.0) + -- local h = math.ceil(vim.o.lines * 0.4) + local win = vim.api.nvim_open_win(buf, true, { + -- style = 'minimal', + -- relative = 'editor', + -- width = w, + -- height = h, + -- row = math.ceil(vim.o.lines - h), + -- col = vim.o.columns, + -- border = { ' ', '─', ' ', ' ', ' ', '─', ' ', ' ' }, + split = 'below', + win = -1, + }) + vim.api.nvim_set_current_win(win) + + -- spawn the command + if #opts.cmd == 0 then + opts.cmd = { vim.env.SHELL } + end + + -- vim.notify('termopen: running ' .. vim.inspect(opts.cmd), vim.log.levels.DEBUG) + + jobs.start(vim.tbl_deep_extend('error', opts, { + term = true, + env = { + -- we need this to avoid opening in the term buffer + NVR_PRE_CMD = 'close', + }, + on_exit = function() + -- if vim.api.nvim_win_is_valid(win) then + -- vim.api.nvim_win_close(win, true) + -- end + end, + })) + + -- put into insert mode + vim.cmd.startinsert() +end + +-- wrappers convenience + +function M.term(a) + local cwd = nil + local args = a.fargs + + if #args > 0 then + if args[1]:sub(0, 4) == 'cwd=' then + cwd = args[1]:sub(5) + args = vim.list_slice(args, 2) + end + end + + for i = 0, #args do + if args[i] == '%' then + args[i] = vim.fn.expand(args[i]) + end + end + + M.termopen({ cmd = args, cwd = cwd }) +end + +function M.make(a) + if vim.opt_local.makeprg == nil then + vim.ui.input({ prompt = 'Enter makeprg: ' }, function(input) + vim.opt_local.makeprg = input + end) + end + + local makeprg = vim.opt_local.makeprg:get() + if string.match(makeprg, [[%$%*]]) == nil then + makeprg = makeprg .. ' ' .. a.args + end + + local cmd = vim.split(makeprg, ' ') + cmd = vim.tbl_map(function(p) + p, _ = string.gsub(p, [[%$%*]], a.args) + p, _ = vim.fn.expand(p) + return p + end, cmd) + + M.termopen({ cmd = cmd }) +end + +return M diff --git a/.config/nvim/lua/mod/utils.lua b/.config/nvim/lua/mod/utils.lua new file mode 100644 index 0000000..1f3cd8b --- /dev/null +++ b/.config/nvim/lua/mod/utils.lua @@ -0,0 +1,15 @@ +local M = {} + +function M.buf_edit_lines(buf, start_row, end_row, callback) + local lines = {} + lines = vim.api.nvim_buf_get_lines(buf, start_row, end_row, true) + lines = callback(lines) + return vim.api.nvim_buf_set_lines(buf, start_row, end_row, true, lines) +end + +function M.edit_current_line(callback) + local row, _ = unpack(vim.api.nvim_win_get_cursor(0)) + return M.buf_edit_lines(0, row - 1, row, callback) +end + +return M diff --git a/.config/nvim/lua/mod/win.lua b/.config/nvim/lua/mod/win.lua new file mode 100644 index 0000000..e5c5f71 --- /dev/null +++ b/.config/nvim/lua/mod/win.lua @@ -0,0 +1,110 @@ +local M = {} + +function M.open(name, content, opts) + if name == '' then + return + end + if #content == 0 then + return + end + + local opts = opts or {} + local autoclose = opts.autoclose or false + local buf_opts = opts.buf or { buftype = '' } + + local win_opts = opts.win or false + -- profiles + if type(win_opts) == 'table' and type(win_opts[1] == 'string') then + local profile = win_opts[1] + local overwrites = unpack(win_opts, 2) + if profile == 'emplace' then + win_opts = false + elseif profile == 'smallsplit' then + win_opts = { + split = 'above', + win = 0, + height = 20, + } + elseif profile == 'popup' then + local winh = vim.api.nvim_win_get_height(0) + local winw = vim.api.nvim_win_get_width(0) + local winsize = 0.5 + win_opts = { + relative = 'win', + height = math.floor(winh * winsize), + width = math.floor(winw * winsize), + row = math.floor((winh * 0.5) - (0.5 * (winh * winsize))), + col = math.floor((winw * 0.5) - (0.5 * (winw * winsize))), + style = 'minimal', + border = 'single', + zindex = 99, + title = name, + } + end + if overwrites then + for k, v in pairs(overwrites) do + win_opts[k] = v + end + end + end + + local bufnr = vim.api.nvim_create_buf(false, true) + assert(bufnr ~= 0, 'Failed to create buffer') + + vim.bo[bufnr].modifiable = true + vim.api.nvim_buf_set_name(bufnr, name) + vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, content) + for k, v in pairs(buf_opts) do + vim.bo[bufnr][k] = v + end + + -- without win_opts (by default) replace current buffer + local winid = 0 + if win_opts then + winid = vim.api.nvim_open_win(0, not autoclose, win_opts) + assert(winid ~= 0, 'Failed to create window') + end + + vim.keymap.set('n', 'q', 'quit!', { silent = true, buffer = bufnr }) + + if autoclose then + local group = 'modwin_' .. vim.base64.encode(vim.uv.random(16)) + local group_id = vim.api.nvim_create_augroup(group, {}) + + vim.api.nvim_create_autocmd('WinClosed', { + pattern = tostring(winid), + group = group_id, + callback = function() + vim.api.nvim_create_augroup(group, {}) + M.winid = nil + end, + }) + vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { + group = group_id, + callback = function() + vim.api.nvim_create_augroup(group, {}) + pcall(vim.api.nvim_win_close, winid, true) + end, + }) + end + + vim.api.nvim_win_set_buf(winid, bufnr) + return { bufnr, winid } +end + +function M.popup(name, content, opts) + local defaults = { + autoclose = true, + buf = { + bufhidden = 'wipe', + buftype = 'nofile', + modifiable = false, + }, + win = { 'popup' }, + } + opts = opts or {} + opts = vim.tbl_deep_extend('force', defaults, opts) + M.open(name, content, opts) +end + +return M diff --git a/.config/nvim/lua/plugins/blink.lua b/.config/nvim/lua/plugins/blink.lua index 1122bcc..cefef4a 100644 --- a/.config/nvim/lua/plugins/blink.lua +++ b/.config/nvim/lua/plugins/blink.lua @@ -1,6 +1,7 @@ return { { - 'saghen/blink.cmp', + enabled = true, + 'https://github.com/saghen/blink.cmp.git', version = '1.*', lazy = false, @@ -25,7 +26,7 @@ return { -- TODO: -- 'prefer_rust_with_warning', requires nightly rust, due to: -- https://github.com/rust-lang/rust/issues/86656 - fuzzy = { + fuzzy = { implementation = 'lua', sorts = { function(a, b) @@ -35,11 +36,13 @@ return { } local a_priority = prio[a.source_id] or 0 local b_priority = prio[b.source_id] or 0 - if a_priority ~= b_priority then return a_priority > b_priority end + if a_priority ~= b_priority then + return a_priority > b_priority + end end, -- defaults 'score', - 'sort_text' + 'sort_text', }, }, @@ -74,6 +77,8 @@ return { window = { scrollbar = false }, -- BUG: weird artifacts }, + snippets = { preset = 'luasnip' }, + keymap = { [''] = { 'show', 'show_documentation', 'hide_documentation' }, [''] = { 'cancel', 'fallback' }, @@ -87,8 +92,14 @@ return { [''] = { 'snippet_backward', 'fallback' }, -- [''] = { 'show', 'hide', 'fallback' }, }, - - snippets = { preset = 'luasnip' }, + }, + }, + { + 'https://github.com/saghen/blink.indent.git', + opts = { + scope = { + highlights = { 'BlinkIndentScope' }, + }, }, }, } diff --git a/.config/nvim/lua/plugins/calcium.lua b/.config/nvim/lua/plugins/calcium.lua index f0ab78c..7ff1ba0 100644 --- a/.config/nvim/lua/plugins/calcium.lua +++ b/.config/nvim/lua/plugins/calcium.lua @@ -1,5 +1,6 @@ return { { + enabled = true, 'necrom4/calcium.nvim', cmd = {'Calcium'}, opts = { diff --git a/.config/nvim/lua/plugins/colorizer.lua b/.config/nvim/lua/plugins/colorizer.lua index c949058..0b69d5a 100644 --- a/.config/nvim/lua/plugins/colorizer.lua +++ b/.config/nvim/lua/plugins/colorizer.lua @@ -1,8 +1,9 @@ return { { - 'NvChad/nvim-colorizer.lua', + enabled = true, + 'https://github.com/NvChad/nvim-colorizer.lua.git', -- 'norcalli/nvim-colorizer.lua', - lazy = false, + lazy = true, opts = { options = { display = { diff --git a/.config/nvim/lua/plugins/colors.lua b/.config/nvim/lua/plugins/colors.lua new file mode 100644 index 0000000..764abfd --- /dev/null +++ b/.config/nvim/lua/plugins/colors.lua @@ -0,0 +1,12 @@ +return { + { + enabled = true, + 'https://github.com/oskarnurm/koda.nvim', + lazy = false, + priority = 1000, + config = function() + vim.opt.termguicolors = true + vim.cmd('colorscheme koda') + end, + } +} diff --git a/.config/nvim/lua/plugins/diff.lua b/.config/nvim/lua/plugins/diff.lua new file mode 100644 index 0000000..d758522 --- /dev/null +++ b/.config/nvim/lua/plugins/diff.lua @@ -0,0 +1,47 @@ +return { + { + enabled = true, + 'https://github.com/sindrets/diffview.nvim', + cmd = { + 'DiffviewOpen', + 'DiffviewFileHistory', + }, + init = function() + vim.keymap.set( + 'n', + 'g-', + vim.cmd.DiffviewFileHistory, + { desc = 'DiffviewFileHistory' } + ) + + vim.api.nvim_create_autocmd('Filetype', { + pattern = { 'git', 'gitcommit', 'gitrebase' }, + callback = function() + vim.keymap.set('n', 'K', function() + vim.cmd.DiffviewOpen(vim.fn.expand('') .. '^!') + end, { buffer = 0, desc = 'DiffviewOpen' }) + end, + }) + end, + config = function() + vim.api.nvim_create_autocmd('User', { + pattern = { 'DiffviewViewEnter' }, + callback = function() + vim.keymap.set('n', 'q', 'DiffviewClose', { buffer = 0 }) + vim.keymap.set( + 'n', + '', + require('diffview.actions').select_next_entry, + { buffer = 0 } + ) + vim.keymap.set( + 'n', + '', + require('diffview.actions').select_prev_entry, + { buffer = 0 } + ) + end, + }) + end, + }, +} diff --git a/.config/nvim/lua/plugins/fzf.lua b/.config/nvim/lua/plugins/fzf.lua index 73246a8..1a25c0d 100644 --- a/.config/nvim/lua/plugins/fzf.lua +++ b/.config/nvim/lua/plugins/fzf.lua @@ -1,5 +1,6 @@ return { { + enabled = true, 'ibhagwan/fzf-lua', dependencies = { 'echasnovski/mini.icons', @@ -13,10 +14,12 @@ return { { 'default' }, -- OPTIONS winopts = { + backdrop = 0, split = 'belowright 20new', border = 'none', preview = { border = 'none', + hidden = true, }, -- on_create = function() end, }, @@ -27,11 +30,12 @@ return { ['ctrl-p'] = 'up', }, }, - -- actions = { - -- files = { - -- ['ctrl-q'] = { fn = fzf.actions.file_sel_to_qf }, - -- }, - -- }, + actions = { + files = { + true, + ['ctrl-q'] = { fn = fzf.actions.file_sel_to_qf, prefix = 'select-all' }, + }, + }, fzf_colors = true, -- PICKER CONFIG files = { @@ -39,7 +43,7 @@ return { }, marks = { marks = '[a-zA-Z]', - } + }, }) end, keys = { @@ -48,11 +52,26 @@ return { { mode = 'n', ';b', 'FzfLua buffers', desc = 'fzf: buffers' }, { mode = 'n', ';f', 'FzfLua files', desc = 'fzf: find_files' }, { mode = 'n', ';g', 'FzfLua live_grep', desc = 'fzf: live_grep' }, - { mode = 'n', ';d', 'FzfLua diagnostics_workspace', desc = 'fzf: workspace diagnostics' }, - { mode = 'n', ';D', 'FzfLua diagnostics_document', desc = 'fzf: document diagnostics' }, + { + mode = 'n', + ';D', + 'FzfLua diagnostics_workspace sort=true', + desc = 'fzf: workspace diagnostics', + }, + { + mode = 'n', + ';d', + 'FzfLua diagnostics_document sort=true', + desc = 'fzf: document diagnostics', + }, { mode = 'n', ';h', 'FzfLua helptags', desc = 'fzf: help' }, { mode = 'n', ';s', 'FzfLua lsp_document_symbols', desc = 'fzf: document symbols' }, - { mode = 'n', ';w', 'FzfLua lsp_live_workspace_symbols', desc = 'fzf: workspace symbols' }, + { + mode = 'n', + ';w', + 'FzfLua lsp_live_workspace_symbols', + desc = 'fzf: workspace symbols', + }, { mode = 'n', ';m', 'FzfLua marks', desc = 'fzf: marks' }, { mode = 'n', @@ -62,12 +81,60 @@ return { end, desc = 'fzf: vim_config', }, - -- { - -- mode = 'n', - -- ';;t', - -- 'Telescope', - -- desc = 'telescope: select (interactive)', - -- }, + { + mode = 'n', + ';z', + function() + -- register one-time autocmd to open changed directory with oil + vim.api.nvim_create_autocmd('DirChanged', { + pattern = '*', + callback = vim.schedule_wrap(function(args) + vim.cmd.Oil(args.file) + end), + once = true, + }) + require('fzf-lua').zoxide() + end, + desc = 'fzf: zoxide', + }, + { + mode = 'n', + ';Z', + function() + require('fzf-lua').live_grep({ + cwd = vim.env.ZK_NOTEBOOK_DIR, + actions = { + ['ctrl-c'] = function(selected, opts) + local utils = require('fzf-lua.utils') + + local title = opts.last_query + local p = vim + .system({ 'zk', 'new', '--dry-run', '--no-input', '--title', title }, { text = true }) + :wait() + if not p.code == 0 then + return + end + utils.info(vim.inspect(p.stdout)) + + local note_path = vim.trim(p.stderr) + local note_body = vim.split(p.stdout, '\n') + require('mod.win').open(note_path, note_body, { + buf = { filetype = 'markdown' }, + }) + end, + }, + }) + end, + desc = 'fzf: zettelkasten', + }, + { + mode = 'n', + ';T', + function() + require('fzf-lua').live_grep({ regex = '(TODO|XXX|NOTE|HACK):' }) + end, + desc = 'fzf: zettelkasten', + }, { mode = 'n', ';;f', @@ -78,7 +145,6 @@ return { else dir = vim.fn.expand('%:p:h') end - -- require('fzf-lua').files({ cwd = dir }) _G.feedkeys(':Fzf files cwd=' .. dir) end, desc = 'fzf: files (interactive)', diff --git a/.config/nvim/lua/plugins/gentoo.lua b/.config/nvim/lua/plugins/gentoo.lua index 15ef3aa..9af7571 100644 --- a/.config/nvim/lua/plugins/gentoo.lua +++ b/.config/nvim/lua/plugins/gentoo.lua @@ -1,5 +1,6 @@ return { { + enabled = true, 'https://github.com/gentoo/gentoo-syntax', lazy = false, init = function() diff --git a/.config/nvim/lua/plugins/git.lua b/.config/nvim/lua/plugins/git.lua index d1e3f7b..7f1db6d 100644 --- a/.config/nvim/lua/plugins/git.lua +++ b/.config/nvim/lua/plugins/git.lua @@ -1,5 +1,6 @@ return { { + enabled = true, 'lewis6991/gitsigns.nvim', lazy = false, opts = { @@ -46,6 +47,7 @@ return { }, { + enabled = true, 'linrongbin16/gitlinker.nvim', cmd = { 'GitLink' }, dependencies = { 'nvim-lua/plenary.nvim' }, @@ -54,6 +56,7 @@ return { }, keys = { { + mode = { 'n', 'x' }, 'gl', vim.cmd.GitLink, desc = 'GitLinker: clipboard', @@ -62,11 +65,13 @@ return { }, { - enabled = false, + enabled = true, 'moyiz/git-dev.nvim', lazy = true, cmd = { 'GitDevOpen', 'GitDevCleanAll' }, opts = { + pickers = { type = 'uiselect' }, + ephemeral = false, read_only = false, }, }, diff --git a/.config/nvim/lua/plugins/haunt.lua b/.config/nvim/lua/plugins/haunt.lua new file mode 100644 index 0000000..aa24cec --- /dev/null +++ b/.config/nvim/lua/plugins/haunt.lua @@ -0,0 +1,47 @@ +return { + { + enabled = true, + 'https://github.com/TheNoeTrevino/haunt.nvim', + lazy = true, + opts = { + sign = '', + -- sign_hl = nil, + -- line_hl = nil, + -- virt_text_hl = nil, + data_dir = nil, + annotation_prefix = '  ', + -- virt_text_pos = 'eol', + virt_text_pos = 'above', + picker_keys = { + delete = { key = 'ctrl-x' }, + edit_annotation = { key = 'ctrl-e' }, + }, + }, + cmd = { + 'HauntAnnoate', + 'HauntDelete', + 'HauntList', + 'HauntNext', + 'HauntPrev', + 'HauntQfAll', + }, + keys = { + { '[h', 'HauntPrev', desc = 'haunt: prev annotation', silent = true }, + { ']h', 'HauntNext', desc = 'haunt: next annotation', silent = true }, + { 'h', '', desc = 'haunt' }, + { 'ha', 'HauntAnnotate', desc = 'haunt: annotate', silent = true }, + { 'ha', 'HauntAnnotate', desc = 'haunt: annotate', silent = true }, + { 'hd', 'HauntDelete', desc = 'haunt: delete', silent = true }, + { 'hl', 'HauntList', desc = 'haunt: list', silent = true }, + { 'hf', 'HauntQfAll', desc = 'haunt: quickfix', silent = true }, + { + 'ht', + function() + require('haunt.api').toggle_all_lines() + end, + desc = 'haunt: toggle all', + silent = true, + }, + }, + }, +} diff --git a/.config/nvim/lua/plugins/icons.lua b/.config/nvim/lua/plugins/icons.lua index 9a597ab..339ad12 100644 --- a/.config/nvim/lua/plugins/icons.lua +++ b/.config/nvim/lua/plugins/icons.lua @@ -1,5 +1,6 @@ return { { + enabled = true, 'echasnovski/mini.icons', version = false, events = { 'VeryLazy' }, diff --git a/.config/nvim/lua/plugins/indent.lua b/.config/nvim/lua/plugins/indent.lua index e247c5a..d197a43 100644 --- a/.config/nvim/lua/plugins/indent.lua +++ b/.config/nvim/lua/plugins/indent.lua @@ -1,6 +1,7 @@ return { -- show indents using virtual text { + enabled = false, 'lukas-reineke/indent-blankline.nvim', lazy = false, main = 'ibl', diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index 311f1bc..306953c 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -1,14 +1,22 @@ return { { + enabled = true, 'neovim/nvim-lspconfig', version = '^2.0', }, { + enabled = true, 'nvimtools/none-ls.nvim', dependencies = { 'nvim-lua/plenary.nvim', 'gbprod/none-ls-shellcheck.nvim', }, + ft = { + 'sh', + 'bash', + 'go', + 'lua', + }, config = function() local nls = require('null-ls') nls.setup({ @@ -18,10 +26,25 @@ return { nls.builtins.formatting.stylua, nls.builtins.formatting.shfmt, - nls.builtins.formatting.buf, - require("none-ls-shellcheck.diagnostics"), - require("none-ls-shellcheck.code_actions"), + require('none-ls-shellcheck.diagnostics'), + require('none-ls-shellcheck.code_actions'), + + nls.builtins.diagnostics.golangci_lint.with({ + command = 'task', + args = { + '--offline', + '--silent', + '--exit-code', + '--failfast', + '--output=interleaved', + 'go:lint', + '--', + '--show-stats=false', + '--output.json.path=stdout', + '--path-mode=abs', + }, + }), }, }) end, diff --git a/.config/nvim/lua/plugins/markdown.lua b/.config/nvim/lua/plugins/markdown.lua index efe7019..a02cb67 100644 --- a/.config/nvim/lua/plugins/markdown.lua +++ b/.config/nvim/lua/plugins/markdown.lua @@ -1,5 +1,6 @@ return { { + enabled = true, -- handy markdown commands 'tadmccorkle/markdown.nvim', ft = { 'markdown' }, @@ -17,6 +18,7 @@ return { }, }, { + enabled = true, -- pretty markdown 'MeanderingProgrammer/markdown.nvim', name = 'render-markdown', -- needed if used together with markdown.nvim above diff --git a/.config/nvim/lua/plugins/mini.lua b/.config/nvim/lua/plugins/mini.lua index fb4c9a6..fdf4a0e 100644 --- a/.config/nvim/lua/plugins/mini.lua +++ b/.config/nvim/lua/plugins/mini.lua @@ -1,23 +1,27 @@ return { { + enabled = true, 'echasnovski/mini.align', version = false, lazy = false, opts = {}, }, { + enabled = true, 'echasnovski/mini.ai', version = false, lazy = false, opts = {}, }, { + enabled = true, 'echasnovski/mini.surround', version = false, lazy = false, opts = {}, }, { + enabled = true, 'echasnovski/mini.operators', version = false, lazy = false, diff --git a/.config/nvim/lua/plugins/minimap.lua b/.config/nvim/lua/plugins/minimap.lua new file mode 100644 index 0000000..99e9ec7 --- /dev/null +++ b/.config/nvim/lua/plugins/minimap.lua @@ -0,0 +1,13 @@ +return { + { + enabled = false, + 'alchezar/fishbone.nvim', + event = 'VeryLazy', + opts = {}, + }, + { + enabled = false, + 'https://github.com/lewis6991/satellite.nvim', + opts = {}, + } +} diff --git a/.config/nvim/lua/plugins/oil.lua b/.config/nvim/lua/plugins/oil.lua index 401fe8b..d21b041 100644 --- a/.config/nvim/lua/plugins/oil.lua +++ b/.config/nvim/lua/plugins/oil.lua @@ -1,5 +1,6 @@ return { { + enabled = true, 'stevearc/oil.nvim', lazy = false, opts = { diff --git a/.config/nvim/lua/plugins/snippets.lua b/.config/nvim/lua/plugins/snippets.lua index 71276a0..2a38a1d 100644 --- a/.config/nvim/lua/plugins/snippets.lua +++ b/.config/nvim/lua/plugins/snippets.lua @@ -1,5 +1,6 @@ return { { + enabled = true, 'L3MON4D3/LuaSnip', version = 'v2.*', build = 'make install_jsregexp', diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua index 0978eb7..ccacc7a 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -1,5 +1,6 @@ return { { + enabled = true, 'nvim-treesitter/nvim-treesitter', branch = 'main', lazy = false, @@ -36,6 +37,7 @@ return { 'gotmpl', 'gowork', 'html', + 'janet_simple', 'javascript', 'json', 'lua', @@ -43,15 +45,18 @@ return { 'markdown', 'markdown_inline', 'ninja', + 'proto', 'python', 'regex', 'rust', 'scss', 'sql', + 'templ', -- golang html templates 'todotxt', 'toml', 'typescript', 'typst', + 'vala', 'vim', 'vimdoc', 'yaml', diff --git a/.config/nvim/lua/plugins/whichkey.lua b/.config/nvim/lua/plugins/whichkey.lua index cb89df4..442b43f 100644 --- a/.config/nvim/lua/plugins/whichkey.lua +++ b/.config/nvim/lua/plugins/whichkey.lua @@ -1,9 +1,19 @@ return { { + enabled = true, 'folke/which-key.nvim', event = 'VeryLazy', opts = { icons = { separator = '→ ', group = ' +' }, }, + keys = { + { + '?', + function() + require('which-key').show({ global = true }) + end, + desc = 'which-key: show buffer local keymaps', + }, + }, }, } -- cgit 1.4.1