From 23de12baba9fbfc4ca24581b37c374aa5345cc25 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Mon, 25 Nov 2024 13:30:37 +0100 Subject: update nvim config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- .vim/after/ftplugin/c.lua | 1 + .vim/after/ftplugin/dirbuf.lua | 3 - .vim/after/ftplugin/gitmessengerpopup.lua | 1 - .vim/after/ftplugin/gitrebase.lua | 34 - .vim/after/ftplugin/go.lua | 19 - .vim/after/ftplugin/html.lua | 20 + .vim/after/ftplugin/ledger.lua | 2 - .vim/after/ftplugin/lua.lua | 2 + .vim/after/ftplugin/mail.lua | 2 - .vim/after/ftplugin/markdown.lua | 74 +- .vim/after/ftplugin/mediawiki.lua | 5 + .vim/after/ftplugin/norg.lua | 1 - .vim/after/ftplugin/rust.lua | 1 - .vim/after/ftplugin/scd.lua | 0 .vim/after/ftplugin/tex.lua | 8 - .vim/after/ftplugin/todofile.lua | 23 - .vim/after/queries.bak/markdown/highlights.scm | 100 ++ .../queries.bak/markdown_inline/highlights.scm | 11 + .vim/after/snippets/c.snippets | 1 - .vim/after/snippets/dockerfile.snippets.todo | 31 - .vim/after/snippets/ebuild.snippets.todo | 25 - .vim/after/snippets/go.snippets | 20 - .vim/after/snippets/go.snippets.todo | 11 - .vim/after/snippets/mail.snippets | 15 - .vim/after/snippets/markdown.snippets.todo | 43 - .vim/after/snippets/readme | 1 - .vim/after/snippets/sh.snippets | 16 - .vim/after/snippets/tex.snippets.todo | 81 - .vim/colorizer-nohash.patch | 14 - .vim/init.lua | 480 +----- .vim/lazy-lock.json | 98 +- .vim/lua/_globals.lua | 16 - .vim/lua/internal/commit-preview.lua | 67 - .vim/lua/internal/completion.lua | 154 ++ .vim/lua/internal/cursor.lua | 11 - .vim/lua/internal/dap.lua | 173 --- .vim/lua/internal/find.lua | 106 -- .vim/lua/internal/hardmode.lua | 10 - .vim/lua/internal/job.lua | 181 --- .vim/lua/internal/lsp.lua | 319 ---- .vim/lua/internal/lsp_symbols.lua | 36 - .vim/lua/internal/misc.lua | 223 --- .vim/lua/internal/notify.lua | 105 -- .vim/lua/internal/plugins/aerial.lua | 13 + .vim/lua/internal/plugins/colorizer.lua | 16 + .vim/lua/internal/plugins/colorschemes.lua | 11 + .vim/lua/internal/plugins/completion.lua | 60 + .vim/lua/internal/plugins/csv.lua | 20 + .vim/lua/internal/plugins/gentoo.lua | 15 + .vim/lua/internal/plugins/git.lua | 108 ++ .vim/lua/internal/plugins/icons.lua | 12 + .vim/lua/internal/plugins/indent.lua | 28 + .vim/lua/internal/plugins/lsp.lua | 276 ++++ .vim/lua/internal/plugins/mediawiki.lua | 6 + .vim/lua/internal/plugins/mini.lua | 35 + .vim/lua/internal/plugins/oil.lua | 21 + .vim/lua/internal/plugins/telescope.lua | 137 ++ .vim/lua/internal/plugins/todo.lua | 46 + .vim/lua/internal/plugins/treesitter.lua | 124 ++ .vim/lua/internal/plugins/whichkey.lua | 9 + .vim/lua/internal/plugins/writing.lua | 123 ++ .vim/lua/internal/plugins/zk.lua | 35 + .vim/lua/internal/snippets.lua | 129 ++ .vim/lua/internal/snips.lua | 159 -- .vim/lua/internal/sortline.lua | 78 - .vim/lua/internal/spell.lua | 8 - .vim/lua/internal/statusline.lua | 206 --- .vim/lua/internal/syncbg.lua | 46 - .vim/lua/internal/zk.lua | 7 - .vim/lua/plugins.lua | 1578 -------------------- .vim/lua/telescope/_extensions/jobs.lua | 84 -- .vim/plugin/_globals.lua | 3 + .vim/plugin/auto.lua | 38 + .vim/plugin/colorscheme.lua | 23 + .vim/plugin/diagnostics.lua | 59 + .vim/plugin/hardmode.lua | 10 + .vim/plugin/keymaps.lua | 29 + .vim/plugin/options.lua | 27 + .vim/plugin/statuscolumn.lua | 11 + .vim/plugin/statusline.lua | 152 ++ .vim/plugin/syncbg.lua | 53 + .vim/plugin/termopen.lua | 59 + .vim/plugin/undo.lua | 10 + .vim/snippets/.licenses/agpl-3.0 | 662 -------- .vim/snippets/.licenses/cc0-1.0 | 116 -- .vim/snippets/.licenses/gpl-3.0 | 675 --------- .vim/snippets/.licenses/mit | 19 - .vim/snippets/all.lua | 83 +- .vim/snippets/cmake.lua | 26 - .vim/snippets/gitcommit.lua | 6 - .vim/snippets/go.lua | 35 - .vim/snippets/html.lua | 51 + .vim/snippets/javascript.lua | 26 + .vim/snippets/license_eupl.txt | 287 ++++ .vim/snippets/license_mit0.txt | 18 + .vim/snippets/lua.lua | 25 - .vim/snippets/mail.lua | 15 +- .vim/snippets/markdown.lua | 20 + .vim/snippets/sh.lua | 39 - .vim/snippets/text.lua | 26 - .vim/snippets/zig.lua | 13 + 101 files changed, 2541 insertions(+), 6009 deletions(-) create mode 100644 .vim/after/ftplugin/c.lua delete mode 100644 .vim/after/ftplugin/dirbuf.lua delete mode 100644 .vim/after/ftplugin/gitmessengerpopup.lua delete mode 100644 .vim/after/ftplugin/gitrebase.lua delete mode 100644 .vim/after/ftplugin/go.lua create mode 100644 .vim/after/ftplugin/html.lua delete mode 100644 .vim/after/ftplugin/ledger.lua create mode 100644 .vim/after/ftplugin/lua.lua create mode 100644 .vim/after/ftplugin/mediawiki.lua delete mode 100644 .vim/after/ftplugin/norg.lua delete mode 100644 .vim/after/ftplugin/rust.lua delete mode 100644 .vim/after/ftplugin/scd.lua delete mode 100644 .vim/after/ftplugin/tex.lua delete mode 100644 .vim/after/ftplugin/todofile.lua create mode 100644 .vim/after/queries.bak/markdown/highlights.scm create mode 100644 .vim/after/queries.bak/markdown_inline/highlights.scm delete mode 100644 .vim/after/snippets/c.snippets delete mode 100644 .vim/after/snippets/dockerfile.snippets.todo delete mode 100644 .vim/after/snippets/ebuild.snippets.todo delete mode 100644 .vim/after/snippets/go.snippets delete mode 100644 .vim/after/snippets/go.snippets.todo delete mode 100644 .vim/after/snippets/mail.snippets delete mode 100644 .vim/after/snippets/markdown.snippets.todo delete mode 100644 .vim/after/snippets/readme delete mode 100644 .vim/after/snippets/sh.snippets delete mode 100644 .vim/after/snippets/tex.snippets.todo delete mode 100644 .vim/colorizer-nohash.patch delete mode 100644 .vim/lua/_globals.lua delete mode 100644 .vim/lua/internal/commit-preview.lua create mode 100644 .vim/lua/internal/completion.lua delete mode 100644 .vim/lua/internal/cursor.lua delete mode 100644 .vim/lua/internal/dap.lua delete mode 100644 .vim/lua/internal/find.lua delete mode 100644 .vim/lua/internal/hardmode.lua delete mode 100644 .vim/lua/internal/job.lua delete mode 100644 .vim/lua/internal/lsp.lua delete mode 100644 .vim/lua/internal/lsp_symbols.lua delete mode 100644 .vim/lua/internal/misc.lua delete mode 100644 .vim/lua/internal/notify.lua create mode 100644 .vim/lua/internal/plugins/aerial.lua create mode 100644 .vim/lua/internal/plugins/colorizer.lua create mode 100644 .vim/lua/internal/plugins/colorschemes.lua create mode 100644 .vim/lua/internal/plugins/completion.lua create mode 100644 .vim/lua/internal/plugins/csv.lua create mode 100644 .vim/lua/internal/plugins/gentoo.lua create mode 100644 .vim/lua/internal/plugins/git.lua create mode 100644 .vim/lua/internal/plugins/icons.lua create mode 100644 .vim/lua/internal/plugins/indent.lua create mode 100644 .vim/lua/internal/plugins/lsp.lua create mode 100644 .vim/lua/internal/plugins/mediawiki.lua create mode 100644 .vim/lua/internal/plugins/mini.lua create mode 100644 .vim/lua/internal/plugins/oil.lua create mode 100644 .vim/lua/internal/plugins/telescope.lua create mode 100644 .vim/lua/internal/plugins/todo.lua create mode 100644 .vim/lua/internal/plugins/treesitter.lua create mode 100644 .vim/lua/internal/plugins/whichkey.lua create mode 100644 .vim/lua/internal/plugins/writing.lua create mode 100644 .vim/lua/internal/plugins/zk.lua create mode 100644 .vim/lua/internal/snippets.lua delete mode 100644 .vim/lua/internal/snips.lua delete mode 100644 .vim/lua/internal/sortline.lua delete mode 100644 .vim/lua/internal/spell.lua delete mode 100644 .vim/lua/internal/statusline.lua delete mode 100644 .vim/lua/internal/syncbg.lua delete mode 100644 .vim/lua/internal/zk.lua delete mode 100644 .vim/lua/plugins.lua delete mode 100644 .vim/lua/telescope/_extensions/jobs.lua create mode 100644 .vim/plugin/_globals.lua create mode 100644 .vim/plugin/auto.lua create mode 100644 .vim/plugin/colorscheme.lua create mode 100644 .vim/plugin/diagnostics.lua create mode 100644 .vim/plugin/hardmode.lua create mode 100644 .vim/plugin/keymaps.lua create mode 100644 .vim/plugin/options.lua create mode 100644 .vim/plugin/statuscolumn.lua create mode 100644 .vim/plugin/statusline.lua create mode 100644 .vim/plugin/syncbg.lua create mode 100644 .vim/plugin/termopen.lua create mode 100644 .vim/plugin/undo.lua delete mode 100644 .vim/snippets/.licenses/agpl-3.0 delete mode 100644 .vim/snippets/.licenses/cc0-1.0 delete mode 100644 .vim/snippets/.licenses/gpl-3.0 delete mode 100644 .vim/snippets/.licenses/mit delete mode 100644 .vim/snippets/cmake.lua delete mode 100644 .vim/snippets/gitcommit.lua delete mode 100644 .vim/snippets/go.lua create mode 100644 .vim/snippets/html.lua create mode 100644 .vim/snippets/javascript.lua create mode 100644 .vim/snippets/license_eupl.txt create mode 100644 .vim/snippets/license_mit0.txt delete mode 100644 .vim/snippets/lua.lua create mode 100644 .vim/snippets/markdown.lua delete mode 100644 .vim/snippets/sh.lua delete mode 100644 .vim/snippets/text.lua create mode 100644 .vim/snippets/zig.lua diff --git a/.vim/after/ftplugin/c.lua b/.vim/after/ftplugin/c.lua new file mode 100644 index 0000000..8b2cea9 --- /dev/null +++ b/.vim/after/ftplugin/c.lua @@ -0,0 +1 @@ +vim.opt_local.commentstring = '// %s' diff --git a/.vim/after/ftplugin/dirbuf.lua b/.vim/after/ftplugin/dirbuf.lua deleted file mode 100644 index 4f41efc..0000000 --- a/.vim/after/ftplugin/dirbuf.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.opt_local.list = false - -vim.keymap.set('n', '/', ':Telescope current_buffer_fuzzy_find', { buffer = vim.api.nvim_get_current_buf() }) diff --git a/.vim/after/ftplugin/gitmessengerpopup.lua b/.vim/after/ftplugin/gitmessengerpopup.lua deleted file mode 100644 index ab4688f..0000000 --- a/.vim/after/ftplugin/gitmessengerpopup.lua +++ /dev/null @@ -1 +0,0 @@ -vim.keymap.set('n', 'gd', require('internal.commit-preview').under_cursor, { buffer = 0, desc = 'commit preview' }) diff --git a/.vim/after/ftplugin/gitrebase.lua b/.vim/after/ftplugin/gitrebase.lua deleted file mode 100644 index 6b9e5dc..0000000 --- a/.vim/after/ftplugin/gitrebase.lua +++ /dev/null @@ -1,34 +0,0 @@ -local function commit_preview() - local beforewin = vim.api.nvim_get_current_win() - local commit = vim.api.nvim_get_current_line():match([[ ([0-9a-f]+) ]]) - if not commit then - return - end - require('internal.commit-preview').commit_preview(commit, function(bufnr, winid) - -- keymaps: - local close = function() - pcall(vim.api.nvim_win_close, winid, true) - pcall(vim.api.nvim_buf_delete, bufnr, { force = true }) - end - vim.keymap.set('n', 'q', close, { buffer = bufnr }) - - local goup = function() - vim.api.nvim_set_current_win(beforewin) - vim.cmd('normal k') - vim.cmd('normal cp') - end - vim.keymap.set('n', '', goup, { buffer = bufnr }) - vim.keymap.set('n', '', goup, { buffer = bufnr }) - - local godown = function() - vim.api.nvim_set_current_win(beforewin) - vim.cmd('normal j') - vim.cmd('normal cp') - end - vim.keymap.set('n', '', godown, { buffer = bufnr }) - vim.keymap.set('n', '', godown, { buffer = bufnr }) - end) -end - -vim.keymap.set('n', 'cp', commit_preview, { buffer = 0, desc = 'commit preview' }) -vim.keymap.set('n', 'c', commit_preview, { buffer = 0, desc = 'commit preview' }) diff --git a/.vim/after/ftplugin/go.lua b/.vim/after/ftplugin/go.lua deleted file mode 100644 index cda6a34..0000000 --- a/.vim/after/ftplugin/go.lua +++ /dev/null @@ -1,19 +0,0 @@ --- vim.opt.shiftwidth = 4 - -vim.keymap.set('n', 'i', function() - local iface = vim.fn.input('Impl: ') - if not iface or iface == '' then - return - end - require('internal.cursor').word(function(word) - vim.cmd('normal ][o') - local args = { - 'impl', - '-dir', - vim.fn.expand('%:h:p'), - '"' .. string.lower(word:sub(0, 1)) .. ' *' .. word .. '"', - iface, - } - vim.cmd('r!' .. table.concat(args, ' ')) - end) -end) diff --git a/.vim/after/ftplugin/html.lua b/.vim/after/ftplugin/html.lua new file mode 100644 index 0000000..35f0bd1 --- /dev/null +++ b/.vim/after/ftplugin/html.lua @@ -0,0 +1,20 @@ +local function get_visual_selection() + local start_pos = vim.fn.getpos('v') + local end_pos = vim.fn.getpos('.') + local text = vim.fn.getregion(vim.fn.getpos('v'), vim.fn.getpos('.'), { type = vim.fn.mode() }) + return { start_pos = start_pos, end_pos = end_pos, text = text } +end + +vim.keymap.set('x', '', function() + local sel = get_visual_selection() + vim.print(sel) + vim.api.nvim_buf_set_text( + sel.start_pos[1], -- bufnum + sel.start_pos[2] - 1, -- vim.api funcs use 0-based indexing + sel.start_pos[3] - 1, + sel.end_pos[2] - 1, + sel.end_pos[3], + { '' .. table.concat(sel.text, '') .. '' } + ) + vim.api.nvim_input('') +end, { desc = 'html: make link' }) diff --git a/.vim/after/ftplugin/ledger.lua b/.vim/after/ftplugin/ledger.lua deleted file mode 100644 index bcdcf9a..0000000 --- a/.vim/after/ftplugin/ledger.lua +++ /dev/null @@ -1,2 +0,0 @@ -vim.opt_local.commentstring = '; %s' -vim.opt_local.cursorcolumn = true diff --git a/.vim/after/ftplugin/lua.lua b/.vim/after/ftplugin/lua.lua new file mode 100644 index 0000000..ff08e11 --- /dev/null +++ b/.vim/after/ftplugin/lua.lua @@ -0,0 +1,2 @@ +vim.keymap.set('n', 'x', 'source %', { desc = 'Reload buf' }) +vim.keymap.set('n', 'X', ':Lazy reload ', { desc = 'Reload plugin' }) diff --git a/.vim/after/ftplugin/mail.lua b/.vim/after/ftplugin/mail.lua index 6e0fa20..fba17a2 100644 --- a/.vim/after/ftplugin/mail.lua +++ b/.vim/after/ftplugin/mail.lua @@ -1,4 +1,2 @@ -require('internal.spell') - vim.opt_local.cursorline = false vim.opt_local.commentstring = '> %s' diff --git a/.vim/after/ftplugin/markdown.lua b/.vim/after/ftplugin/markdown.lua index 7e6b22e..9b98392 100644 --- a/.vim/after/ftplugin/markdown.lua +++ b/.vim/after/ftplugin/markdown.lua @@ -1,68 +1,6 @@ --- require('internal.spell') -vim.opt_local.foldenable = false -vim.opt_local.foldlevel = 1 - -vim.fn.matchadd('Conceal', '- \\[ \\]\\&- \\zs\\[ ', 0, -1, { conceal = '☐ ' }) --- vim.fn.matchadd('Conceal', '\\[x\\]', 0, -1, { conceal = '☑ ' }) --- vim.fn.matchadd('Conceal', '\\[-\\]', 0, -1, { conceal = '☒ ' }) -vim.fn.matchadd('Conceal', '- \\[x\\]\\&- \\zs\\[x', 0, -1, { conceal = '🞕 ' }) -vim.fn.matchadd('Conceal', '- \\[[ x]\\zs\\]', 0, -1, { conceal = ' ' }) - -vim.keymap.set('n', 'Markdown_OpenUrlUnderCursor', vim.ui.open) - -vim.keymap.set( - 'n', - 'l', - require('internal.misc').link_preview, - { desc = 'link preview' } -) - -local function toggle_checkbox() - local ln, n = vim.api.nvim_get_current_line(), 0 - ln, n = string.gsub(ln, '%[ %]', '[x]', 1) - if n > 0 then - goto set_line - end - ln, n = string.gsub(ln, '%[x%]', '[ ]', 1) - if n > 0 then - goto set_line - end - ln, n = string.gsub(ln, 'TODO', 'DONE', 1) - if n > 0 then - goto set_line - end - ln, n = string.gsub(ln, 'DONE', 'TODO', 1) - if n > 0 then - goto set_line - end - - ::set_line:: - vim.api.nvim_set_current_line(ln) -end - -vim.keymap.set('n', '', toggle_checkbox, { desc = 'toggle checkbox', buffer = true }) -vim.keymap.set('i', '', toggle_checkbox, { desc = 'toggle checkbox', buffer = true }) - --- vim.keymap.set('n', 'o', function() --- local cursor = vim.api.nvim_win_get_cursor(0) --- -- need to decrement the row number here, to account for 0 indexing --- local node = vim.treesitter.get_node({ --- bufnr = 0, --- pos = { cursor[1] - 1, cursor[2] }, --- }) --- while node do --- if node:type() == 'list_item' then --- local ln = vim.treesitter.get_node_text(node:child(0), 0, {}) --- local ln_start = string.match(ln, '^(%d+)%.') --- if ln_start ~= nil then --- ln = ln:gsub(ln_start, tonumber(ln_start) + 1) --- end --- vim.api.nvim_buf_set_lines(0, cursor[1], cursor[1], false, { ln }) --- vim.api.nvim_feedkeys('jA', 'n', false) --- return --- end --- node = node:parent() --- end --- --- vim.api.nvim_feedkeys('o', 'n', false) --- end, { desc = 'smart-o', buffer = true }) +-- TODO: no idea if this is the best way to do this +-- the part that makes this work lives in ../../../after/ftplugin/markdown.lua +require('null-ls').disable('vale') +vim.keymap.set('n', 'v', function() + require('null-ls').toggle('vale') +end) diff --git a/.vim/after/ftplugin/mediawiki.lua b/.vim/after/ftplugin/mediawiki.lua new file mode 100644 index 0000000..5011e85 --- /dev/null +++ b/.vim/after/ftplugin/mediawiki.lua @@ -0,0 +1,5 @@ +vim.opt.wrap = true +vim.opt.linebreak = true + +vim.keymap.set({ 'n', 'v' }, 'j', 'gj', { buffer = true }) +vim.keymap.set({ 'n', 'v' }, 'k', 'gk', { buffer = true }) diff --git a/.vim/after/ftplugin/norg.lua b/.vim/after/ftplugin/norg.lua deleted file mode 100644 index 9bf66e6..0000000 --- a/.vim/after/ftplugin/norg.lua +++ /dev/null @@ -1 +0,0 @@ -vim.keymap.set('n', 'im', [[:Neorg inject-metadata]]) diff --git a/.vim/after/ftplugin/rust.lua b/.vim/after/ftplugin/rust.lua deleted file mode 100644 index a26bebe..0000000 --- a/.vim/after/ftplugin/rust.lua +++ /dev/null @@ -1 +0,0 @@ -vim.opt_local.makeprg = [[cargo run]] diff --git a/.vim/after/ftplugin/scd.lua b/.vim/after/ftplugin/scd.lua deleted file mode 100644 index e69de29..0000000 diff --git a/.vim/after/ftplugin/tex.lua b/.vim/after/ftplugin/tex.lua deleted file mode 100644 index bf62d26..0000000 --- a/.vim/after/ftplugin/tex.lua +++ /dev/null @@ -1,8 +0,0 @@ -local find_doc_root = require('lspconfig.util').root_pattern('Tectonic.toml') -if find_doc_root(vim.fn.expand('%:p:h')) then - vim.opt_local.makeprg = 'latextbx mk -1' -else - vim.opt_local.makeprg = 'latextbx mk -1 %' -end - -vim.opt_local.textwidth = 80 diff --git a/.vim/after/ftplugin/todofile.lua b/.vim/after/ftplugin/todofile.lua deleted file mode 100644 index 2080d39..0000000 --- a/.vim/after/ftplugin/todofile.lua +++ /dev/null @@ -1,23 +0,0 @@ -local function toggle_todo() - local ln, n = vim.api.nvim_get_current_line(), 0 - ln, n = string.gsub(ln, 'TODO', 'DONE', 1) - if n > 0 then - goto set_line - end - ln, n = string.gsub(ln, 'DONE', 'TODO', 1) - if n > 0 then - goto set_line - end - ln, n = string.gsub(ln, '^(-|*) ', '%1 TODO ') - if n > 0 then - goto set_line - end - - goto exit -- skip over set_current_line - - ::set_line:: - vim.api.nvim_set_current_line(ln) - - ::exit:: -end -vim.keymap.set('n', '', toggle_todo, { desc = 'toggle todo', buffer = true }) diff --git a/.vim/after/queries.bak/markdown/highlights.scm b/.vim/after/queries.bak/markdown/highlights.scm new file mode 100644 index 0000000..9aba385 --- /dev/null +++ b/.vim/after/queries.bak/markdown/highlights.scm @@ -0,0 +1,100 @@ +;; inherits: markdown +;; extends + +;From MDeiml/tree-sitter-markdown & Helix + +(list_item (task_list_marker_checked)) @comment (#set! "priority" 90) + +[ + (list_marker_plus) + (list_marker_minus) + (list_marker_star) + (list_marker_dot) + (list_marker_parenthesis) + (thematic_break) +] @string + +[ + (task_list_marker_checked) + (task_list_marker_unchecked) +] @task_marker + +[ + (atx_h1_marker) + (atx_h2_marker) + (atx_h3_marker) + (atx_h4_marker) + (atx_h5_marker) + (atx_h6_marker) +] @header_marker + +(atx_heading) @header_content + +; concealing +((atx_h1_marker) @header_marker.h1 + (#offset! @header_marker.h1 0 0 0 0) + ;(#set! conceal "󰉫 ") +) + +((atx_h2_marker) @header_marker.h2 + (#offset! @header_marker.h2 0 0 0 0) + ;(#set! conceal "󰉬 ") +) + +((atx_h3_marker) @header_marker.h3 + (#offset! @header_marker.h3 0 0 0 0) + ;(#set! conceal "󰉭 ") +) + +((atx_h4_marker) @header_marker.h4 + (#offset! @header_marker.h4 0 0 0 0) + ;(#set! conceal "󰉮 ") +) + +((atx_h5_marker) @header_marker.h5 + (#offset! @header_marker.h5 0 0 0 0) + ;(#set! conceal "󰉯 ") +) + +((atx_h6_marker) @header_marker.h6 + (#offset! @header_marker.h6 0 0 0 0) + ;(#set! conceal "󰉰 ") +) + +; used for first level list items +((list_marker_star) @list_marker.star + (#offset! @list_marker.star 0 0 0 -1) + ;(#set! conceal "󰅂 ") +) +; used for second level list items +((list_marker_minus) @list_marker.minus + (#offset! @list_marker.minus 0 0 0 -1) + ;(#set! conceal "󰍴 ") +) + +((list_marker_plus) @list_marker.plus + (#offset! @list_marker.plus 0 0 0 -1) + ;(#set! conceal "󰍴 ") +) +((list_marker_dot) @list_marker.dot + (#offset! @list_marker.dot 0 0 0 -1) + ;(#set! conceal "󰍴 ") +) +((list_marker_parenthesis) @list_marker.parenthesis + (#offset! @list_marker.parenthesis 0 0 0 -1) + ;(#set! conceal "󰍴 ") +) + +;; replace '[x]' with 󰄲 +((task_list_marker_checked) @text.todo.checked + (#offset! @text.todo.checked 0 -2 0 0) + (#set! conceal "☑ ") +) + +;; replace '[ ]' with 󰄱 +((task_list_marker_unchecked) @text.todo.unchecked + (#offset! @text.todo.unchecked 0 -2 0 0) + (#set! conceal "☐ ") +) + +([(minus_metadata)] @comment) diff --git a/.vim/after/queries.bak/markdown_inline/highlights.scm b/.vim/after/queries.bak/markdown_inline/highlights.scm new file mode 100644 index 0000000..ab0a7f4 --- /dev/null +++ b/.vim/after/queries.bak/markdown_inline/highlights.scm @@ -0,0 +1,11 @@ +;; inherits: markdown_inline +;; extends + +([ + (code_span_delimiter) + (shortcut_link) +] @comment) + +([ + (link_text) +] @string) diff --git a/.vim/after/snippets/c.snippets b/.vim/after/snippets/c.snippets deleted file mode 100644 index 8b13789..0000000 --- a/.vim/after/snippets/c.snippets +++ /dev/null @@ -1 +0,0 @@ - diff --git a/.vim/after/snippets/dockerfile.snippets.todo b/.vim/after/snippets/dockerfile.snippets.todo deleted file mode 100644 index c8d7502..0000000 --- a/.vim/after/snippets/dockerfile.snippets.todo +++ /dev/null @@ -1,31 +0,0 @@ -# vim: ft=snippets: - -snippet FROM:skel "skeleton" b -#syntax=docker/dockerfile:1.2 - -FROM docker.io/library/alpine:3${1} -$0 - -#vim: ft=Dockerfile: -endsnippet - -snippet FROM:alpine "FROM --platform=$BUILDPLATFORM" -FROM --platform=$BUILDPLATFORM docker.io/library/alpine:3${1} AS base -ARG TARGETPLATFORM -RUN apk -U add --no-cache $0 -endsnippet - -snippet FROM:final "FROM scratch AS final" -FROM scratch AS final -COPY --from=build /out/* / -endsnippet - -snippet RUN "RUN" b -RUN --mount=target=. \ - --mount=target=${1:/root/.cache},type=cache \ - ${0} -endsnippet - -snippet FROM:xx "tonistiigi/xx" b -FROM --platform=$BUILDPLATFORM docker.io/tonistiigi/xx:${1:golang} AS xx -endsnippet diff --git a/.vim/after/snippets/ebuild.snippets.todo b/.vim/after/snippets/ebuild.snippets.todo deleted file mode 100644 index 6856c61..0000000 --- a/.vim/after/snippets/ebuild.snippets.todo +++ /dev/null @@ -1,25 +0,0 @@ -snippet eapi7 "eapi7" -# Copyright `!v strftime('%Y')` Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=7 - -DESCRIPTION="$2" -HOMEPAGE="$3" - -if [[ ${PV} = *9999* ]]; then - inherit git-r3 - EGIT_REPO_URI="https://github.com/$1/${PN}.git" -else - SRC_URI="https://github.com/$1/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz" -fi - -LICENSE="MIT" -SLOT="0" -IUSE="" -KEYWORDS="~amd64 ~arm64 ~x86" - -DEPEND="$0" -RDEPEND="${DEPEND}" -BDEPEND="" -endsnippet diff --git a/.vim/after/snippets/go.snippets b/.vim/after/snippets/go.snippets deleted file mode 100644 index 84df9a1..0000000 --- a/.vim/after/snippets/go.snippets +++ /dev/null @@ -1,20 +0,0 @@ -snippet memfd - func newMemFd(data []byte) (*io.File, error) { - fd, err := unix.MemfdCreate("memfd", 0) - if err != nil { - return nil, err - } - if err := unix.Ftruncate(fd, int64(len(data))); err != nil { - return nil, err - } - var mem []byte - mem, err = unix.Mmap(fd, 0, len(data), unix.PROT_READ|unix.PROT_WRITE, unix.MAP_SHARED) - if err != nil { - return nil, err - } - copy(mem, data) - if err := unix.Munmap(mem); err != nil { - return nil, err - } - return os.NewFile(uintptr(fd), fmt.Sprintf("/proc/self/fd/%d", fd)), nil - } diff --git a/.vim/after/snippets/go.snippets.todo b/.vim/after/snippets/go.snippets.todo deleted file mode 100644 index 3152e3a..0000000 --- a/.vim/after/snippets/go.snippets.todo +++ /dev/null @@ -1,11 +0,0 @@ -snippet main "func main()" -func main() { - ${0} -} -endsnippet - -snippet hfn "http.HandlerFunc" -func $1(w http.ResponseWriter, r *http.Request) { - $0 -} -endsnippet diff --git a/.vim/after/snippets/mail.snippets b/.vim/after/snippets/mail.snippets deleted file mode 100644 index afca39f..0000000 --- a/.vim/after/snippets/mail.snippets +++ /dev/null @@ -1,15 +0,0 @@ - -snippet sehr "Sehr geehrte (...)" - Sehr geehrte Damen und Herren, - - $0 - -snippet mfg "Mit freundlichen Grüßen" - Mit freundlichen Grüßen, - - Robert Günzler - -snippet sign "Signature" - ${1:Cheers}, - - Robert Günzler diff --git a/.vim/after/snippets/markdown.snippets.todo b/.vim/after/snippets/markdown.snippets.todo deleted file mode 100644 index 641e77c..0000000 --- a/.vim/after/snippets/markdown.snippets.todo +++ /dev/null @@ -1,43 +0,0 @@ -snippet new "new page" b ---- -date: "`now`" -title: "$0" ---- -endsnippet - -snippet link "Link" -[$1](${2:${VISUAL}}) -endsnippet - -snippet code "Code block" b -\`\`\`$1 -${2:${VISUAL}} -\`\`\` -$0 -endsnippet - -snippet detail "Detail block" b -
-$1 - -${2:${VISUAL}} - -
-$0 -endsnippet - -snippet todo "todo: generic" -* [ ] $0 -endsnippet - -snippet todoKV "todo: krankenversicherung" -* [ ] $0 - - [ ] überweisung - - [ ] beleg einreichen - - [ ] filings - - [ ] refund -endsnippet - -snippet furigana -$\stackrel{\text{$2}}{\text{$1}}$$0 -endsnippet diff --git a/.vim/after/snippets/readme b/.vim/after/snippets/readme deleted file mode 100644 index c71464a..0000000 --- a/.vim/after/snippets/readme +++ /dev/null @@ -1 +0,0 @@ -move to ~/.vim/snippets and implement in lua diff --git a/.vim/after/snippets/sh.snippets b/.vim/after/snippets/sh.snippets deleted file mode 100644 index d87442e..0000000 --- a/.vim/after/snippets/sh.snippets +++ /dev/null @@ -1,16 +0,0 @@ -snippet deps "for app in" - # check requirements - for tool in $1; do - if ! command -v "$tool" >/dev/null; then - printf "%s: %s not installed but required\n" "$(basename "\$0")" "$tool" >&2 - exit 1 - fi - done - - $0 -snippet doc "script docs" - # - # DESCRIPTION: - # $1 - # - $0 diff --git a/.vim/after/snippets/tex.snippets.todo b/.vim/after/snippets/tex.snippets.todo deleted file mode 100644 index de9a974..0000000 --- a/.vim/after/snippets/tex.snippets.todo +++ /dev/null @@ -1,81 +0,0 @@ -snippet frac "\\frac" iA -\\frac{$1}{$2}$0 -endsnippet - -snippet fun "Function" wA -f: \R \to \R -endsnippet -snippet sum "\sum_" wA -\sum_{n=1}^{${1:\infty}} $0 -endsnippet -snippet !> "\mapsto" wA -\mapsto -endsnippet -snippet -> "\to" wA -\to -endsnippet - -snippet report "\documentclass{report}" -\documentclass{report} -\usepackage[a4paper,margin=30truemm]{geometry} -\usepackage{polyglossia} -% font -\usepackage{fontspec} -\setmainfont{IBM Plex Sans} -\setmonofont{IBM Plex Mono} - -\title{$1} -\author{Robert Günzler} -\date{\today} - -\begin{document} - -$0 - -\end{document} -endsnippet - -snippet brief "\documentclass{dinbrief}" -\documentclass{dinbrief} -\usepackage{graphicx} -\usepackage[a4paper,margin=30truemm]{geometry} -% language -\usepackage{polyglossia} -\setdefaultlanguage[spelling=new]{german} -% font -\usepackage{fontspec} -\setmainfont{IBM Plex Sans} -\setmonofont{IBM Plex Mono} -% dinbrief options -\nowindowtics -\nowindowrules - -% unterschrift -\newcommand{\setsign}{\includegraphics[height=30truemm]{/home/robert/Pictures/sign.png}} -\signature{Robert Günzler} -\address{ -% absender - Robert Günzler \\\\ - STREET \\\\ - PLZ Berlin} - -\date{\today} -\place{Berlin} - -% betreff -% \subject{{\bf anliegen}} - -\begin{document} -\begin{letter}{ -% empfänger - $1} - -\opening{${2:Sehr geehrte Damen und Herren,}} - -$0 - -\vspace{10truemm} -\closing[\protect\setsign]{${3:Mit freundlichen Grüßen}} -\end{letter} -\end{document} -endsnippet diff --git a/.vim/colorizer-nohash.patch b/.vim/colorizer-nohash.patch deleted file mode 100644 index 2215c76..0000000 --- a/.vim/colorizer-nohash.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/lua/colorizer.lua b/lua/colorizer.lua -index e47e079..d986a4a 100644 ---- a/lua/colorizer.lua -+++ b/lua/colorizer.lua -@@ -190,7 +190,7 @@ local function rgb_hex_parser(line, i, minlen, maxlen) - if i > 1 and byte_is_alphanumeric(line:byte(i-1)) then - return - end -- if line:byte(i) ~= b_hash then -+ if line:byte(i) ~= b_hash and (not vim.g.colorizer_nohash) then - return - end - local j = i + 1 - diff --git a/.vim/init.lua b/.vim/init.lua index d46dbfc..e2682cd 100644 --- a/.vim/init.lua +++ b/.vim/init.lua @@ -1,442 +1,48 @@ --- vim: fdm=marker fdl=0 - -vim.cmd [[ - function! LessInitFunc() - set nolist - set nocursorcolumn nocursorline - set laststatus=0 - set readonly - set nonumber - endfunction -]] - local g = vim.g g.mapleader = ' ' -- key to g.maplocalleader = '\\' --- OPTIONS -- {{{ -local opt = vim.opt - -opt.backspace = 'indent,eol,start' -opt.clipboard:prepend({ 'unnamedplus' }) -opt.cmdheight = 1 -opt.colorcolumn = '+1' -opt.formatoptions:remove('t') --- opt.complete = '.,w,b,u' -opt.completeopt = { 'menu', 'menuone', 'noinsert' } -opt.concealcursor = '' -opt.conceallevel = 2 -opt.cursorline = true -opt.expandtab = false -opt.exrc = true -opt.fillchars:append({ - fold = '─', - horiz = '─', -}) -opt.foldenable = true -opt.foldmethod = 'expr' -opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" -opt.foldtext = 'v:lua.vim.treesitter.foldtext()' --- opt.foldlevel = 0 -opt.foldlevelstart = 999 -opt.hidden = true -opt.hlsearch = false -opt.ignorecase = true -opt.inccommand = 'split' -opt.incsearch = true --- 3; https://github.com/neovim/neovim/pull/17266 -opt.laststatus = 3 -opt.lazyredraw = true -opt.list = true -opt.listchars:append({ - trail = '¬', - tab = '> ', - -- space/lead = '⋅', -}) -opt.mouse = 'a' -opt.number = true -opt.relativenumber = false -opt.pumheight = 12 -- 0 use available screenspace -opt.redrawtime = 1500 -opt.ruler = true -opt.scrolloff = 3 -opt.shiftround = true -opt.shortmess:append({ c = true }) -opt.breakindent = true -opt.breakindentopt = { shift = 2 } -opt.showbreak = '↪ ' -opt.showcmd = false -opt.showmode = true -opt.showmatch = true -opt.signcolumn = 'auto' -opt.smartcase = true -opt.spell = false -opt.spelllang = { 'en_gb' } --- opt.splitkeep = 'topline' -opt.termguicolors = true -opt.textwidth = 80 -opt.timeoutlen = 400 -opt.title = true -opt.ttimeoutlen = 10 -opt.undolevels = 1000 -opt.updatetime = 200 -opt.wrap = true -opt.path = { '', '.', '.;$HOME', '/usr/include/**' } -opt.isfname:remove(':') -opt.guicursor = { - -- block shape in normal/visual/command - 'n-c-v:block', - -- bar in insert/cmdline-insert/visual-exclusive - 'i-ci-ve:ver15', - -- underline in replace/cmdline-replace/operator-pending - 'r-cr-o:hor10', - - -- 'sm:block-blinkwait175-blinkoff150-blinkon175', - -- 'a:blinkwait700-blinkoff400-blinkon250-Cgrsor/lCursor', - -- 'a:blinkon0-Cursor', -} - --- configure :grep to use ripgrep if it's available -if vim.fn.executable('rg') then - opt.grepprg = 'rg --vimgrep --smart-case --hidden' - opt.grepformat = '%f:%l:%c:%m' -end - --- persistent undo -local undodir = vim.fn.stdpath('cache') .. '/undodir' -if vim.fn.isdirectory(undodir) == 0 then - vim.fn.mkdir(undodir, 'p', '0700') -end -g.undodir = undodir -opt.undofile = true --- }}} - -opt.background = 'dark' -require('internal.syncbg').setup() - -require('_globals') -require('plugins') - -require('internal.hardmode') - --- TODO: load internal.* like normal plugins using lazy - --- DIAGNOSITIC {{{ -vim.diagnostic.config({ - signs = true, - underline = { - severity = { min = vim.diagnostic.severity.WARN }, - }, - float = { - severity = { min = vim.diagnostic.severity.INFO }, - }, - virtual_text = { - severity = { min = vim.diagnostic.severity.ERROR }, - }, - severity_sort = true, -}) -vim.fn.sign_define({ - { name = 'DiagnosticSignError', text = '✗', texthl = 'DiagnosticSignError', linehl = 'Search' }, - { name = 'DiagnosticSignWarn', text = '▷', texthl = 'DiagnosticSignWarn' }, - { name = 'DiagnosticSignInfo', text = 'ℹ', texthl = 'DiagnosticSignInfo' }, - { name = 'DiagnosticSignHint', text = '🞶', texthl = 'DiagnosticSignHint' }, -}) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Next diagnostic' }) -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Prev diagnostic' }) -vim.keymap.set( - 'n', - 'DD', - vim.diagnostic.open_float, - { desc = 'show line diagnositics' } -) -vim.keymap.set('n', 'td', function() - if not _G.diagnostic_hidden then - vim.diagnostic.hide() - else - vim.diagnostic.show() - end - _G.diagnostic_hidden = not _G.diagnostic_hidden -end, { desc = 'toggle diagnositics' }) --- }}} - --- KEY BINDS -- {{{ -vim.keymap.set('n', 'Q', [[ :quitall ]], { silent = true }) -vim.keymap.set('n', 'gb', [[ :bnext ]], { silent = true }) -vim.keymap.set('n', 'gB', [[ :bprevious ]], { silent = true }) -vim.keymap.set('n', '', [[ :normal za ]], { silent = true }) --- vim.keymap.set('n', '', [[ :exe 'normal za' | IndentBlanklineRefresh ]], {silent = true}) - -vim.keymap.set({ 'n', 'v' }, 'gf', function() - local Path = require('plenary.path') - -- call twice to expand env vars - local cfile = vim.fn.expand(vim.fn.expand('')) - if string.sub(cfile, 0, 7) == 'file://' then - cfile = string.sub(cfile, 8) - end - if not Path:new(cfile):is_absolute() then - cfile = Path:new(vim.fn.expand('%:p:h'), cfile):normalize() - end - vim.cmd.edit(cfile) -end, { desc = 'extends `:e ` with path normalization' }) - -vim.keymap.set('n', '{', [[ {zz ]]) -vim.keymap.set('n', '}', [[ }zz ]]) --- this makes c jump to the start of the line --- vim.keymap.set({'n', 'v'}, 'c', '_c') --- vim.keymap.set({'n', 'v'}, 'C', '_C') - -vim.keymap.set('t', '', [[ ]]) -vim.keymap.set('t', 'qq', [[ :bdelete! ]]) -vim.keymap.set('v', 'T', function() - vim.cmd([[retab!]]) - vim.api.nvim_input('') -end) - -vim.keymap.set('n', 'dgl', 'diffget LOCAL', { desc = 'diff get local' }) -vim.keymap.set('n', 'dgr', 'diffget REMOTE', { desc = 'diff get remote' }) -vim.keymap.set('n', 'dpl', 'diffpush LOCAL', { desc = 'diff push local' }) -vim.keymap.set('n', 'dpr', 'diffpush REMOTE', { desc = 'diff push remote' }) - --- vim.keymap.set('v', '', [[y:%s/h//gc]], { noremap = true, silent = true }) -vim.keymap.set('n', 'yP', function() - local fnln = (vim.fn.expand('%:p') .. ':' .. vim.fn.line('.')) - vim.fn.setreg('+', fnln) - vim.notify(fnln) -end, { desc = 'yank absolute file path' }) -vim.keymap.set('n', 'yT', function() - local fnln = (vim.fn.expand('%:t') .. ':' .. vim.fn.line('.')) - vim.fn.setreg('+', fnln) - vim.notify(fnln) -end, { desc = 'yank file name' }) --- }}} - --- MENU -- {{{ -vim.cmd [[unmenu PopUp.-1-]] -vim.cmd [[unmenu PopUp.How-to\ disable\ mouse]] - -vim.cmd [[nnoremenu PopUp.Inspect :normal K]] -vim.cmd [[nnoremenu PopUp.Goto :normal gd]] -vim.cmd [[nnoremenu PopUp.References :normal gR]] -vim.cmd [[nnoremenu PopUp.Diagnostic :normal DD]] --- }}} - --- AUTO GROUPS -- {{{ -local augroup = vim.api.nvim_create_augroup -local autocmd = vim.api.nvim_create_autocmd - -autocmd('TextYankPost', { callback = vim.highlight.on_yank }) - -do - local group = augroup('ObviousActiveWin', { clear = true }) - autocmd('WinEnter', { command = 'set cul', group = group }) - autocmd('WinLeave', { command = 'set nocul', group = group }) -end - -do - local group = augroup('OpenQuickFix', { clear = true }) - autocmd('QuickFixCmdPost', { - callback = function() - local qf = vim.fn.getqflist({ qfbufnr = true, size = true }) - if (not qf == vim.empty_dict()) and qf and qf.size > 0 then - -- check if the quickfix buffer is already open - for bufnr in ipairs(vim.api.nvim_list_bufs()) do - if vim.api.nvim_buf_get_option_value(bufnr, 'buftype') == 'quickfix' then - return - end - end - vim.cmd.copen() - end - end, - group = group, - }) - autocmd('BufEnter', { - pattern = 'qf', - command = [[silent normal! G]], - group = group, - }) -end - -do - local group = augroup('ManualCommentString', { clear = true }) - autocmd('FileType', { - pattern = 'i3config', - callback = function() - vim.opt_local.commentstring = '# %s' - end, - group = group, - }) - autocmd('FileType', { - pattern = 'jsonc', - callback = function() - vim.opt_local.commentstring = '// %s' - end, - group = group, - }) -end - -do - local group = augroup('ManualFolds', { clear = true }) - autocmd('VimEnter', { - pattern = 'vim/*', - callback = function() - vim.opt_local.foldenable = true - end, - group = group, - }) - autocmd('FileType', { - pattern = 'json,jsonc,yaml,toml', - callback = function() - vim.opt_local.foldenable = false - end, - group = group, - }) -end - -do - local group = augroup('EasyQuit', { clear = true }) - autocmd('FileType', { - pattern = 'help,neorg,dap-float,qf', - callback = function() - vim.keymap.set('n', 'q', 'close', { silent = true, buffer = 0 }) - end, - group = group, - }) - autocmd('FileType', { - pattern = 'alpha', - callback = function() - vim.keymap.set('n', 'q', 'bdel', { silent = true, buffer = 0 }) - end, - group = group, - }) - autocmd('TermClose', { - pattern = 'term://*', - command = [[ if !v:event.status | exe 'bdelete! '..expand('') | endif ]], - group = group, - }) -end - -autocmd({ 'BufRead', 'BufNewFile' }, { - pattern = '/home/robert/bin/*', - callback = function() - vim.opt_local.filetype = 'sh' - end, - group = augroup('DetectBinDir', {}), +-- disable distribution plugins +vim.g.loaded_gzip = 1 +vim.g.loaded_tar = 1 +vim.g.loaded_tarPlugin = 1 +vim.g.loaded_zip = 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_matchit = 1 +vim.g.loaded_2html_plugin = 1 +vim.g.loaded_logiPat = 1 +vim.g.loaded_rrhelper = 1 +vim.g.loaded_netrw = 1 +vim.g.loaded_netrwPlugin = 1 +vim.g.loaded_netrwSettings = 1 +vim.g.loaded_netrwFileHandlers = 1 + +-- prevent bluescreen +-- https://github.com/neovim/neovim/issues/29505 +-- https://github.com/folke/lazy.nvim/issues/1438 +vim.cmd('highlight Normal guibg=NONE guifg=NONE ctermbg=NONE ctermfg=NONE') +vim.opt.termguicolors = true + +-- install lazy +local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' +if not vim.uv.fs_stat(lazypath) then + vim.fn.system({ + 'git', + 'clone', + '--filter=blob:none', + 'https://github.com/folke/lazy.nvim.git', + '--branch=stable', + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) + +require('lazy').setup({ import = 'internal/plugins' }, { + change_detection = { notify = false }, + defaults = { lazy = true }, + dev = { path = '~/src' }, }) - --- autocmd({ 'FileType' }, { --- pattern = 'dirbuf', --- callback = function() --- if not vim.startswith(vim.api.nvim_buf_get_name(0), '/home/robert/zettelkasten') then return end --- vim.notify('hi') --- for i, l in ipairs(vim.api.nvim_buf_get_lines(0, 0, -1, true)) do --- vim.notify(vim.inspect(i, l)) --- end --- end, --- group = augroup('DetectZkDirbuf', {}), --- }) - --- autocmd({ 'TermOpen' }, { --- pattern = 'term://*', --- callback = function() --- local bufnr = vim.api.nvim_get_current_buf() --- vim.opt_local.number = false --- vim.opt_local.relativenumber = false --- vim.opt_local.signcolumn = 'no' --- vim.cmd.split('#0') -- split the previous window --- vim.api.nvim_win_set_height(vim.fn.win_findbuf(bufnr)[1], 20) --- vim.cmd.startinsert() --- end, --- group = augroup('CustomizeTermBuffer', {}), --- }) - --- custom diagnostic settings for zk -autocmd({ 'DiagnosticChanged' }, { - pattern = '*.md', - callback = function(args) - if not (args.data.diagnostics or args.data.diagnostics[1].source == 'zk') then - return - end - if vim.b.did_configure_diagnostics then - return - end - for key, ns in pairs(vim.api.nvim_get_namespaces()) do - if vim.startswith(key, 'vim.lsp.zk') then - vim.b.did_configure_diagnostics = true - vim.diagnostic.config({ - signs = { - severity = vim.diagnostic.severity.INFO, - }, - virtual_text = { - source = false, - prefix = '', - }, - }, ns) - end - end - end, - group = augroup('DiagnosticConfigZk', {}), -}) - -do - local group = augroup('VisualModeRelativeNumber', {}) - autocmd({ 'ModeChanged' }, { - pattern = '*:[vV\x16]*', - callback = function() - vim.opt_local.relativenumber = true - end, - group = group, - }) - autocmd({ 'ModeChanged' }, { - pattern = '[vV\x16]*:*', - callback = function() - -- vim.opt_local.relativenumber = (vim.api.nvim_get_mode().mode ~= '^[vV\x16]') - vim.opt_local.relativenumber = false - end, - group = group, - }) -end --- }}} - -require('internal.misc').setup() -require('internal.find').setup() -require('internal.sortline').setup() - -_G.statusline_enable_notifysend = false -require('internal.statusline') - -require('internal.job').setup({}) - --- TODO: remove eventually -local is_gotmpl = function(bufnr) - for ln = 1, vim.api.nvim_buf_line_count(bufnr), 1 do - local line = vim.api.nvim_buf_get_lines(bufnr, ln - 1, ln, true) - if #line == 0 then - break - end - if line[1]:match('{{.+}}') then - return true - end - end - return false -end -vim.filetype.add({ - extension = { - ha = 'hare', - html = function(_, bufnr) - return is_gotmpl(bufnr) and 'gotmpl.html' or 'html' - end, - yaml = function(_, bufnr) - return is_gotmpl(bufnr) and 'gotmpl.yaml' or 'yaml' - end, - }, - filename = { - ['Caddyfile'] = 'conf', - ['TODO'] = 'todofile', - }, - pattern = { - ['${ZK_NOTEBOOK_DIR}/.*md$'] = 'zk.markdown', - } -}) - --- use bash parsers for gentoo ebuilds -vim.treesitter.language.register('bash', 'ebuild') diff --git a/.vim/lazy-lock.json b/.vim/lazy-lock.json index ec2c5bf..dc26713 100644 --- a/.vim/lazy-lock.json +++ b/.vim/lazy-lock.json @@ -1,56 +1,54 @@ { - "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, - "LuaSnip": { "branch": "master", "commit": "8f3d3465ba5c7ade0a8adb41eca5736f291a3fa8" }, - "aerial.nvim": { "branch": "master", "commit": "83a79f39b709c20be4c830d241379fa85ef21a7c" }, - "clangd_extensions.nvim": { "branch": "main", "commit": "2992ba8c13c2de41f91a7c7488bf1c48bcec31fe" }, + "LuaSnip": { "branch": "master", "commit": "787dee55ca364cc9119787165418fe93b74c1842" }, + "aerial.nvim": { "branch": "master", "commit": "60a784614acb1d7695bd9ae0fee8ada1bf7b0c28" }, + "cmp-async-path": { "branch": "main", "commit": "d6d1ffa2075039632a2d71e8fa139818e15ac757" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, - "cmp-nvim-lsp-document-symbol": { "branch": "main", "commit": "f0f53f704c08ea501f9d222b23491b0d354644b0" }, - "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "3d8912ebeb56e5ae08ef0906e3a54de1c66b92f1" }, - "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, - "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "cmp-spell": { "branch": "master", "commit": "32a0867efa59b43edbb2db67b0871cfad90c9b66" }, + "cmp-cmdline-history": { "branch": "master", "commit": "003573b72d4635ce636234a826fa8c4ba2895ffe" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-nvim-lsp-document-symbol": { "branch": "main", "commit": "f94f7ba948e32cd302caba1c2ca3f7c697fb4fcf" }, + "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "conform.nvim": { "branch": "master", "commit": "8a3fd27fddffe2d2eb24eab90e105ad66e20423c" }, + "decisive.nvim": { "branch": "main", "commit": "a7251adebccbc9c899cff39a524b20d06e2b78b5" }, + "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, + "evangelion.nvim": { "branch": "main", "commit": "75b368c0080fc3c30d5f649d44ed35da82e0fe3a" }, + "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" }, "gentoo-syntax": { "branch": "master", "commit": "2bbb23d32d0546e78e7ecc3b310951b86c781780" }, - "git-messenger.vim": { "branch": "master", "commit": "8a61bdfa351d4df9a9118ee1d3f45edbed617072" }, - "gitlinker.nvim": { "branch": "master", "commit": "542f51784f20107ef9ecdadc47825204837efed5" }, - "gitsigns.nvim": { "branch": "main", "commit": "035da036e68e509ed158414416c827d022d914bd" }, - "grapple.nvim": { "branch": "main", "commit": "493f174a1ace3f2d55ba2191129e43b3875b9124" }, - "guess-indent.nvim": { "branch": "main", "commit": "b8ae749fce17aa4c267eec80a6984130b94f80b2" }, - "indent-blankline.nvim": { "branch": "master", "commit": "3d08501caef2329aba5121b753e903904088f7e6" }, - "lazy.nvim": { "branch": "main", "commit": "3f13f080434ac942b150679223d54f5ca91e0d52" }, - "lsp-status.nvim": { "branch": "master", "commit": "54f48eb5017632d81d0fd40112065f1d062d0629" }, - "markdown-table-mode.nvim": { "branch": "main", "commit": "e10bf5a604cf650e174b78d057294a7430466b88" }, - "mini.align": { "branch": "main", "commit": "b820379e333da87b4ee1eca41792aecea998eee3" }, - "nvim-autopairs": { "branch": "master", "commit": "4f41e5940bc0443fdbe5f995e2a596847215cd2a" }, - "nvim-cmp": { "branch": "main", "commit": "8f3c541407e691af6163e2447f3af1bd6e17f9a3" }, - "nvim-code-action-menu": { "branch": "main", "commit": "8c7672a4b04d3cc4edd2c484d05b660a9cb34a1b" }, - "nvim-colorizer.lua": { "branch": "master", "commit": "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6" }, - "nvim-dap": { "branch": "master", "commit": "6ae8a14828b0f3bff1721a35a1dfd604b6a933bb" }, - "nvim-dap-ui": { "branch": "master", "commit": "5934302d63d1ede12c0b22b6f23518bb183fc972" }, - "nvim-lspconfig": { "branch": "master", "commit": "ae0651d850f8f9313d4db3f96fe24dbf054edeb4" }, - "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, - "nvim-treesitter": { "branch": "master", "commit": "160e5d52c841dc9261c0b2dc6f253bddbcf3d766" }, - "nvim-treesitter-refactor": { "branch": "master", "commit": "65ad2eca822dfaec2a3603119ec3cc8826a7859e" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "23b820146956b3b681c19e10d3a8bc0cbd9a1d4c" }, - "orgmode.nvim": { "branch": "master", "commit": "389e91f6f935aa845bc0cd13dd80f75431c34751" }, + "git-dev.nvim": { "branch": "master", "commit": "57c62bdccbe35eba19532791218fc8fcc24d0d82" }, + "gitgraph.nvim": { "branch": "main", "commit": "01e466b32c346a165135dd47d42f1244eca06572" }, + "gitlinker.nvim": { "branch": "master", "commit": "a221c13fc3c7f5b8799933f4966ee8e618287292" }, + "gitsigns.nvim": { "branch": "main", "commit": "ee7634ab4f0a6606438fe13e16cbf2065589a5ed" }, + "guess-indent.nvim": { "branch": "main", "commit": "6cd61f7a600bb756e558627cd2e740302c58e32d" }, + "indent-blankline.nvim": { "branch": "master", "commit": "e7a4442e055ec953311e77791546238d1eaae507" }, + "lazy.nvim": { "branch": "main", "commit": "cf8ecc2c5e4332760431a33534240b0cbc6680ab" }, + "lazydev.nvim": { "branch": "main", "commit": "491452cf1ca6f029e90ad0d0368848fac717c6d2" }, + "lspkind.nvim": { "branch": "master", "commit": "59c3f419af48a2ffb2320cea85e44e5a95f71664" }, + "markdown.nvim": { "branch": "master", "commit": "dfa0d2def6dbf77e9206b16dc90cad4dd23d55d2" }, + "mediawiki.vim": { "branch": "master", "commit": "26e5737264354be41cb11d16d48132779795e168" }, + "mini.align": { "branch": "main", "commit": "26111a737494bc39576ad67b52bbc2638ca23553" }, + "mini.icons": { "branch": "main", "commit": "a2742459f0ee32806c2438ca06b4d8b331f3f4d4" }, + "mini.surround": { "branch": "main", "commit": "48a9795c9d352c771e1ab5dedab6063c0a2df037" }, + "none-ls.nvim": { "branch": "main", "commit": "dcc8cd4efdcb29275681a3c95786a816330dbca6" }, + "nvim-cmp": { "branch": "main", "commit": "c1e62697f650c68b19deffd952aa6c9d901a5cd6" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "0671e0eabc6842676d3310370e8fae4e1c51d7f9" }, + "nvim-lspconfig": { "branch": "master", "commit": "dc997ac334b811072fe6bf232521511698430eb8" }, + "nvim-treesitter": { "branch": "master", "commit": "377039daa260b71f304c881d1b21d643c501a261" }, + "nvim-treesitter-refactor": { "branch": "master", "commit": "d8b74fa87afc6a1e97b18da23e762efb032dc270" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "0d79d169fcd45a8da464727ac893044728f121d4" }, + "oil.nvim": { "branch": "master", "commit": "39dbf875861449cf09e936fa80073f3413e9439c" }, "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, - "plenary.nvim": { "branch": "master", "commit": "08e301982b9a057110ede7a735dd1b5285eb341f" }, - "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, - "spinner.nvim": { "branch": "master", "commit": "886ce6bed656aed95126d88ea388284aab3c4994" }, - "telescope-dap.nvim": { "branch": "master", "commit": "8c88d9716c91eaef1cdea13cb9390d8ef447dbfe" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" }, - "telescope-lsp-handlers.nvim": { "branch": "trunk", "commit": "de02085d6af1633942549a238bc7a5524fa9b201" }, + "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "render-markdown": { "branch": "main", "commit": "34044cdfcc90b87f32eb962f1fcd9119fc1a62a5" }, + "sqlite.lua": { "branch": "master", "commit": "d0ffd703b56d090d213b497ed4eb840495f14a11" }, + "telescope-all-recent.nvim": { "branch": "main", "commit": "267e9e5fd13a6e9a4cc6ffe00452d446d040401d" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, - "telescope.nvim": { "branch": "master", "commit": "35f94f0ef32d70e3664a703cefbe71bd1456d899" }, - "todo-comments.nvim": { "branch": "main", "commit": "a7e39ae9e74f2c8c6dc4eea6d40c3971ae84752d" }, - "twilight.nvim": { "branch": "main", "commit": "8b7b50c0cb2dc781b2f4262a5ddd57571556d1e4" }, - "vim-indent-object": { "branch": "master", "commit": "8ab36d5ec2a3a60468437a95e142ce994df598c6" }, - "vim-lastplace": { "branch": "master", "commit": "cf0abc5f89c88f0c5219abe89334a8a3ef91fefd" }, - "vim-markdown": { "branch": "master", "commit": "a657e697376909c41475a686eeef7fc7a4972d94" }, - "vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" }, - "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, - "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }, - "zen-mode.nvim": { "branch": "main", "commit": "78557d972b4bfbb7488e17b5703d25164ae64e6a" }, - "zk-nvim": { "branch": "main", "commit": "e2b6d62b18a88249016bf917d4e5bb0e417ac974" } -} \ No newline at end of file + "telescope.nvim": { "branch": "master", "commit": "df534c3042572fb958586facd02841e10186707c" }, + "tiny-inline-diagnostic.nvim": { "branch": "main", "commit": "ccb67504f93b20f36775d3aad620f9dc9ed98bd9" }, + "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, + "twilight.nvim": { "branch": "main", "commit": "1584c0b0a979b71fd86b18d302ba84e9aba85b1b" }, + "which-key.nvim": { "branch": "main", "commit": "8badb359f7ab8711e2575ef75dfe6fbbd87e4821" }, + "zen-mode.nvim": { "branch": "main", "commit": "29b292bdc58b76a6c8f294c961a8bf92c5a6ebd6" }, + "zk-nvim": { "branch": "main", "commit": "aa9b346f2b0ab0c822bef917ee7f607d5c99f7bc" } +} diff --git a/.vim/lua/_globals.lua b/.vim/lua/_globals.lua deleted file mode 100644 index 6aef29b..0000000 --- a/.vim/lua/_globals.lua +++ /dev/null @@ -1,16 +0,0 @@ ----@diagnostic disable: undefined-global - -_G.augroup = function(tbl) - for name, autocmds in pairs(tbl) do - local group = vim.api.nvim_create_augroup(name, { clear = true }) - for _, au in ipairs(autocmds) do - vim.api.nvim_create_autocmd(au[1], { - pattern = au[2], - command = au[3], - group = group, - }) - end - end -end - -_G.floating_win_border = 'solid' diff --git a/.vim/lua/internal/commit-preview.lua b/.vim/lua/internal/commit-preview.lua deleted file mode 100644 index 512b3fb..0000000 --- a/.vim/lua/internal/commit-preview.lua +++ /dev/null @@ -1,67 +0,0 @@ -local M = {} - -function M.under_cursor() - require('internal.cursor').word(require('internal.commit-preview').commit_preview) -end - -function M.commit_preview(commit, on_attach) - if not commit then return end - - local result = require('internal.job') - .jobstart({ - command = 'git', - args = { 'show', '--stat', '--patch', commit }, - format_title = function(_, _) - return 'git-show' - end, - populate_quickfix = false, - }) - :wait() - :result() - - -- create buffer - local bufnr = vim.api.nvim_create_buf(false, true) - assert(bufnr, 'Failed to create buffer') - vim.api.nvim_buf_set_name(bufnr, commit) - vim.api.nvim_set_option_value('filetype', 'commitpreview', { buf = bufnr }) - - -- add lines - vim.api.nvim_set_option_value('modifiable', true, { buf = bufnr }) - vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, result) - vim.api.nvim_set_option_value('modifiable', false, { buf = bufnr }) - - -- create window - local winpos = 'belowright' - local winheight = #result <= 25 and #result or 25 - vim.cmd(string.format('%s %dsplit', winpos, winheight)) -- open split - local winid = vim.api.nvim_get_current_win() - vim.api.nvim_win_set_buf(winid, bufnr) - vim.cmd('wincmd p') - - vim.keymap.set('n', 'gd', M.under_cursor, { buffer = bufnr }) - vim.keymap.set('n', 'q', function() vim.api.nvim_win_close(winid, true) end, { buffer = bufnr }) - - if on_attach then on_attach(bufnr, winid) end - -- close on CursorMoved (anywhere but git-show-buf) - -- local old_cursor = vim.api.nvim_win_get_cursor(beforewin) - -- local group = vim.api.nvim_create_augroup('gitcommit_win_' .. winid, {}) - -- vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { - -- group = group, - -- callback = function() - -- local cursor = vim.api.nvim_win_get_cursor(0) - -- if - -- (old_cursor[1] ~= cursor[1] or old_cursor[2] ~= cursor[2]) - -- and vim.api.nvim_get_current_win() ~= winid - -- then - -- close() - -- return - -- end - -- old_cursor = cursor - -- end, - -- }) - - -- focus - vim.api.nvim_set_current_win(winid) -end - -return M diff --git a/.vim/lua/internal/completion.lua b/.vim/lua/internal/completion.lua new file mode 100644 index 0000000..552a45e --- /dev/null +++ b/.vim/lua/internal/completion.lua @@ -0,0 +1,154 @@ +vim.opt.completeopt = { 'menu', 'menuone', 'noselect' } +vim.opt.shortmess:append('c') +vim.opt.pumheight = 20 -- max height of completion window + +-- re-link the highlight group for the 3rd field in the completion popup +-- which is populated with the completion source +vim.schedule(function() + local hl = vim.api.nvim_set_hl + + hl(0, 'CmpItemMenu', { link = 'Comment', force = true }) + + hl(0, 'CmpItemAbbrMatch', { bold = true, force = true }) + hl(0, 'CmpItemAbbrMatchFuzzy', { link = 'CmpItemAbbrMatch', force = true }) + + hl(0, 'CmpItemKindVariable', { link = 'Normal', force = true }) + hl(0, 'CmpItemKindInterface', { link = 'CmpItemKindVariable', force = true }) + hl(0, 'CmpItemKindText', { link = 'CmpItemKindVariable', force = true }) + + hl(0, 'CmpItemKindFunction', { link = 'Function', force = true }) + hl(0, 'CmpItemKindMethod', { link = 'CmpItemKindFunction', force = true }) + + hl(0, 'CmpItemKindKeyword', { link = 'Keyword', force = true }) + hl(0, 'CmpItemKindProperty', { link = 'CmpItemKindKeyword', force = true }) + hl(0, 'CmpItemKindUnit', { link = 'CmpItemKindKeyword', force = true }) +end) + +local cmp = require('cmp') + +cmp.setup({ + sources = { + { name = 'nvim_lsp', keyword_length = 1, group_index = 1 }, + { name = 'nvim_lsp_signature_help', keyword_length = 1, group_index = 1 }, + { name = 'luasnip', keyword_length = 2, group_index = 1 }, + -- { name = 'spell' }, + { name = 'async_path', group_index = 2 }, + { name = 'buffer', keyword_length = 3, group_index = 2 }, + }, + + mapping = { + [''] = cmp.mapping( + cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + { 'i', 'c' } + ), + [''] = cmp.mapping( + cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + { 'i', 'c' } + ), + [''] = cmp.mapping( + cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }), + { 'i', 'c' } + ), + }, + + -- enable snippet expansion + snippet = { + expand = function(args) + vim.snippet.expand(args.body) + end, + }, + + experimental = { + ghost_text = false, + native_menu = false, + }, + + window = { + completion = { + scrollbar = true, + -- align 'abbr' with cursor, necessary due to 'kind' appearing first + col_offset = -3, + }, + }, + + formatting = { + fields = { 'kind', 'abbr', 'menu' }, + expandable_indicator = true, + format = function(entry, item) + item.dup = 0 -- dedup items from the same source, first one wins + item.menu = '░ ' .. entry.source.name + return require('lspkind').cmp_format({ + mode = 'symbol', + symbol_map = { + -- 󰆼 󱆃 + Array = '󰨾 ', + Boolean = '󰦍 ', + Class = '󰙀 ', + Color = '󰉦 ', + Constant = '󰐀 ', + Constructor = '󱇿 ', + Enum = '󱃢 ', + EnumMember = '󱃡 ', + Event = '󱐋 ', + -- Field = '󰽜 ', + Field = '󰆈 ', + File = '󰈔 ', + Folder = '󰝰 ', + Function = '󰊕 ', + Interface = '󱦜 ', + Key = '󰌋 ', + Keyword = '󰓽 ', + Method = '󰒓 ', + Module = '󰏖 ', + Namespace = '󰆧 ', + Null = '󰎣 ', + Object = '󰘦 ', + Operator = '󱓉 ', + Property = '󰐱 ', + Package = '󰏗 ', + Reference = '󰌹 ', + Snippet = '󰯁 ', + Struct = '󰙅 ', + Text = '󰉿 ', + TypeParameter = '󰌨 ', + Unit = '󰠱 ', + Value = '󰎠 ', + Variable = '󱄑 ', + }, + })(entry, item) + end, + }, +}) + +cmp.setup.cmdline({ ':', '/', '?', '@' }, { + sources = { + { name = 'cmdline', group_index = 1 }, + { name = 'cmdline_history', group_index = 1 }, + { name = 'nvim_lsp_document_symbol', keyword_length = 1, group_index = 1 }, + { name = 'async_path', group_index = 1 }, + { name = 'buffer', group_index = 1 }, + }, + + matching = { + disallow_symbol_nonprefix_matching = false, + }, + + view = { + entries = { selection_order = 'near_cursor' }, + }, + + formatting = { + fields = { 'abbr', 'menu' }, + }, +}) + +cmp.setup.cmdline({ '/', '?' }, { + sources = { + { name = 'nvim_lsp_document_symbol', keyword_length = 1, group_index = 1 }, + { name = 'path', max_item_count = 12, group_index = 1 }, + { name = 'buffer', group_index = 2 }, + }, +}) diff --git a/.vim/lua/internal/cursor.lua b/.vim/lua/internal/cursor.lua deleted file mode 100644 index ad8d8b2..0000000 --- a/.vim/lua/internal/cursor.lua +++ /dev/null @@ -1,11 +0,0 @@ -local M = {} - -function impl(obj, cb) return cb(vim.fn.expand(vim.fn.expand(obj))) end - -function M.word(cb) return impl('', cb) end - -function M.expr(cb) return impl('', cb) end - -function M.file(cb) return impl('', cb) end - -return M diff --git a/.vim/lua/internal/dap.lua b/.vim/lua/internal/dap.lua deleted file mode 100644 index 4b1d776..0000000 --- a/.vim/lua/internal/dap.lua +++ /dev/null @@ -1,173 +0,0 @@ --- vim: fdm=marker - -local dap = require('dap') -dap.defaults.fallback.terminal_win_cmd = 'belowright 10new' -dap.defaults.fallback.focus_terminal = false - --- open repl when session starts -dap.listeners.after['event_initialized']['me'] = function() - -- dap.repl.toggle() -end - --- try loading dap-launch.json --- require('dap.ext.vscode').load_launchjs(vim.fn.getcwd() .. '/dap-launch.json') - --- signs -vim.fn.sign_define({ - { name = 'DapBreakpoint', text = '🞱', texthl = 'DapBreakpoint', linehl = 'DapBreakpointLn' }, -}) -vim.fn.sign_define({ - { name = 'DapStopped', text = '→', texthl = 'DapStopped', linehl = 'DapStoppedLn' }, -}) - --- keymaps -vim.keymap.set('n', 'dd', dap.toggle_breakpoint, { desc = 'toggle breakpoint' }) -- convenience -vim.keymap.set('n', 'db', dap.toggle_breakpoint, { desc = 'toggle breakpoint' }) -vim.keymap.set('n', 'dc', dap.continue, { desc = 'continue' }) -vim.keymap.set('n', 'ds', dap.step_over, { desc = 'step over' }) -vim.keymap.set('n', 'di', dap.step_into, { desc = 'step into' }) -vim.keymap.set('n', 'do', dap.step_out, { desc = 'step out' }) -vim.keymap.set('n', 'dR', dap.repl.toggle, { desc = 'toggle REPL' }) -vim.keymap.set('n', 'dL', dap.run_last, { desc = 'run last' }) -vim.keymap.set('n', 'dq', dap.terminate, { desc = 'terminate' }) - -local widgets = require('dap.ui.widgets') -vim.keymap.set('n', 'dh', widgets.hover, { desc = 'hover' }) -vim.keymap.set( - 'n', - 'dB', - require('telescope').extensions.dap.list_breakpoints, - { desc = 'list breakpoints' } -) - --- Common -local bin_from_var_or_pick = function() - local ok, retval = pcall(vim.api.nvim_get_var, 'dap_bin') -- global let g:dap_bin - if ok then - local workspace_folders = vim.lsp.buf.list_workspace_folders() - if #workspace_folders >= 1 then - retval = retval:gsub(':workspace', workspace_folders[1]) - end - return retval - end - -- NOTE: try to resolve binaries from build system - local bin = nil - vim.ui.input({ prompt = 'DAP: binary to launch: ' }, function(choice) - bin = choice - end) - if not bin == nil then - return bin - end - return false -end - --- Go {{{ -dap.adapters.go_dlv_local = function(callback, config) -- {{{ - local stdout = vim.loop.new_pipe() - local handle - local pid_or_err - local port = 38697 - local opts = { - stdio = { nil, stdout }, - args = { 'dap', '-l', '127.0.0.1:' .. port }, - detached = true, - } - handle, pid_or_err = vim.loop.spawn('dlv', opts, function(exit) - stdout:close() - handle:close() - if exit ~= 0 then - vim.notify('dlv exited with exit code ' .. exit) - end - end) - assert(handle, 'Error running dlv: ' .. tostring(pid_or_err)) - stdout:read_start(function(err, chunk) - assert(not err, err) - if chunk then - vim.schedule(function() - require('dap.repl').append(chunk) - end) - end - end) - vim.defer_fn(function() - callback({ type = 'server', host = '127.0.0.1', port = port }) - end, 100) -end -- }}} - -dap.adapters.go_dlv_remote = { - type = 'server', - host = '127.0.0.1', - port = 38697, -} - -dap.configurations.go = { - { - name = 'Debug (local)', - type = 'go_dlv_local', - request = 'launch', - program = '${file}', - }, - { - name = 'Debug (remote)', - type = 'go_dlv_remote', - request = 'launch', - mode = 'exec', - program = bin_from_var_or_pick, - }, -} --- end of Go }}} - --- C/C++/Rust {{{ -dap.adapters.lldb = { - type = 'executable', - command = '/usr/bin/lldb-vscode', - name = 'lldb', -} - -dap.configurations.c = { - { - name = 'Launch', - type = 'lldb', - request = 'launch', - program = bin_from_var_or_pick, - args = {}, - cwd = '${workspaceFolder}', - stopOnEntry = false, - }, - { - name = 'Attach', - type = 'lldb', - request = 'attach', - pid = require('dap.utils').pick_process, - args = {}, - }, -} -dap.configurations.cpp = dap.configurations.c - --- enable rust types -dap.configurations.rust = vim.tbl_extend('force', dap.configurations.c, { - initCommands = function() - local rustc_sysroot = vim.fn.trim(vim.fn.system('rustc --print sysroot')) - - local script_import = 'command script import "' - .. rustc_sysroot - .. '/lib/rustlib/etc/lldb_lookup.py"' - local commands_file = rustc_sysroot .. '/lib/rustlib/etc/lldb_commands' - - local commands = {} - local file = io.open(commands_file, 'r') - if file then - for line in file:lines() do - table.insert(commands, line) - end - file:close() - end - table.insert(commands, 1, script_import) - - return commands - end, -}) --- end of C/C++/Rust }}} - -local dapui = require('dapui') -dapui.setup {} -vim.keymap.set('n', 'du', dapui.toggle, { desc = 'toggle ui' }) diff --git a/.vim/lua/internal/find.lua b/.vim/lua/internal/find.lua deleted file mode 100644 index 32bdea5..0000000 --- a/.vim/lua/internal/find.lua +++ /dev/null @@ -1,106 +0,0 @@ -local M = {} - -local get_searchdirs = function(dirs) - dirs = dirs or {} - if type(dirs) == 'table' and #dirs > 0 then - return dirs - elseif type(dirs) == 'string' and (dirs == ':workspace') then - dirs = vim.lsp.buf.list_workspace_folders() - elseif type(dirs) == 'string' and not (dirs == '') then - dirs = vim.split(dirs, ',') - end - -- skip asking if we're looking at known filetypes - local ft = vim.api.nvim_buf_get_option(0, 'filetype') - if #dirs == 0 and (ft == 'dirbuf' or ft == 'NvimTree' or ft == 'alpha') then - dirs = { '%:p:h' } - end - -- ask user - if #dirs == 0 then - vim.ui.input({ prompt = 'Search directories: ', default = '%:p:h' }, function(result) - dirs = { result } - end) - end - -- default to something reasonable - if #dirs == 0 then - dirs = { '%:p:h' } - end - -- finally return - return dirs -end - -function onchoice(opts, cb) - if not cb then - return - end - opts.attach_mappings = function(prompt_bufnr) - require('telescope.actions').select_default:replace(function() - local selection = require('telescope.actions.state').get_selected_entry() - if selection == nil then - return - end - require('telescope.actions').close(prompt_bufnr) - on_choice(selection.path) - end) - return true - end -end - -function search_shim(fn, search_dirs, opts, cb) - opts = opts or {} - opts.search_dirs = get_searchdirs(search_dirs) - opts.prompt_title = vim.fn.expand(table.concat(opts.search_dirs, ',')) - onchoice(opts, cb) - fn(opts) -end - -function M.live_grep(search_dirs, opts, cb) - search_shim(require('telescope.builtin').live_grep, search_dirs, opts, cb) -end - -function M.find_files(search_dirs, opts, cb) - -- convenience aliases - if type(search_dirs) == 'string' and search_dirs == 'data' then - search_dirs = vim.fn.stdpath('data') - end - search_shim(require('telescope.builtin').find_files, search_dirs, opts, cb) -end - -function M.setup(opts) - vim.keymap.set('n', ';f', function() - vim.notify('use gsf', vim.log.levels.ERROR) - end, { desc = 'find files' }) - vim.keymap.set('n', ';g', function() - vim.notify('use gsg', vim.log.levels.ERROR) - end, { desc = 'live grep' }) - - vim.keymap.set('n', 'gsg', function() - M.live_grep(':workspace') - end, { desc = 'live grep in workspace' }) - vim.keymap.set('n', 'gsG', M.live_grep, { desc = 'live grep ask' }) - vim.keymap.set('n', 'gs-', function() - M.live_grep('%:p:h') - end, { desc = 'live grep in parent' }) - - vim.keymap.set('n', 'gsf', function() - M.find_files(':workspace') - end, { desc = 'find files in workspace' }) - vim.keymap.set('n', 'gsF', M.find_files, { desc = 'find files ask' }) - - vim.api.nvim_create_user_command('Grep', function(o) - M.live_grep(table.concat(o.fargs)) - end, { - desc = 'live grep (rg)', - nargs = '*', - complete = 'dir', - }) - - vim.api.nvim_create_user_command('Find', function(o) - M.find_files(table.concat(o.fargs)) - end, { - desc = 'find files (fd)', - nargs = '*', - complete = 'dir', - }) -end - -return M diff --git a/.vim/lua/internal/hardmode.lua b/.vim/lua/internal/hardmode.lua deleted file mode 100644 index 2774ead..0000000 --- a/.vim/lua/internal/hardmode.lua +++ /dev/null @@ -1,10 +0,0 @@ --- hard mode means we're not using the arrow keys! - -local bail = function() - vim.cmd([[silent! echohl ErrorMsg | echo "HARD MODE: hjkl operation only" | echohl None]]) -end - -vim.keymap.set({ 'n', 'v', 'i' }, '', bail) -vim.keymap.set({ 'n', 'v', 'i' }, '', bail) -vim.keymap.set({ 'n', 'v', 'i' }, '', bail) -vim.keymap.set({ 'n', 'v', 'i' }, '', bail) diff --git a/.vim/lua/internal/job.lua b/.vim/lua/internal/job.lua deleted file mode 100644 index 2e97f16..0000000 --- a/.vim/lua/internal/job.lua +++ /dev/null @@ -1,181 +0,0 @@ -local M = { - current_jobs = {}, -} - -local strip_ansi = function(line) - line, _ = line:gsub(string.char(27) .. '[[0-9;]*m', '') - return line -end -local setqf = function(opts, pid, data) - if data == nil then - return - end - vim.fn.setqflist({}, 'a', { - title = opts.format_title, - lines = { strip_ansi(data) }, - efm = '%m', - context = { - cmd = { opts.command, unpack(opts.args) }, - pid = pid, - source = 'jobstart', - }, - }) - vim.cmd.doautocmd('QuickFixCmdPost') -end - ---create a new job and register ---@return ~/.local/share/nvim/site/pack/packer/start/plenary.nvim/lua/plenary/job.lua -function M.jobstart(opts) - opts = opts or {} - - opts = vim.tbl_extend('keep', opts or {}, { - enable_spinner = vim.g.job_enable_spinner, - populate_quickfix = vim.g.job_populate_quickfix, - attach = vim.g.job_attach, - }) - - -- vim.notify_once(vim.inspect(opts), vim.log.levels.DEBUG) - - if opts.attach then - return vim.schedule_wrap(function() - vim.cmd.terminal({ args = { opts.command, unpack(opts.args) } }) - end)() - end - - local spinner = {} - if opts.enable_spinner then - local ok = false - ok, spinner = pcall(require, 'spinner.core') - if not ok then - opts.enable_spinner = false - end - end - - if opts.format_title == nil then - opts.format_title = table.concat({ opts.command, unpack(opts.args) }, ' ') - elseif type(opts.format_title) == 'function' then - opts.format_title = opts.format_title(opts.command, opts.args) - elseif type(opts.format_title) == 'string' then - -- noop - else - error(string.format('Invalid field "format_title" of type %s', type(opts.format_title))) - end - - opts.on_start = vim.schedule_wrap(function(j) - M.current_jobs[j.pid] = j - - if opts.populate_quickfix then - vim.fn.setqflist({}, 'r') -- clear quickfix - end - if opts.enable_spinner then - spinner.on_attach(j.pid, opts.format_title, vim.fn.bufnr()) - spinner.on_progress('begin', j.pid, j.pid) - end - end) - - opts.on_exit = vim.schedule_wrap(function(j, code) - M.current_jobs[j.pid] = nil - - if not (code == 0) then - vim.notify(string.format('[%d] exit %d', j.pid, code), vim.log.levels.ERROR) - end - if opts.enable_spinner then - spinner.on_progress('end', j.pid, j.pid) - spinner.on_exit(nil, nil, j.pid) - end - if opts.populate_quickfix then - vim.cmd.doautocmd('QuickFixCmdPost') - end - end) - - opts.on_stdout = vim.schedule_wrap(function(err, data, j) - if err ~= nil then - vim.notify(string.format('[%d] error: %s', j.pid, err), vim.log.levels.ERROR) - end -- handle error? - - if opts.populate_quickfix and opts.populate_quickfix ~= 'onerror' then - setqf(opts, j.pid, data) - end - end) - - opts.on_stderr = vim.schedule_wrap(function(err, data, j) - if err ~= nil then - vim.notify(string.format('[%d] error: %s', j.pid, err), vim.log.levels.ERROR) - end -- handle error? - - if opts.populate_quickfix then - setqf(opts, j.pid, data) - end - end) - - -- run vim.fn.expand() on all args - for i = 1, #opts.args do - opts.args[i] = vim.fn.expandcmd(opts.args[i]) - end - - local j = require('plenary.job'):new(opts) - j:start() - - return j -end - -function M.sh(command, opts) - return M.jobstart(vim.tbl_extend('keep', opts or {}, { - command = vim.env.SHELL, - args = { '-c', command }, - -- strip 'sh -c' from the title (used by progress reporting etc.) - format_title = function(_, args) - return table.concat({ unpack(args, 2, #args) }, ' ') - end, - })) -end - -function M.make(opts) - opts = opts or {} - - local makeprg = vim.fn.expandcmd(vim.opt.makeprg:get()) - local cwd = vim.fn.expand('%:p:h') - - if not (string.match(makeprg, 'make') == nil) then - -- detect makefile - opts.cwd = require('lspconfig.util').root_pattern('Makefile')(cwd) - end - - return M.sh(makeprg, opts) -end - -function M.list() - require('telescope._extensions').manager['jobs']['jobs']() -end - -function M.setup(opts) - opts = vim.tbl_extend('keep', opts, { telescope = true, mappings = true }) - - -- defaults - vim.g.job_enable_spinner = true - vim.g.job_populate_quickfix = 'onerror' - vim.g.job_attach = false - - if opts.telescope then - require('telescope').load_extension('jobs') - vim.api.nvim_create_user_command('Jobs', M.list, { desc = 'list jobs managed by internal.job' }) - if opts.mappings then - vim.keymap.set('n', 'jl', M.list, { desc = 'list jobs managed by internal.job' }) - end - end - - vim.api.nvim_create_user_command('Make', function(a) - require('internal.job').make(a.fargs) - end, { nargs = '*', desc = 'run make target or &makeprg with internal.job' }) - - vim.api.nvim_create_user_command('Sh', function(a) - require('internal.job').sh(table.concat(a.fargs, ' ')) - end, { nargs = '*', desc = 'run shell command with internal.job' }) - - if opts.mappings then - vim.keymap.set('n', 'jm', M.make, { desc = 'run &makeprg with internal.job' }) - vim.keymap.set('n', 'js', ':Sh ', { desc = 'run shell commands with internal.job' }) - end -end - -return M diff --git a/.vim/lua/internal/lsp.lua b/.vim/lua/internal/lsp.lua deleted file mode 100644 index b0aa7dc..0000000 --- a/.vim/lua/internal/lsp.lua +++ /dev/null @@ -1,319 +0,0 @@ --- TODO vim.api.nvim_create_autocmd('LspAttach', { --- callback = function(args) --- local client = vim.lsp.get_client_by_id(args.data.client_id) --- local bufnr = args.buf --- end, --- }) - -local my_attach = function(client, bufnr) - if vim.opt.diff:get() then - vim.notify('not running LSP client in diff mode', vim.log.levels.WARN) - vim.lsp.stop_client(client) - return - end - - local group = vim.api.nvim_create_augroup('LspOnAttach', {}) - vim.api.nvim_create_autocmd('CursorHold', { - buffer = bufnr, - group = group, - callback = function() - if _G.diagnostic_hidden then - return - end - -- evalutate if there's already a floating preview buffer - local existing = vim.F.npcall(vim.api.nvim_buf_get_var, bufnr, 'lsp_floating_preview') - if not existing or not vim.api.nvim_win_is_valid(existing) then - vim.diagnostic.open_float() - end - end, - }) - - require('lsp-status').on_attach(client) - if client.supports_method('textDocument/documentSymbol') then - require('nvim-navic').attach(client, bufnr) - -- require('aerial').on_attach(client, bufnr) - -- vim.keymap.set('n', 'g0', vim.lsp.buf.document_symbol, {buffer = bufnr}) - end - if client.supports_method('workspace/symbol') then - vim.keymap.set( - 'n', - 'gW', - vim.lsp.buf.workspace_symbol, - { buffer = bufnr, desc = 'goto symbol' } - ) - vim.keymap.set( - 'n', - ';s', - require('telescope.builtin').lsp_workspace_symbols, - { desc = 'lsp workspace symbols' } - ) - end - if client.supports_method('textDocument/definition') then - vim.keymap.set( - 'n', - '', - vim.lsp.buf.definition, - { buffer = bufnr, desc = 'goto definition' } - ) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { buffer = bufnr, desc = 'goto definition' }) - vim.keymap.set('n', 'gR', vim.lsp.buf.references, { buffer = bufnr, desc = 'goto references' }) - vim.keymap.set( - 'n', - ';R', - require('telescope.builtin').lsp_references, - { desc = 'lsp references' } - ) - end - if client.supports_method('textDocument/hover') then - vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = bufnr, desc = 'hover' }) - end - if client.supports_method('textDocument/rename') then - vim.keymap.set('n', 'grr', vim.lsp.buf.rename, { buffer = bufnr, desc = 'rename' }) - end - if client.supports_method('signatureHelp') then - vim.keymap.set( - 'n', - '', - vim.lsp.buf.signature_help, - { buffer = bufnr, desc = 'signature help' } - ) - end - if client.supports_method('textDocument/formatting') then - -- if client.server_capabilities.documentFormattingProvider then - vim.api.nvim_set_option_value('formatexpr', 'v:lua.vim.lsp.formatexpr()', { buf = bufnr }) - vim.keymap.set('n', 'f', vim.lsp.buf.format, { buffer = bufnr, desc = 'format' }) - vim.api.nvim_create_autocmd('BufWritePre', { - buffer = bufnr, - callback = function() - vim.cmd.mkview({ bang = true }) - require('internal.lsp').format(vim.fn.expand(':p')) - end, - group = vim.api.nvim_create_augroup('LspAutoFormat', {}), - }) - end - if client.supports_method('textDocument/typeDefinition') then - vim.keymap.set( - 'n', - 'gT', - vim.lsp.buf.type_definition, - { buffer = bufnr, desc = 'goto typedef' } - ) - end - if client.supports_method('textDocument/declaration') then - vim.keymap.set( - 'n', - 'gD', - vim.lsp.buf.declaration, - { buffer = bufnr, desc = 'goto declaration' } - ) - end - if client.supports_method('textDocument/implementation') then - vim.keymap.set( - 'n', - 'gI', - vim.lsp.buf.implementation, - { buffer = bufnr, desc = 'goto implementation' } - ) - end - if client.supports_method('textDocument/codeAction') then - -- vim.keymap.set('n', 'ga', vim.lsp.buf.code_action, { buffer = bufnr, desc = 'code action' }) - vim.keymap.set('n', 'ga', vim.cmd.CodeActionMenu, { buffer = bufnr, desc = 'code action' }) - end - if client.supports_method('textDocument/documentHighlight') then - vim.keymap.set( - 'n', - '8', - vim.lsp.buf.document_highlight, - { buffer = bufnr, desc = 'document highlight' } - ) - -- vim.keymap.set('n', '', vim.lsp.buf.clear_references, {buffer = bufnr, desc = 'clear references'}) - vim.api.nvim_create_autocmd('CursorMoved', { - callback = vim.lsp.buf.clear_references, - buffer = bufnr, - }) - end -end - -local my_exit = function(_, _, _) end - -local capabilities = function() - local caps = vim.lsp.protocol.make_client_capabilities() - - -- enable lsp-based snippets - caps = vim.tbl_extend('keep', caps or {}, require('cmp_nvim_lsp').default_capabilities()) - - -- add window/workDoneProgress capability - caps = vim.tbl_extend('keep', caps or {}, require('lsp-status').capabilities) - return caps -end - -local servers = { - clangd = { - cmd = { - 'clangd', - '--clang-tidy', - '--header-insertion=iwyu', - '--import-insertions', - '--header-insertion-decorators', - } - }, - elixirls = { - cmd = { 'elixir-ls' }, - settings = { - elixirLS = { - dialyzerEnabled = false, - }, - }, - }, - gopls = { - settings = { - gopls = { - analyses = { - -- composites = false, - fieldalignment = true, - nilness = true, - shadow = false, - unusedparams = true, - unusedwrite = true, - }, - gofumpt = true, - -- hoverKind = 'Structured', - }, - }, - }, - lua_ls = { - -- cmd = { 'lua-language-server' }, - cmd = { 'luals' }, -- custom firejail-wrapped - settings = { - Lua = { - runtime = { - version = 'LuaJIT', - path = vim.split(package.path, ';'), - }, - diagnostics = { - globals = { - '_G', - 'assert', - 'error', - 'os', - 'package', - 'pairs', - 'ipairs', - 'pcall', - 'require', - 'string', - 'table', - 'type', - 'unpack', - 'vim', - 'xpcall', - }, - neededFileStatus = { - ['code-style-check'] = 'Any', - }, - }, - format = { - enable = true, - defaultConfig = { - indent_style = 'space', - indent_size = '2', - }, - }, - workspace = { - -- library = vim.api.nvim_get_runtime_file("", true), - library = { - [vim.env.VIMRUNTIME .. '/lua'] = true, - [vim.env.VIMRUNTIME .. '/lua/vim/lsp'] = true, - [vim.fn.stdpath('config') .. '/lua'] = true, - }, - }, - telemetry = { - enable = false, - }, - }, - }, - }, - rust_analyzer = { - -- cmd = { 'env', 'CARGO_TARGET_DIR=/tmp', 'RUST_SRC_PATH=/usr/src/rustlib/library', 'rust-analyzer' }, - settings = { - ['rust-analyzer'] = { - checkOnSave = { - command = { 'cargo', 'clippy' }, - }, - }, - }, - }, - tsserver = {}, - pylsp = {}, - zls = {}, -} - -local setup = function() - -- configure floating win handlers - vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { - focus = false, - zindex = 100, - border = _G.floating_win_border, - }) - vim.lsp.handlers['textDocument/signature_help'] = - vim.lsp.with(vim.lsp.handlers.signature_help, { border = _G.floating_win_border }) - - local caps = capabilities() - for server, opts in pairs(servers) do - if not opts.disabled then - opts = vim.tbl_extend('error', opts, { - on_attach = my_attach, - on_exit = my_exit, - capabilities = caps, - }) - -- lsp-status custom handlers - local ok, lspstatus_ext = pcall(require('lsp-status').extensions[server]) - if ok then - opts = vim.tbl_extend('error', opts, { - handlers = lspstatus_ext.setup(), - }) - end - require('lspconfig')[server].setup(opts) - end - end -end - -local format = function(afile) - if vim.g.nofmt then - return - end - - local errhandler = function(err) - vim.notify('internal.lsp.format: ' .. err, vim.log.levels.ERROR) - return err - end - - -- save folds - pcall(vim.cmd.mkview, { bang = true }) - - -- run lsp format - xpcall(vim.lsp.buf.format, errhandler) - - -- run organize imports for go - if string.match(afile, '.go$') then - xpcall( - vim.lsp.buf.code_action, - errhandler, - { context = { only = { 'source.organizeImports' } }, apply = true } - ) - end - - -- restore folds - pcall(vim.cmd.silent, { 'loadview', bank = true }) - - -- vim.notify('%#MoreMsg#󰃢%#Italic# fmt', vim.log.levels.INFO) - vim.notify('internal.lsp.format: 󰃢', vim.log.levels.INFO) -end - -return { - my_attach = my_attach, - my_exit = my_exit, - capabilities = capabilities, - setup = setup, - format = format, -} diff --git a/.vim/lua/internal/lsp_symbols.lua b/.vim/lua/internal/lsp_symbols.lua deleted file mode 100644 index 97a1b0e..0000000 --- a/.vim/lua/internal/lsp_symbols.lua +++ /dev/null @@ -1,36 +0,0 @@ -return { - -- 󰆼 󱆃 - Array = '󰨾 ', - Boolean = '󰦍 ', - Class = '󰙀 ', - Color = '󰉦 ', - Constant = '󰐀 ', - Constructor = '󱇿 ', - Enum = '󱃢 ', - EnumMember = '󱃡 ', - Event = '󱐋 ', - -- Field = '󰽜 ', - Field = '󰆈 ', - File = '󰈔 ', - Folder = '󰝰 ', - Function = '󰊕 ', - Interface = '󱦜 ', - Key = '󰌋 ', - Keyword = '󰓽 ', - Method = '󰒓 ', - Module = '󰏖 ', - Namespace = '󰆧 ', - Null = '󰎣 ', - Object = '󰘦 ', - Operator = '󱓉 ', - Property = '󰐱 ', - Package = '󰏗 ', - Reference = '󰌹 ', - Snippet = '󰯁 ', - Struct = '󰙅 ', - Text = '󰉿 ', - TypeParameter = '󰌨 ', - Unit = '󰠱 ', - Value = '󰎠 ', - Variable = '󱄑 ', -} diff --git a/.vim/lua/internal/misc.lua b/.vim/lua/internal/misc.lua deleted file mode 100644 index a92b7aa..0000000 --- a/.vim/lua/internal/misc.lua +++ /dev/null @@ -1,223 +0,0 @@ --- misc stuff implemented in lua - -local M = {} - -local function get_visual_selection() - local top = vim.fn.getpos("'<") - top = { ln = top[2], col = top[3] } - local bot = vim.fn.getpos("'>") - bot = { ln = bot[2], col = bot[3] } - local lines = vim.api.nvim_buf_get_lines(0, (top.ln - 1), bot.ln, false) - if vim.opt.selection:get() == 'inclusive' then - lines[#lines] = lines[#lines]:sub(1, bot.col) - else - lines[#lines] = lines[#lines]:sub(1, (bot.col - 1)) - end - lines[1] = lines[1]:sub(top.col) - return top, bot, lines -end - -function M.sort_lines(_, preview_ns, preview_bufnr) - local bufnr = vim.api.nvim_get_current_buf() - - local top, bot, lines = get_visual_selection() - for i = 1, #lines do - lines[i] = vim.fn.join(vim.fn.sort(vim.fn.split(lines[i], ' '))) - end - - if not preview_ns then - vim.api.nvim_buf_set_lines(bufnr, top.ln - 1, bot.ln, false, lines) - vim.notify('no preview') - return 0 - end - - -- inccommand preview - if preview_ns ~= nil then - for i, line in ipairs(lines) do - vim.api.nvim_buf_set_extmark(bufnr, preview_ns, top.ln + i - 2, 0, { - hl_mode = 'combine', - virt_text_pos = 'overlay', - virt_text = { { line, 'Substitute' } }, - }) - - if preview_bufnr ~= nil then - local prefix = string.format('|%d| ', top.ln + i - 1) - vim.api.nvim_buf_set_lines(preview_bufnr, i - 1, -1, false, { prefix .. line }) - vim.api.nvim_buf_add_highlight( - preview_bufnr, - preview_ns, - 'Substitute', - i, - #prefix, - #prefix + #line - ) - end - end - return (#lines > 1 and 2 or 1) - end -end - -local get_searchdirs = function(dirs) - if type(dirs) == 'table' and #dirs > 0 then - return dirs - elseif type(dirs) == 'string' and not (dirs == '') then - dirs = vim.split(dirs, ',') - end - -- skip asking if we're looking at known filetypes - local ft = vim.api.nvim_buf_get_option(0, 'filetype') - if #dirs == 0 and (ft == 'dirbuf' or ft == 'alpha') then - dirs = { '%:p:h' } - end - -- ask user - if #dirs == 0 then - vim.ui.input({ prompt = 'Search directories: ' }, function(result) - dirs = { result } - end) - end - -- default to something reasonable - if #dirs == 0 then - dirs = { '%:p:h' } - end - -- finally return - for i = 1, #dirs do - dirs[i] = vim.fn.expand(dirs[i]) - end - return dirs -end - -local function onchoice(opts, cb) - if not cb then - return - end - opts.attach_mappings = function(prompt_bufnr) - require('telescope.actions').select_default:replace(function() - local selection = require('telescope.actions.state').get_selected_entry() - if selection == nil then - return - end - require('telescope.actions').close(prompt_bufnr) - cb(selection.path) - end) - return true - end -end - -function M.live_grep(dirs, opts, cb) - opts = opts or {} - local search_dirs = get_searchdirs(dirs) - opts.search_dirs = search_dirs - opts.prompt_title = 'Grep: ' .. vim.inspect(search_dirs) - onchoice(opts, cb) - require('telescope.builtin').live_grep(opts) -end - -function M.find_files(dirs, opts, cb) - -- convenience aliases - if dirs == 'plugins' then - dirs = vim.fn.stdpath('data') .. '/site/pack/' - end - - opts = opts or {} - local search_dirs = dirs - if type(dirs) == 'string' then - search_dirs = get_searchdirs(dirs) - end - opts.search_dirs = search_dirs - opts.prompt_title = 'Find: ' .. vim.inspect(search_dirs) - onchoice(opts, cb) - require('telescope.builtin').find_files(opts) -end - -function M.fold_block() -- {{{ - local Comment = require('Comment.api') - local m = vim.api.nvim_buf_get_mark - local inital_cusor_pos = vim.api.nvim_win_get_cursor(0) - local spos, epos = m(0, '<'), m(0, '>') - - -- do start of selection - vim.api.nvim_win_set_cursor(0, spos) - Comment.insert_linewise_eol() - vim.api.nvim_feedkeys('\\', 'ni', true) - local sln = vim.api.nvim_get_current_line() - vim.api.nvim_set_current_line(sln .. '{{{') - - -- do end of selection - vim.api.nvim_win_set_cursor(0, epos) - Comment.insert_linewise_eol() - vim.api.nvim_feedkeys('\\', 'ni', true) - local eln = vim.api.nvim_get_current_line() - vim.api.nvim_set_current_line(eln .. '}}}') - - -- restore initial cursor postition - vim.api.nvim_win_set_cursor(0, inital_cusor_pos) -end -- }}} - -function M.link_preview() - local link = vim.fn.expand('') - if not link then - return - end - - local buf = vim.api.nvim_get_current_buf() - local ln = vim.api.nvim_win_get_cursor(0)[1] - 1 - - require('job') - .jobstart({ - format_title = function() - return 'link-preview' - end, - command = vim.env.SHELL, - args = { - '-c', - [[ curl -sSfL ]] - .. link - .. [[ | grep -iPo '(?<=property="og:title" content=")([^\"]+)(?=")' ]], - }, - populate_quickfix = false, - enable_recording = true, - }) - :after_success(vim.schedule_wrap(function(j, code, _) - local results = j:result() - if not code == 0 or #results == 0 then - return - end - - local ns = vim.api.nvim_create_namespace('') - vim.api.nvim_buf_set_extmark(buf, ns, ln, 0, { - virt_text = { { results[1], 'Error' } }, - virt_text_pos = 'eol', - }) - end)) -end - -function M.setup(opts) - opts = opts or {} - - if opts.sortline then - vim.api.nvim_create_user_command( - 'SortLine', - M.sort_lines, - { desc = 'sort line', range = '%', preview = M.sort_lines } - ) - end - if opts.grep then - vim.api.nvim_create_user_command('Grep', function(o) - M.live_grep(table.concat(o.fargs)) - end, { - desc = 'live grep (rg)', - nargs = '*', - complete = 'dir', - }) - end - if opts.find then - vim.api.nvim_create_user_command('Find', function(o) - M.find_files(table.concat(o.fargs)) - end, { - desc = 'find files (fd)', - nargs = '*', - complete = 'dir', - }) - end -end - -return M diff --git a/.vim/lua/internal/notify.lua b/.vim/lua/internal/notify.lua deleted file mode 100644 index 5445f4f..0000000 --- a/.vim/lua/internal/notify.lua +++ /dev/null @@ -1,105 +0,0 @@ --- notifications cache -_G.statusline_notifications = {} -_G.statusline_notifications_archive = {} - --- out vim.notify implementation -local notify = function(m, l, o) - local lvl_string = l - local hi = nil - if l and type(l) == 'number' then - if l == vim.log.levels.TRACE then - hi = 'deEmph' - elseif l == vim.log.levels.DEBUG then - hi = 'DiagnosticHint' - elseif l == vim.log.levels.INFO then - hi = 'DiagnosticInfo' - elseif l == vim.log.levels.WARN then - hi = 'DiagnosticWarn' - elseif l == vim.log.levels.ERROR then - hi = 'DiagnosticError' - end - -- get level string - lvl_string = vim.lsp.log_levels[l] - end - local display = m - if lvl_string then - display = lvl_string .. ' ' .. display - end - table.insert(_G.statusline_notifications, { - message = m, - level = l, - options = o, - lvl_string = lvl_string, - hi = hi, - display = display, - }) - - if _G.statusline_enable_notifysend then - local args = {} - if lvl_string then - if lvl_string == 'ERROR' then - table.insert(args, '--category=error') - end - if lvl_string == 'WARN' then - table.insert(args, '--category=warning') - end - end - table.insert(args, 'nvim') - table.insert(args, display) - require('internal.job').jobstart({ command = 'notify-send', args = args }) - end -end - --- overwrite vim.notify -vim.notify = function(m, l, o) - if vim.in_fast_event() then - vim.schedule(function() - notify(m, l, o) - end) - else - return notify(m, l, o) - end -end - -vim.keymap.set('n', 'n', function() - local pickers = require('telescope.pickers') - local finders = require('telescope.finders') - local conf = require('telescope.config').values - local actions = require('telescope.actions') - -- local action_state = require('telescope.actions.state') - -- local previewers = require('telescope.previewers') - - local opts = {} - pickers - .new(opts, { - prompt_title = 'Notifications', - finder = finders.new_dynamic({ - fn = function() - return _G.statusline_notifications_archive - end, - entry_maker = function(n) - return { - value = n, - display = n.display, - ordinal = n.message, - } - end, - }), - sorter = conf.generic_sorter(opts), - attach_mappings = function(prompt_bufnr, _) - actions.select_default:replace(function() - actions.close(prompt_bufnr) - -- noop - -- local sel = action_state.get_selected_entry() - -- vim.notify(sel.value.message, sel.value.level, sel.value.options) - end) - return true - end, - -- previewer = previewers.new_buffer_previewer { - -- define_preview = function(self, entry) - -- vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, false, {entry.value.display}) - -- end, - -- }, - }) - :find() -end, { desc = 'notifications' }) diff --git a/.vim/lua/internal/plugins/aerial.lua b/.vim/lua/internal/plugins/aerial.lua new file mode 100644 index 0000000..a5fb4b3 --- /dev/null +++ b/.vim/lua/internal/plugins/aerial.lua @@ -0,0 +1,13 @@ +return { + { + 'stevearc/aerial.nvim', + opts = {}, + dependencies = { + 'nvim-treesitter/nvim-treesitter', + 'echasnovski/mini.icons', + }, + keys = { + { 'b', 'AerialToggle' }, + }, + }, +} diff --git a/.vim/lua/internal/plugins/colorizer.lua b/.vim/lua/internal/plugins/colorizer.lua new file mode 100644 index 0000000..cf55336 --- /dev/null +++ b/.vim/lua/internal/plugins/colorizer.lua @@ -0,0 +1,16 @@ +return { + { + 'NvChad/nvim-colorizer.lua', + -- 'norcalli/nvim-colorizer.lua', + -- events = { 'VeryLazy' }, + lazy = false, + opts = { + name = true, + RRGGBB = true, + RRGGBBAA = false, + rgb_fn = true, + hsl_fn = true, + mode = 'background', + }, + }, +} diff --git a/.vim/lua/internal/plugins/colorschemes.lua b/.vim/lua/internal/plugins/colorschemes.lua new file mode 100644 index 0000000..9371229 --- /dev/null +++ b/.vim/lua/internal/plugins/colorschemes.lua @@ -0,0 +1,11 @@ +return { + { + enabled = false, + 'xero/evangelion.nvim', + lazy = false, + priority = 1000, + config = function() + vim.cmd('colorscheme evangelion') + end, + }, +} diff --git a/.vim/lua/internal/plugins/completion.lua b/.vim/lua/internal/plugins/completion.lua new file mode 100644 index 0000000..db96085 --- /dev/null +++ b/.vim/lua/internal/plugins/completion.lua @@ -0,0 +1,60 @@ +return { + { + -- 'hrsh7th/nvim-cmp', + 'iguanacucumber/magazine.nvim', -- perf improvements + name = 'nvim-cmp', + + lazy = false, + -- event = {'InsertEnter', 'CmdlineEnter' }, + priority = 100, + dependencies = { + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-nvim-lsp', + 'https://codeberg.org/FelipeLema/cmp-async-path', + -- 'hrsh7th/cmp-nvim-lua', + 'hrsh7th/cmp-nvim-lsp-signature-help', -- used to provide function signature completion + 'hrsh7th/cmp-cmdline', + 'dmitmel/cmp-cmdline-history', + 'hrsh7th/cmp-nvim-lsp-document-symbol', -- used by cmdline completion + -- 'f3fora/cmp-spell', + + { 'L3MON4D3/LuaSnip', run = 'make install_jsregexp' }, + 'saadparwaiz1/cmp_luasnip', + + 'onsails/lspkind.nvim', + }, + config = function() + require('internal.snippets') + require('internal.completion') + end, + }, + + -- { -- TODO: try when it doesnt require nightly rust, i dont want binary blobs + -- + -- 'saghen/blink.cmp', + -- lazy = false, + -- -- use a release tag to download pre-built binaries + -- -- version = 'v0.*', + -- -- OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust + -- build = 'cargo build --release', + -- + -- opts = { + -- highlight = { + -- -- sets the fallback highlight groups to nvim-cmp's highlight groups + -- -- useful for when your theme doesn't support blink.cmp + -- -- will be removed in a future release, assuming themes add support + -- use_nvim_cmp_as_default = true, + -- }, + -- + -- -- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- -- adjusts spacing to ensure icons are aligned + -- nerd_font_variant = 'normal', + -- + -- -- experimental auto-brackets support + -- -- accept = { auto_brackets = { enabled = true } } + -- + -- -- experimental signature help support + -- -- trigger = { signature_help = { enabled = true } } + -- }, + -- }, +} diff --git a/.vim/lua/internal/plugins/csv.lua b/.vim/lua/internal/plugins/csv.lua new file mode 100644 index 0000000..bc4cb2c --- /dev/null +++ b/.vim/lua/internal/plugins/csv.lua @@ -0,0 +1,20 @@ +return { + { + 'emmanueltouzery/decisive.nvim', + lazy = true, + ft = { 'csv' }, + main = 'decisive', + keys = { + { + 'a', + function() + require('decisive').align_csv({}) + require('decisive').show_sticky_header() + end, + desc = 'decisive: Align CSV', + }, + { '[,', ":lua require('decisive').align_csv_prev_col()", desc = 'decisive: Prev column' }, + { '],', ":lua require('decisive').align_csv_next_col()", desc = 'decisive: Next column' }, + }, + }, +} diff --git a/.vim/lua/internal/plugins/gentoo.lua b/.vim/lua/internal/plugins/gentoo.lua new file mode 100644 index 0000000..142374c --- /dev/null +++ b/.vim/lua/internal/plugins/gentoo.lua @@ -0,0 +1,15 @@ +return { + { + 'gentoo/gentoo-syntax', + lazy = false, + config = function() + vim.api.nvim_create_autocmd('LspAttach', { + callback = function(args) + if vim.bo.filetype == 'ebuild' then + vim.lsp.stop_client(vim.lsp.get_clients({ bufnr = args.bufnr })) + end + end, + }) + end, + }, +} diff --git a/.vim/lua/internal/plugins/git.lua b/.vim/lua/internal/plugins/git.lua new file mode 100644 index 0000000..d907161 --- /dev/null +++ b/.vim/lua/internal/plugins/git.lua @@ -0,0 +1,108 @@ +return { + { + 'lewis6991/gitsigns.nvim', + lazy = false, + opts = { + signs = { + change = { text = '▋' }, + add = { text = '▋' }, + }, + }, + keys = { + { + ']c', + function() + if vim.wo.diff then + vim.cmd.normal({ ']c', bang = true }) + else + require('gitsigns').nav_hunk('next') + end + end, + desc = 'Gitsigns: next hunk', + }, + { + '[c', + function() + if vim.wo.diff then + vim.cmd.normal({ '[c', bang = true }) + else + require('gitsigns').nav_hunk('prev') + end + end, + desc = 'Gitsigns: prev hunk', + }, + { 'gb', 'Gitsigns blame', desc = 'Gitsigns: blame' }, + { 'gs', 'Gitsigns', desc = 'Gitsigns: select action' }, + { + ';c', + function() + require('gitsigns').setqflist('all', { open = false }) + require('telescope.builtin').quickfix({ prompt_title = 'Git changesets' }) + end, + desc = 'Telescope: list hunks via gitsigns', + }, + }, + }, + + { + 'linrongbin16/gitlinker.nvim', + cmd = { 'GitLink' }, + dependencies = { 'nvim-lua/plenary.nvim' }, + opts = { + message = true, + }, + keys = { + { + 'gl', + vim.cmd.GitLink, + desc = 'gitlinker: clipboard', + }, + }, + }, + + { + 'moyiz/git-dev.nvim', + lazy = true, + cmd = { 'GitDevOpen', 'GitDevCleanAll' }, + opts = { + read_only = false, + }, + }, + + { + 'isakbm/gitgraph.nvim', + dependencies = { 'sindrets/diffview.nvim' }, + opts = { + symbols = { + merge_commit = 'M', + commit = '∙', + }, + format = { + timestamp = '%d-%m-%Y %H:%M:%S %z', + fields = { 'hash', 'timestamp', 'author', 'branch_name', 'tag' }, + }, + }, + init = vim.schedule_wrap(function() + vim.api.nvim_set_hl(0, 'GitGraphBranch1', { fg = 'NvimLightGray1' }) + vim.api.nvim_set_hl(0, 'GitGraphBranch2', { fg = 'NvimLightMagenta' }) + vim.api.nvim_set_hl(0, 'GitGraphBranch3', { fg = 'NvimLightRed' }) + vim.api.nvim_set_hl(0, 'GitGraphBranch4', { fg = 'NvimDarkCyan' }) + vim.api.nvim_set_hl(0, 'GitGraphBranch5', { fg = 'NvimDarkYellow' }) + vim.api.nvim_set_hl(0, 'GitGraphHash', { fg = 'NvimLightMagenta' }) + vim.api.nvim_set_hl(0, 'GitGraphAuthor', { fg = 'NvimLightGray4', italic = true }) + vim.api.nvim_set_hl(0, 'GitGraphTimestamp', { fg = 'NvimLightCyan' }) + vim.api.nvim_set_hl(0, 'GitGraphBranchName', { fg = 'NvimLightYellow' }) + vim.api.nvim_set_hl(0, 'GitGraphBranchTag', { fg = 'NvimLightYellow' }) + vim.api.nvim_set_hl(0, 'GitGraphBranchMsg', { link = 'Normal' }) + end), + keys = { + { + 'g-', + function() + require('gitgraph').draw({}, { all = true, max_count = 5000 }) + end, + desc = 'git graph', + }, + }, + }, +} diff --git a/.vim/lua/internal/plugins/icons.lua b/.vim/lua/internal/plugins/icons.lua new file mode 100644 index 0000000..3d503dc --- /dev/null +++ b/.vim/lua/internal/plugins/icons.lua @@ -0,0 +1,12 @@ +return { + { + 'echasnovski/mini.icons', + version = false, + events = { 'VeryLazy' }, + config = function(_, opts) + require('mini.icons').setup(opts) + ---@diagnostic disable-next-line: undefined-global + MiniIcons.mock_nvim_web_devicons() + end, + }, +} diff --git a/.vim/lua/internal/plugins/indent.lua b/.vim/lua/internal/plugins/indent.lua new file mode 100644 index 0000000..a27a328 --- /dev/null +++ b/.vim/lua/internal/plugins/indent.lua @@ -0,0 +1,28 @@ +return { + -- show indents using virtual text + { + 'lukas-reineke/indent-blankline.nvim', + lazy = false, + main = 'ibl', + opts = { + indent = { + char = '▏', + }, + scope = { + enabled = true, + show_start = false, + show_end = false, + }, + }, + }, + -- detect indent from the buffer contents + { + 'NMAC427/guess-indent.nvim', + lazy = false, + opts = { + auto_cmd = true, + filetype_exclude = { 'netrw', 'tutor', 'dirbuf', 'nvimtree', 'oil' }, + buftype_exclude = { 'help', 'nofile', 'terminal', 'prompt' }, + }, + }, +} diff --git a/.vim/lua/internal/plugins/lsp.lua b/.vim/lua/internal/plugins/lsp.lua new file mode 100644 index 0000000..d138c6c --- /dev/null +++ b/.vim/lua/internal/plugins/lsp.lua @@ -0,0 +1,276 @@ +return { + { + 'neovim/nvim-lspconfig', + lazy = false, + dependencies = { + { 'j-hui/fidget.nvim', opts = {} }, + 'stevearc/conform.nvim', + }, + config = function() + local capabilities = nil + if pcall(require, 'cmp_nvim_lsp') then + capabilities = require('cmp_nvim_lsp').default_capabilities() + end + + local lspconfig = require('lspconfig') + + local servers = { + clangd = { + cmd = { + 'clangd', + '--clang-tidy', + '--header-insertion=iwyu', + '--import-insertions', + '--header-insertion-decorators', + }, + }, + elixirls = { + cmd = { 'elixir-ls' }, + settings = { + elixirLS = { + dialyzerEnabled = false, + }, + }, + }, + gopls = { + settings = { + gopls = { + hints = { + assignVariableTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + constantValues = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true, + }, + analyses = { + -- composites = false, + nilness = true, + shadow = false, + unusedparams = true, + unusedwrite = true, + }, + gofumpt = true, + -- hoverKind = 'Structured', + }, + }, + }, + lua_ls = { + cmd = { 'luals' }, -- custom firejail-wrapped + -- cmd = { 'lua-language-server' }, + settings = { + Lua = { + runtime = { + version = 'LuaJIT', + path = vim.split(package.path, ';'), + }, + diagnostics = { + globals = { + '_G', + 'assert', + 'error', + 'os', + 'package', + 'pairs', + 'ipairs', + 'pcall', + 'require', + 'string', + 'table', + 'type', + 'unpack', + 'vim', + 'xpcall', + }, + neededFileStatus = { + ['code-style-check'] = 'Any', + }, + }, + format = { + enable = true, + defaultConfig = { + indent_style = 'space', + indent_size = '2', + }, + }, + workspace = { + library = { + [vim.env.VIMRUNTIME .. '/lua'] = true, + [vim.env.VIMRUNTIME .. '/lua/vim/lsp'] = true, + [vim.fn.stdpath('config') .. '/lua'] = true, + }, + }, + telemetry = { + enable = false, + }, + }, + }, + }, + rust_analyzer = { + settings = { + ['rust-analyzer'] = { + checkOnSave = { + command = { 'cargo', 'clippy' }, + }, + }, + }, + }, + ts_ls = { + init_options = { + tsserver = { + path = '/usr/lib/node_modules/typescript/lib', + }, + }, + }, + pylsp = {}, + zls = { + cmd = { + 'zls', + '--enable-debug-log', + '--enable-message-tracing', + }, + }, + bashls = {}, + cssls = {}, + jsonls = {}, + html = {}, + superhtml = {}, + kotlin_language_server = { + -- cmd = vim.lsp.rpc.connect('127.0.0.1', 20100), + cmd = { + 'distrobox', + 'enter', + '-n', + 'android-dev', + '--', + '/usr/local/kotlin-langserver/bin/kotlin-language-server', + }, + init_options = { + formatting = { + formatter = 'none', -- disable because we use ktlint via gradle + }, + }, + }, + } + + for name, opts in pairs(servers) do + opts = vim.tbl_deep_extend('force', { + capabilities = capabilities, + }, opts) + lspconfig[name].setup(opts) + end + + vim.api.nvim_create_autocmd('LspAttach', { + callback = function() + -- local client = + -- assert(vim.lsp.get_client_by_id(args.data.client_id), 'must have valid client') + + vim.opt_local.omnifunc = 'v:lua.vim.lsp.omnifunc' + + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { buffer = true }) + vim.keymap.set('n', 'gR', vim.lsp.buf.references, { buffer = true }) + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, { buffer = true }) + vim.keymap.set('n', 'gT', vim.lsp.buf.type_definition, { buffer = true }) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = true }) + vim.keymap.set('n', 'grr', vim.lsp.buf.rename, { buffer = true }) + vim.keymap.set('n', 'ga', vim.lsp.buf.code_action, { buffer = true }) + end, + }) + end, + }, + + { + 'folke/lazydev.nvim', + ft = 'lua', + -- could add a completion source to cmp? + }, + + -- formatting + { + 'stevearc/conform.nvim', + lazy = false, + opts = { + formatters_by_ft = { + lua = { 'stylua' }, + go = { 'goimports', 'gofmt' }, + python = { 'ruff_format' }, + }, + }, + config = function(_, opts) + require('conform').setup(opts) + + vim.api.nvim_create_autocmd('BufWritePre', { + callback = function(args) + if vim.g.nofmt then + return + end + require('conform').format({ + bufnr = args.buf, + lsp_fallback = true, + quiet = true, + }) + end, + }) + end, + }, + + -- linting + { + 'nvimtools/none-ls.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + event = { 'VeryLazy' }, + config = function() + local nls = require('null-ls') + nls.setup({ + sources = { + -- https://github.com/nvimtools/none-ls.nvim/blob/main/doc/BUILTINS.md + -- nls.builtins.code_actions.gitsigns, + nls.builtins.code_actions.impl, + + -- nls.builtins.completion.spell, + + -- nls.builtins.diagnostics.checkmake, + -- nls.builtins.diagnostics.cmake_lint, + -- nls.builtins.diagnostics.cppcheck, + -- nls.builtins.diagnostics.gccdiag, + nls.builtins.diagnostics.golangci_lint, + nls.builtins.diagnostics.hadolint, + -- nls.builtins.diagnostics.pylint, + -- nls.builtins.diagnostics.selene, + -- nls.builtins.diagnostics.semgrep, + nls.builtins.diagnostics.sqlfluff, + -- nls.builtins.diagnostics.stylelint, + -- nls.builtins.diagnostics.textidote, + nls.builtins.diagnostics.vale, + }, + }) + end, + }, + + -- diagnostics + { + 'rachartier/tiny-inline-diagnostic.nvim', + event = 'VeryLazy', + opts = { + signs = { + left = ' ', + right = '', + diag = '', + arrow = '◂ ', + up_arrow = '▴ ', + }, + options = { + throttle = 0, + show_source = true, + }, + }, + config = function(_, opts) + vim.diagnostic.config({ virtual_text = false }) + require('tiny-inline-diagnostic').setup(opts) + if vim.opt.background:get() == 'light' then + require('tiny-inline-diagnostic').change({}, { mixing_color = '#aaaaaa' }) + end + end, + }, +} diff --git a/.vim/lua/internal/plugins/mediawiki.lua b/.vim/lua/internal/plugins/mediawiki.lua new file mode 100644 index 0000000..f557627 --- /dev/null +++ b/.vim/lua/internal/plugins/mediawiki.lua @@ -0,0 +1,6 @@ +return { + { + 'chikamichi/mediawiki.vim', + ft = { 'mediawiki' }, + }, +} diff --git a/.vim/lua/internal/plugins/mini.lua b/.vim/lua/internal/plugins/mini.lua new file mode 100644 index 0000000..1886766 --- /dev/null +++ b/.vim/lua/internal/plugins/mini.lua @@ -0,0 +1,35 @@ +return { + { + 'echasnovski/mini.align', + version = false, + opts = {}, + keys = { + { mode = 'n', 'ga' }, + { mode = 'n', 'gA' }, + { mode = 'v', 'ga' }, + { mode = 'v', 'gA' }, + { + mode = 'v', + '', + function() + vim.cmd([[silent! echohl ErrorMsg | echo "use ga/gA" | echohl None]]) + end, + }, + }, + }, + { + 'echasnovski/mini.surround', + lazy = false, + version = false, + opts = { + mappings = { + delete = 'ds', + replace = 'cs', + }, + }, + keys = { + { mode = 'n', 'cs' }, + { mode = 'n', 'ds' }, + }, + }, +} diff --git a/.vim/lua/internal/plugins/oil.lua b/.vim/lua/internal/plugins/oil.lua new file mode 100644 index 0000000..401fe8b --- /dev/null +++ b/.vim/lua/internal/plugins/oil.lua @@ -0,0 +1,21 @@ +return { + { + 'stevearc/oil.nvim', + lazy = false, + opts = { + keymaps = { + ['gt'] = { + function() + local cwd = require('oil').get_current_dir() + vim.cmd('silent !footclient --no-wait -D ' .. cwd) + end, + nowait = true, + desc = 'Open current directory with foot', + }, + }, + }, + keys = { + { mode = 'n', '-', 'Oil', desc = 'oil: open parent directory' }, + }, + }, +} diff --git a/.vim/lua/internal/plugins/telescope.lua b/.vim/lua/internal/plugins/telescope.lua new file mode 100644 index 0000000..6339a2c --- /dev/null +++ b/.vim/lua/internal/plugins/telescope.lua @@ -0,0 +1,137 @@ +return { + { + 'nvim-telescope/telescope.nvim', + lazy = false, + dependencies = { + { 'nvim-lua/plenary.nvim' }, + { + 'nvim-telescope/telescope-fzf-native.nvim', + build = 'cmake -S. -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release', + }, + { 'nvim-telescope/telescope-ui-select.nvim' }, + }, + config = function(spec, _) + require('telescope').setup({ + defaults = require('telescope.themes').get_ivy({ + prompt = false, + borderchars = { + preview = { '─', '│', '─', '│', '┌', '┐', '┘', '└' }, + }, + }), + + extensions = { + wrap_results = true, + + fzf = {}, + + ['ui-select'] = { + require('telescope.themes').get_ivy({ + prompt = false, + -- sharp edges please + borderchars = { + preview = { '─', '│', '─', '│', '┌', '┐', '┘', '└' }, + }, + layout_config = { height = 9 }, + }), + }, + }, + }) + + pcall(require('telescope').load_extension, 'fzf') + pcall(require('telescope').load_extension, 'ui-select') + + -- user commands + vim.api.nvim_create_user_command( + 'F', + 'Telescope find_files search_dirs=', + { desc = 'Telescope find_files', nargs = '?' } + ) + vim.api.nvim_create_user_command( + 'G', + 'Telescope live_grep search_dirs=', + { desc = 'Telescope live_grep', nargs = '?' } + ) + + -- keymaps + local builtin = require('telescope.builtin') + for _, o in ipairs(spec.keys) do + if not o[2] then + local mod = vim.split(o.desc, ': ')[2] + vim.keymap.set(o.mode, o[1], builtin[mod], { desc = o.desc }) + end + end + + -- highlights + vim.schedule(function() + vim.api.nvim_set_hl(0, 'TelescopeBorder', { fg = 'NvimDarkGrey4', force = true }) + vim.api.nvim_set_hl(0, 'TelescopeTitle', { fg = 'NvimLightMagenta', force = true }) + vim.api.nvim_set_hl(0, 'NormalFloat', { link = 'TelescopeNormal', force = true }) + end) + end, + keys = { + { mode = 'n', ';/', desc = 'telescope: current_buffer_fuzzy_find' }, + { mode = 'n', ';b', desc = 'telescope: buffers' }, + { mode = 'n', ';f', desc = 'telescope: find_files' }, + { mode = 'n', ';g', desc = 'telescope: live_grep' }, + { mode = 'n', ';d', desc = 'telescope: diagnostics' }, + { + mode = 'n', + ';v', + function() + require('telescope.builtin').find_files({ + prompt_title = 'vimrc', + search_dirs = { + vim.fn.stdpath('config'), + }, + }) + end, + desc = 'telescope: vim_config', + }, + { + mode = 'n', + ';;t', + 'Telescope', + desc = 'telescope: select (interactive)', + }, + { + mode = 'n', + ';;f', + function() + local dir + if vim.opt.filetype:get() == 'oil' then + dir = require('oil').get_current_dir() + else + dir = vim.fn.expand('%:p') + end + _G.feedkeys(':Telescope find_files search_dirs=' .. dir) + end, + desc = 'telescope: find_files (interactive)', + }, + { + mode = 'n', + ';;g', + function() + local dir + if vim.opt.filetype:get() == 'oil' then + dir = require('oil').get_current_dir() + else + dir = vim.fn.expand('%:p') + end + _G.feedkeys(':Telescope live_grep search_dirs=' .. dir) + end, + desc = 'telescope: live_grep (interactive)', + }, + }, + }, + + { + 'prochri/telescope-all-recent.nvim', + lazy = false, + dependencies = { + 'nvim-telescope/telescope.nvim', + 'kkharji/sqlite.lua', + }, + after = { 'nvim-telescope/telescope-ui-select.nvim' }, + opts = {}, + }, +} diff --git a/.vim/lua/internal/plugins/todo.lua b/.vim/lua/internal/plugins/todo.lua new file mode 100644 index 0000000..e7ae0a7 --- /dev/null +++ b/.vim/lua/internal/plugins/todo.lua @@ -0,0 +1,46 @@ +return { + { + 'folke/todo-comments.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + lazy = false, + cmd = { 'TodoTelescope' }, + opts = { + merge_keywords = true, + keywords = { + FIX = { icon = '󰃤' }, + TODO = { icon = '󰸞' }, + HACK = { icon = '󰈸' }, + WARN = { icon = '󱇎' }, + PERF = { icon = '󰅒' }, + NOTE = { icon = '󰐃' }, + TEST = { icon = '󰂓' }, + }, + highlight = { + keyword = 'bg', + pattern = [[<(KEYWORDS)(|\(.+\))(:|)]], + }, + search = { + pattern = [[\b(KEYWORDS)(|\(.+\))(:|)]], + }, + }, + keys = { + { mode = 'n', ';t', 'TodoTelescope', desc = 'telescope: todos' }, + { + mode = 'n', + ']t', + function() + require('todo-comments').jump_next() + end, + desc = 'todo: next', + }, + { + mode = 'n', + '[t', + function() + require('todo-comments').jump_prev() + end, + desc = 'todo: prev', + }, + }, + }, +} diff --git a/.vim/lua/internal/plugins/treesitter.lua b/.vim/lua/internal/plugins/treesitter.lua new file mode 100644 index 0000000..b8b1d56 --- /dev/null +++ b/.vim/lua/internal/plugins/treesitter.lua @@ -0,0 +1,124 @@ +return { + { + 'nvim-treesitter/nvim-treesitter', + dependencies = { + -- TODO: https://github.com/nvim-treesitter/nvim-treesitter-context + { 'nvim-treesitter/nvim-treesitter-refactor', lazy = false }, + { 'nvim-treesitter/nvim-treesitter-textobjects', lazy = false }, + { 'nvim-treesitter/playground', cmd = { 'TSPlayground' } }, + }, + lazy = false, + build = ':TSUpdate', + config = function(_, opts) + -- TODO: overwrite parser configs, insert gotmpl + + require('nvim-treesitter.configs').setup(opts) + + -- use bash parser for gentoo ebuilds + vim.treesitter.language.register('bash', 'ebuild') + + -- register mediawiki parser + -- local parser_configs = require('nvim-treesitter.parsers').get_parser_configs() + -- parser_configs.mediawiki = { + -- install_info = { + -- url = 'github.com/Ordoviz/tree-sitter-mediawiki', + -- files = { 'src/parser.c' }, + -- branch = 'main', + -- generate_requires_npm = false, + -- requires_generate_from_grammar = false, + -- }, + -- filetype = 'mediawiki', + -- } + end, + opts = { + ensure_installed = { + 'bash', + 'bibtex', + 'c', + 'c_sharp', + 'cmake', + 'comment', + 'cpp', + 'css', + 'dockerfile', + 'go', + 'gomod', + 'gotmpl', + 'gowork', + 'hare', + 'hcl', + 'html', + 'java', + 'javascript', + 'json', + 'jsonc', + 'kotlin', + 'latex', + 'ledger', + 'lua', + 'make', + 'markdown', + 'markdown_inline', + 'ninja', + 'norg', + 'python', + 'query', + 'regex', + 'rust', + 'scss', + 'sql', + 'toml', + 'typescript', + 'vim', + 'vimdoc', + 'yaml', + 'zig', + + -- external parsers + -- 'mediawiki', -- TODO: missing queries + }, + highlight = { + enable = true, + additional_vim_regex_highlighting = { 'markdown' }, + }, + indent = { + enable = true, + }, + refactor = { + navigation = { + enable = true, + keymaps = { + goto_definition = 'gd', + }, + }, + smart_rename = { + enable = true, + keymaps = { + smart_rename = 'grr', + }, + }, + }, + textobjects = { + select = { + enable = true, + keymaps = { + ['ib'] = '@block.inner', + ['ab'] = '@block.outer', + -- ['ic'] = '@conditional.inner', + -- ['ac'] = '@conditional.outer', + ['if'] = '@function.inner', + ['af'] = '@function.outer', + ['il'] = '@loop.inner', + ['al'] = '@loop.outer', + ['is'] = '@scopename.inner', + ['as'] = '@scopename.outer', + ['ic'] = '@comment.outer', + }, + selection_mode = { + ['@comment.outer'] = 'V', + }, + }, + }, + }, + }, +} diff --git a/.vim/lua/internal/plugins/whichkey.lua b/.vim/lua/internal/plugins/whichkey.lua new file mode 100644 index 0000000..3c9e802 --- /dev/null +++ b/.vim/lua/internal/plugins/whichkey.lua @@ -0,0 +1,9 @@ +return { + { + 'folke/which-key.nvim', + event = 'VeryLazy', + opts = { + icons = { separator = '→ ', group = '🞱 ' }, + }, + }, +} diff --git a/.vim/lua/internal/plugins/writing.lua b/.vim/lua/internal/plugins/writing.lua new file mode 100644 index 0000000..4792697 --- /dev/null +++ b/.vim/lua/internal/plugins/writing.lua @@ -0,0 +1,123 @@ +return { + { + 'folke/zen-mode.nvim', + cmd = { 'ZenMode' }, + opts = { + window = { + -- width = 0.9, + -- height = 0.9, + options = { + cursorline = true, + }, + }, + plugins = { + options = { + number = false, + ruler = false, + showcmd = false, + }, + gitsigns = { enabled = false }, + twilight = { enabled = true }, + }, + on_open = function() + vim.diagnostic.enable(false) + end, + on_close = function() + vim.diagnostic.enable(true) + end, + }, + -- init = function() + -- vim.api.nvim_create_autocmd({ 'BufWinEnter', 'BufWinLeave' }, { + -- pattern = { '*.md' }, + -- command = [[ZenMode]], + -- }) + -- end, + dependencies = { + { + 'folke/twilight.nvim', + opts = { + context = 24, + dimming = { + alpha = 0.5, + color = { 'Normal', '#ffffff' }, + }, + }, + }, + }, + }, + { + 'tadmccorkle/markdown.nvim', + ft = { 'markdown' }, + opts = { + mappings = false, + }, + config = function(_, opts) + require('markdown').setup(opts) + + local set = vim.keymap.set + set('n', '[[', [[(markdown_go_prev_heading)]], { desc = 'md: previous heading' }) + set('n', ']]', [[(markdown_go_next_heading)]], { desc = 'md: next heading' }) + set('n', '', [[:MDTaskToggle]], { desc = 'md: toggle task' }) + set('x', '', [[gv(markdown_add_link_visual)]], { desc = 'md: make link' }) + local toggle_emph = function(key) + return [[gvlua require('markdown.inline').toggle_emphasis_visual(']] + .. key + .. [[')]] + end + set('x', '', toggle_emph('b'), { desc = 'md: make bold' }) + set('x', '', toggle_emph('i'), { desc = 'md: make italic' }) + set('x', '', toggle_emph('s'), { desc = 'md: make strikethrough' }) + set('x', '', toggle_emph('c'), { desc = 'md: make code' }) + end, + }, + { + 'MeanderingProgrammer/markdown.nvim', + name = 'render-markdown', -- needed if used together with markdown.nvim above + main = 'render-markdown', + dependencies = { + 'nvim-treesitter/nvim-treesitter', + 'echasnovski/mini.icons', + }, + ft = { 'markdown' }, + opts = { + heading = { + -- icons = { '❶ ', '❷ ', '❸ ', '❹ ', '❺ ', '❻ ' }, + icons = { + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + }, + signs = { 'ⅰ', 'ⅱ', 'ⅲ', 'ⅳ', 'ⅴ', 'ⅵ' }, + }, + bullet = { + icons = { '∙', '∘', '⋅', '⋄' }, + }, + checkbox = { + checked = { icon = '󰄲 ' }, + unchecked = { icon = '󰄱 ' }, + custom = { + todo = { raw = '[-]', rendered = '󰔟 ', highlight = 'RenderMarkdownTodo' }, + }, + }, + }, + init = vim.schedule_wrap(function() + vim.api.nvim_set_hl(0, 'RenderMarkdownH1Bg', { bg = 'NvimDarkBlue' }) + vim.api.nvim_set_hl(0, 'RenderMarkdownH1Fg', { fg = 'NvimLightBlue' }) + + vim.api.nvim_set_hl(0, 'RenderMarkdownH2Bg', { bg = 'NvimDarkMagenta' }) + vim.api.nvim_set_hl(0, 'RenderMarkdownH2Fg', { fg = 'NvimLightMagenta' }) + + vim.api.nvim_set_hl(0, 'RenderMarkdownH3Bg', { bg = 'NvimDarkYellow' }) + vim.api.nvim_set_hl(0, 'RenderMarkdownH3Fg', { fg = 'NvimLightYellow' }) + + vim.api.nvim_set_hl(0, 'RenderMarkdownH4Bg', { bg = 'NvimDarkCyan' }) + vim.api.nvim_set_hl(0, 'RenderMarkdownH4Fg', { fg = 'NvimLightCyan' }) + + vim.api.nvim_set_hl(0, 'RenderMarkdownH6Bg', { bg = 'NvimDarkRed' }) + vim.api.nvim_set_hl(0, 'RenderMarkdownH6Fg', { fg = 'NvimLightRed' }) + end), + }, +} diff --git a/.vim/lua/internal/plugins/zk.lua b/.vim/lua/internal/plugins/zk.lua new file mode 100644 index 0000000..76cbcb3 --- /dev/null +++ b/.vim/lua/internal/plugins/zk.lua @@ -0,0 +1,35 @@ +return { + { + lazy = false, + 'zk-org/zk-nvim', + main = 'zk', + opts = { + picker = 'telescope', + }, + keys = { + -- these will work everywhere + { ';zc', ':ZkNew ' }, + { ';zz', 'ZkNotes {sort={"modified"}}' }, + { ';zl', 'ZkLinks' }, + { ';zb', 'ZkBacklinks' }, + { ';zt', 'ZkTags' }, + -- { ';zj', 'ZkNotes { dir = "500_journals" }' }, + }, + init = function() + if not vim.env.ZK_NOTEBOOK_DIR then + return + end + vim.api.nvim_create_autocmd({ 'BufEnter' }, { + pattern = vim.env.ZK_NOTEBOOK_DIR .. '/*', + callback = function() + local o = { remap = true, silent = false, buffer = true } + -- these will only work in a zettel + vim.keymap.set('n', '-', ':call feedkeys(";zz")', o) + vim.keymap.set('n', '', 'lua vim.lsp.buf.definition()', o) + end, + group = vim.api.nvim_create_augroup('zk-binds', { clear = true }), + once = true, + }) + end, + }, +} diff --git a/.vim/lua/internal/snippets.lua b/.vim/lua/internal/snippets.lua new file mode 100644 index 0000000..be00884 --- /dev/null +++ b/.vim/lua/internal/snippets.lua @@ -0,0 +1,129 @@ +local ls = require('luasnip') +local types = require('luasnip.util.types') + +-- attach to builtin snippet hooks + +vim.snippet.expand = ls.lsp_expand + +---@diagnostic disable-next-line: duplicate-set-field +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 + +---@diagnostic disable-next-line: duplicate-set-field +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 + +local snip_env = { + -- snippet helpers + nl = function() + return ls.t({ '', '' }) + end, + exec = function(command) + return ls.f(function(_, _, ...) + local job = require('plenary.job'):new({ + command = vim.env.SHELL, + args = { '-c', ... }, + enable_recording = true, + }) + local res, exitcode = job:sync() + if not exitcode == 0 or #res == 0 then + error(string.format('exec "%s" failed', ...)) + end + return res + end, {}, { user_args = { command } }) + end, + -- condition helpers + cond = { + ts = function(capture) + return function() + return vim.tbl_contains(vim.treesitter.get_captures_at_cursor(), capture) + end + end, + }, +} + +ls.config.set_config({ + enable_autosnippets = true, + history = true, + updateevents = 'TextChanged,TextChangedI', + override_builtin = true, + snip_env = vim.tbl_deep_extend('error', ls.session.config.snip_env, snip_env), + ext_opts = { + [types.choiceNode] = { + active = { + virt_text = { { '◂ 󰬊 ', 'NonText' } }, + }, + }, + [types.insertNode] = { + active = { + virt_text = { { '◂ 󰬐 ', 'NonText' } }, + }, + }, + }, +}) + +require('luasnip.loaders.from_lua').lazy_load({ paths = './snippets' }) + +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' }) + +vim.api.nvim_create_user_command('EditSnippets', require('luasnip.loaders').edit_snippet_files, {}) + +-- vim.api.nvim_create_autocmd('User', { +-- pattern = 'LuasnipChoiceNodeEnter', +-- callback = function() +-- vim.schedule(function() +-- assert(ls.session.active_choice_nodes[vim.api.nvim_get_current_buf()], 'No active choiceNode') +-- vim.ui.select( +-- ls.get_current_choices(), +-- -- TODO: patch luasnip.extras.select_choice to fix missing prompt +-- { prompt = 'LuaSnip: choice node', kind = 'luasnip' }, +-- function(_, idx) +-- if not idx then +-- return +-- end +-- -- feed+immediately execute i to enter INSERT after vim.ui.input closes. +-- vim.api.nvim_feedkeys('i', 'x', false) +-- ls.set_choice(idx) +-- ls.unlink_current() +-- end +-- ) +-- end) +-- end, +-- }) diff --git a/.vim/lua/internal/snips.lua b/.vim/lua/internal/snips.lua deleted file mode 100644 index bb9fdef..0000000 --- a/.vim/lua/internal/snips.lua +++ /dev/null @@ -1,159 +0,0 @@ -local ls = require('luasnip') -local types = require('luasnip.util.types') - -vim.api.nvim_set_hl(0, 'LuasnipIndicator', { - fg = vim.g.terminal_color_15, - bg = vim.g.terminal_color_1, - italic = true, - nocombine = true, -}) - --- autowrap: wraps the function in top and bot if there is any content -local autowrap = function(top, bot, inner) - local autoinsert = function(args, _, _, wrap_with) - local nodes = {} - if vim.trim(table.concat(args[1] or {})) ~= '' then - table.insert(nodes, wrap_with) - end - return ls.sn(nil, nodes) - end - - local argnodes = {} - local maxpos = -1 - for _, e in ipairs(inner) do - if e.pos ~= nil then - table.insert(argnodes, e.pos) - if e.pos > maxpos then - maxpos = e.pos - end - end - end - - local nodes = {} - table.insert(nodes, ls.d(maxpos + 1, autoinsert, argnodes, { user_args = { top } })) - for _, e in ipairs(inner) do - table.insert(nodes, e) - end - table.insert(nodes, ls.d(maxpos + 2, autoinsert, argnodes, { user_args = { bot } })) - return nodes -end - --- comment: wraps the content in &commentstring (or a blockcomment) -local comment = function(wrapped, blockcomment) - -- commentstring helper - local get_cstring = function() - local cs = require('Comment.ft').calculate({ - ctype = blockcomment and 2 or 1, - range = require('Comment.utils').get_region(), - }) - local tbl = vim.split(cs or '', '%s', { plain = true, trimempty = true }) - return (#tbl == 0) and { '', '' } - or ((#tbl == 1) and { tbl[1] .. ' ', '' } or { tbl[1], tbl[2] }) - end - - if type(wrapped) ~= 'table' then - wrapped = { wrapped } - end - - local nodes = {} - table.insert( - nodes, - ls.f(function() - return get_cstring()[1] - end) - ) - for _, n in ipairs(wrapped) do - table.insert(nodes, n) - end - table.insert( - nodes, - ls.f(function() - return get_cstring()[2] - end) - ) - return nodes -end - --- exec: inserts the output of command -local exec = function(command) - return ls.f(function(_, _, ...) - local results, code = require('plenary.job') - :new({ - command = vim.env.SHELL, - args = { '-c', ... }, - enable_recording = true, - }) - :sync() - if not code == 0 or #results == 0 then - error(string.format('exec "%s" failed', ...)) - end - return results - end, {}, { user_args = { command } }) -end - -local file_contents = function(path, vargs) - return ls.d(1, function(_, _, _, ...) - local lines = {} - for line in io.lines(path) do - table.insert(lines, line) - end - return ls.sn(nil, require('luasnip.extras.fmt').fmt(table.concat(lines, '\n'), ...)) - end, {}, { user_args = { vargs } }) -end - -ls.setup({ - history = true, - update_events = 'TextChanged,TextChangedI', - delete_check_events = 'TextChanged', - - ext_opts = { - [types.snippet] = { - active = { - virt_text = { { '<-- snippet', 'LuasnipIndicator' } }, - virt_text_pos = 'right_align', - }, - }, - [types.insertNode] = { - unvisited = { hl_group = 'LuasnipIndicator' }, - }, - [types.choiceNode] = { - active = { - virt_text = { { '<-- choice node', 'LuasnipIndicator' } }, - }, - }, - }, - snip_env = vim.tbl_extend('keep', ls.session.config.snip_env, { - f = ls.f, - i = ls.i, - s = ls.s, - t = ls.t, - c = ls.c, - sn = ls.sn, - fmt = require('luasnip.extras.fmt').fmt, - autowrap = autowrap, - exec = exec, - comment = comment, - file_contents = file_contents, - user_email = { - exec([[git config --get user.name]]), - ls.t(' <'), - ls.c(1, { - exec([[git config --get user.email]]), - ls.t([[robert.gunzler@postman.com]]), - ls.t([[robert@gnzler.io]]), - }), - ls.t('>'), - }, - }), -}) - --- snipmate snippets --- require('luasnip.loaders.from_snipmate').lazy_load({ paths = './after/snippets' }) --- lua snippets -require('luasnip.loaders.from_lua').lazy_load({ paths = './snippets' }) - -vim.api.nvim_create_user_command('LuaSnipUnlinkAll', function() - while #package.loaded.luasnip.session.current_nodes > 0 do - package.loaded.luasnip.unlink_current() - end -end, { desc = 'unlink all active snippets' }) diff --git a/.vim/lua/internal/sortline.lua b/.vim/lua/internal/sortline.lua deleted file mode 100644 index 69f7f64..0000000 --- a/.vim/lua/internal/sortline.lua +++ /dev/null @@ -1,78 +0,0 @@ -local M = {} - -local function get_visual_selection(intact) - intact = intact or false - local top = vim.fn.getpos("'<") - top = { ln = top[2], col = top[3] } - local bot = vim.fn.getpos("'>") - bot = { ln = bot[2], col = bot[3] } - local lines = vim.api.nvim_buf_get_lines(0, (top.ln - 1), bot.ln, false) - if not intact then - if vim.opt.selection:get() == 'inclusive' then - lines[#lines] = lines[#lines]:sub(1, bot.col) - else - lines[#lines] = lines[#lines]:sub(1, (bot.col - 1)) - end - lines[1] = lines[1]:sub(top.col) - end - return top, bot, lines -end - -local function sortline(line, a, o, separator) - separator = separator or ' ' - local result, _ = string.gsub(line, string.sub(line, a, o), - table.concat(vim.fn.sort(vim.fn.split(string.sub(line, a, o), separator)), separator), 1) - return result -end - -function M.sort_lines(_, preview_ns, preview_bufnr) - local bufnr = vim.api.nvim_get_current_buf() - - local top, bot, lines = get_visual_selection(true) - vim.pretty_print(top, bot, lines) - for i = 1, #lines do - local a = 0; if i == 1 then a = top.col end - local o = -1; if i == #lines then o = bot.col end - lines[i] = sortline(lines[i], a, o, ' ') - end - - if not preview_ns then - vim.api.nvim_buf_set_lines(bufnr, top.ln - 1, bot.ln, false, lines) - return 0 - end - - -- inccommand preview - if preview_ns ~= nil then - for i, line in ipairs(lines) do - vim.api.nvim_buf_set_extmark(bufnr, preview_ns, top.ln + i - 2, 0, { - hl_mode = 'combine', - virt_text_pos = 'overlay', - virt_text = { { line, 'Substitute' } }, - }) - - if preview_bufnr ~= nil then - local prefix = string.format('|%d| ', top.ln + i - 1) - vim.api.nvim_buf_set_lines(preview_bufnr, i - 1, -1, false, { prefix .. line }) - vim.api.nvim_buf_add_highlight( - preview_bufnr, - preview_ns, - 'Substitute', - i, - #prefix, - #prefix + #line - ) - end - end - return (#lines > 1 and 2 or 1) - end -end - -function M.setup(opts) - vim.api.nvim_create_user_command( - 'SortLine', - M.sort_lines, - { desc = 'sort line', range = '%', preview = M.sort_lines } - ) -end - -return M diff --git a/.vim/lua/internal/spell.lua b/.vim/lua/internal/spell.lua deleted file mode 100644 index 3c37dad..0000000 --- a/.vim/lua/internal/spell.lua +++ /dev/null @@ -1,8 +0,0 @@ -vim.opt_local.spell = true -vim.opt.spellfile = vim.fn['spellfile#WritableSpellDir']() .. '/spellfile.utf-8.add' -vim.opt.spellcapcheck = '' -vim.opt.spelloptions = { 'camel' } -vim.opt.spellsuggest = 'double' - -vim.keymap.set('n', '', require('telescope.builtin').spell_suggest) -vim.keymap.set('n', '', [[u[s1z=`]au]]) diff --git a/.vim/lua/internal/statusline.lua b/.vim/lua/internal/statusline.lua deleted file mode 100644 index 8ed5cae..0000000 --- a/.vim/lua/internal/statusline.lua +++ /dev/null @@ -1,206 +0,0 @@ -function _G.statusline() - local bufnr = vim.fn.bufnr() or 0 - local hi = statusline_color(vim.fn.mode()) - - local sl = hi - -- sl = sl .. statusline_append([[ ⢷]], 'StatusLineIcon', hi) - - sl = sl .. [[%-h%-w%-q%-f %-m %-r]] - - sl = sl .. statusline_append(statusline_grapple(bufnr), 'StatusLineGrapple', hi) - - -- sl = sl .. statusline_append(statusline_ts(), 'StatusLineTreesitter', hi) - - sl = sl .. [[ %= ]] -- spacer - - sl = sl .. statusline_append(statusline_lsp_diagnostics(bufnr, hi), 'StatusLineDiagnostics', hi) - - sl = sl .. statusline_append(statusline_lspstatus(), 'StatusLineLsp', hi) - - sl = sl .. statusline_append(statusline_dap(), 'StatusLineDap', hi) - - -- sl = sl .. [[ %= ]] -- spacer - - sl = sl .. statusline_append(statusline_notify(hi), 'StatusLineNotify', hi) - - sl = sl .. statusline_append(statusline_spinner(bufnr), 'StatusLineJobs', hi) - - sl = sl .. [[%-l:%-v --%p%%-- %-Y]] - - return sl -end - -function _G.statusline_color(mode) - local hi = '%*' - if mode == 'i' then - -- hi = '%#StatusLineInsert#' - elseif mode == 'c' then - -- hi = '%#StatusLineCommand#' - elseif mode == 'v' or mode == 'V' or mode == '' then - hi = '%#StatusLineVisual#' - elseif mode == 'R' or mode == 'Rv' then - hi = '%#StatusLineReplace#' - end - -- return '%{g:actual_curwin==win_getid()?'.. hi ..':%#StatusLineNC#}' - return hi -end - --- does item highlighting and conditionnal spacing -function _G.statusline_append(element, hi, default_hi, opts) - if not element or element == '' then - return '' - end - opts = opts or { append_space = true } - - if hi ~= nil then - hi = '%#' .. hi .. '#' - end - if not (default_hi == '%*') then - hi = default_hi - end - local el = hi .. element .. default_hi - if opts.append_space then - el = el .. ' ' - end - return el -end - -function _G.statusline_combine_hi(outer_name, inner_name) - local outer = vim.api.nvim_get_hl(0, { name = outer_name, create = false }) - local inner = vim.api.nvim_get_hl(0, { name = inner_name, create = false }) - local name = ('auto' .. outer_name .. inner_name) - vim.api.nvim_get_hl(0, - { name = name, create = true }) - local hi = inner - hi.bg = inner.fg - hi.fg = outer.bg - vim.api.nvim_set_hl(0, name, hi) - return name -end - -function _G.statusline_lsp_diagnostics(bufnr, default_hi) - local error_num = vim.diagnostic.get(bufnr, { severity = vim.diagnostic.severity.ERROR }) - local warn_num = vim.diagnostic.get(bufnr, { severity = vim.diagnostic.severity.WARN }) - - local s = '' - if #error_num > 0 then - local errs = vim.fn.sign_getdefined('DiagnosticSignError')[1].text .. #error_num - s = s - .. statusline_append( - errs, - statusline_combine_hi('StatusLine', 'DiagnosticError'), - default_hi - ) - end - if #warn_num > 0 then - local warns = vim.fn.sign_getdefined('DiagnosticSignWarn')[1].text .. #warn_num - s = s - .. statusline_append( - warns, - statusline_combine_hi('StatusLine', 'DiagnosticWarn'), - default_hi - ) - end - return vim.trim(s) -end - -function _G.statusline_ts() - local navic = package.loaded['nvim-navic'] - if not navic then - return '' - end - local data = navic.get_data() - if not data then - return '' - end - local s = {} - for i = 1, #data do - table.insert( - s, - string.format( - '%%#CmpItemKind%s#%s%%* %%#StatusLine#%s%%*', - data[i].type, - data[i].icon, - data[i].name - ) - ) - end - return table.concat(s, ' > ') -end - -function _G.statusline_grapple(bufnr) - local g = package.loaded.grapple - if not g then return '' end - return g.statusline() - -- if not g or not g.exists({ buffer = bufnr }) then - -- return '' - -- end - -- return '➥ ' .. g.key({ buffer = bufnr }) -end - -function _G.statusline_lspstatus() - local lst = package.loaded['lsp-status'] - if not lst then - return '' - end - return vim.trim(lst.status()) -end - -function _G.statusline_spinner(bufnr) - local sp = package.loaded.spinner - if not sp then - return '' - end - return sp.status(bufnr) -end - -function _G.statusline_dap() - local dap = package.loaded.dap - if not dap then - return '' - end - local s = dap.status() - if s == '' then - return s - end - return '[DAP: ' .. s .. ']' -end - -function _G.statusline_notify(default_hi) - if not _G.statusline_notifications or #_G.statusline_notifications == 0 then - return '' - end - local n = _G.statusline_notifications[1] - local timeout = (n.options and n.options.timeout) or 2000 - -- pop message after and move to archive - vim.defer_fn(function() - local n_ = table.remove(_G.statusline_notifications, 1) - table.insert(_G.statusline_notifications_archive, n_) - -- make sure archive is never longer than 20 notifications - if #_G.statusline_notifications_archive > 20 then - table.remove(_G.statusline_notifications_archive, 1) - end - end, timeout) - - local s = '' - if n.hi then - s = s - .. statusline_append( - n.lvl_string .. ' ', - statusline_combine_hi('StatusLineNotify', n.hi), - default_hi, - { append_space = false } - ) - end - s = s .. statusline_append(vim.inspect(n.message), 'StatusLineNotify', default_hi) - return vim.trim(s) -end - -vim.opt.statusline = '%{%v:lua.statusline()%}' - --- WINBAR -- --- vim.opt.winbar = [[%h%w%q%f %-m %-r %= %#WinBarCwd#%{%getcwd()%}%*]] -- keep it simple --- function _G.winbar() --- return [[%<%F %-m %-r]] --- end --- vim.opt.winbar = '%{%v:lua.winbar()%}' diff --git a/.vim/lua/internal/syncbg.lua b/.vim/lua/internal/syncbg.lua deleted file mode 100644 index 418e17e..0000000 --- a/.vim/lua/internal/syncbg.lua +++ /dev/null @@ -1,46 +0,0 @@ -local M = {} - -M.init = function() - -- get tty - local tty_handle = io.popen('tty') - if tty_handle == nil then return end - local tty = tty_handle:read('*a') - tty_handle:close() - if tty:find("not a tty") then error('not a tty') end - - M.tty = tty -end - -M.update = function() - if M.tty == nil then return end - - if not M.normal then - -- get colorscheme Normal highlight - local normal = vim.api.nvim_get_hl(0, { name = 'Normal', create = false }) - if (normal.bg == nil) then return end - -- cache old value for use with VimResume - M.normal = normal - end - - -- emit CSI to change terminal background to Normal.bg - os.execute('printf "\\033]11;' .. string.format('#%06x', M.normal.bg) .. '\\007" > ' .. M.tty) - - -- set colorscheme Normal.bg to NONE, making it transparent - vim.cmd [[hi Normal ctermbg=NONE guibg=NONE]] -end - -M.reset = function() - if M.tty == nil then return end - - os.execute('printf "\\033]111\\007" > ' .. M.tty) -end - -M.setup = function(opts) - opts = opts or {} - - M.init() - vim.api.nvim_create_autocmd({ 'ColorScheme', 'UIEnter', 'VimResume' }, { callback = M.update }) - vim.api.nvim_create_autocmd({ 'UILeave' }, { callback = M.reset }) -end - -return M diff --git a/.vim/lua/internal/zk.lua b/.vim/lua/internal/zk.lua deleted file mode 100644 index 5e17786..0000000 --- a/.vim/lua/internal/zk.lua +++ /dev/null @@ -1,7 +0,0 @@ --- vim.keymap.set('n', 'zn', function() require('zk').new() end, {buffer=true}) --- vim.keymap.set('n', 'zi', function() require('zk').index() end, {buffer=true}) --- vim.cmd [[ command! -nargs=* ZettelkastenNew lua require('zk').new(nil, ) ]] - -vim.keymap.set('n', 'gt', function() - require('telescope._extensions.todo-comments').exports.todo({ cwd = vim.env.ZK_NOTEBOOK_DIR }) -end, { desc = 'show zk todos', buffer = true }) diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua deleted file mode 100644 index d53eaf6..0000000 --- a/.vim/lua/plugins.lua +++ /dev/null @@ -1,1578 +0,0 @@ --- disable distribution plugins -vim.g.loaded_gzip = 1 -vim.g.loaded_tar = 1 -vim.g.loaded_tarPlugin = 1 -vim.g.loaded_zip = 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_matchit = 1 --- vim.g.loaded_matchparen = 1 -vim.g.loaded_2html_plugin = 1 -vim.g.loaded_logiPat = 1 -vim.g.loaded_rrhelper = 1 -vim.g.loaded_netrw = 1 -vim.g.loaded_netrwPlugin = 1 -vim.g.loaded_netrwSettings = 1 -vim.g.loaded_netrwFileHandlers = 1 - -local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' -if not vim.uv.fs_stat(lazypath) then - vim.fn.system({ - 'git', - 'clone', - '--filter=blob:none', - 'https://github.com/folke/lazy.nvim.git', - '--branch=stable', - lazypath, - }) -end -vim.opt.rtp:prepend(lazypath) - -local pluginspec = { - { - 'lewis6991/gitsigns.nvim', - lazy = false, - opts = { - signs = { - change = { hl = 'GitSignsChange', text = '▋', numhl = 'GitSignsChangeLn' }, - add = { hl = 'GitSignsAdd', text = '▋', numhl = 'GitSignsAddLn' }, - delete = { hl = 'GitSignsDelete', text = '_', numhl = 'GitSignsDeleteLn' }, - topdelete = { hl = 'GitSignsDelete', text = '‾', numhl = 'GitSignsDeleteLn' }, - changedelete = { hl = 'GitSignsChange', text = '~', numhl = 'GitSignsChangeLn' }, - }, - signcolumn = true, - numhl = false, - linehl = false, - word_diff = false, - preview_config = { - border = _G.floating_win_border, - }, - on_attach = function(bufnr) - local gs = require('gitsigns') - vim.keymap.set('n', ']c', function() - if vim.wo.diff then - return ']c' - end - vim.schedule(gs.next_hunk) - return '' - end, { buffer = bufnr, expr = true, desc = 'next hunk' }) - vim.keymap.set('n', '[c', function() - if vim.wo.diff then - return '[c' - end - vim.schedule(gs.prev_hunk) - return '' - end, { buffer = bufnr, expr = true, desc = 'previous hunk' }) - vim.keymap.set('n', 'hb', function() - gs.blame_line({ full = true }) - end, { buffer = bufnr, desc = 'show line blame (full)' }) - vim.keymap.set('n', 'hB', function() - gs.blame_line({ full = false }) - end, { buffer = bufnr, desc = 'show line blame (compact)' }) - vim.keymap.set( - 'n', - 'hp', - gs.preview_hunk, - { buffer = bufnr, desc = 'preview hunk' } - ) - vim.keymap.set('n', 'hd', gs.diffthis, { buffer = bufnr, desc = 'diff this' }) - vim.keymap.set('n', 'hl', function() - gs.setqflist(0, { open = false }) - vim.schedule(function() - require('telescope.builtin').quickfix() - end) - end, { buffer = bufnr, desc = 'list hunks' }) - vim.keymap.set('n', 'gs', vim.cmd.Gitsigns, { - buffer = bufnr, - desc = 'gitsigns', - }) - end, - }, - }, - - { - 'lukas-reineke/indent-blankline.nvim', - lazy = false, - main = 'ibl', - opts = { - indent = { - char = '▏', - highlight = { 'NonText' }, - }, - exclude = { - filetypes = { 'alpha' }, - }, - scope = { - enabled = true, - show_start = false, - show_end = false, - highlight = { 'Comment' }, - }, - }, - keys = { - { - 'ti', - vim.cmd.IBLToggle, - desc = 'toggle indent-blankline', - }, - }, - }, - - { - 'numToStr/Comment.nvim', - opts = { - opleader = { block = 'gC' }, - }, - keys = { - 'gcc', - { 'gc', mode = 'v' }, - { 'gC', mode = 'v' }, - }, - }, - - { - 'windwp/nvim-autopairs', - priority = 40, - event = 'InsertEnter', - config = true, - }, - - { - 'elihunter173/dirbuf.nvim', - enabled = true, - dev = true, - lazy = false, - keys = { - { - '', - function() - local cpath = require('dirbuf').get_cursor_path() - for _, w in ipairs(vim.api.nvim_list_wins()) do - if vim.api.nvim_get_option_value('previewwindow', { win = w }) then - if vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w)) == cpath then - vim.cmd.pclose() - return - end - end - end - require('dirbuf').enter('pedit') - end, - desc = 'Dirbuf: preview file', - }, - }, - }, - { - 'nvim-tree/nvim-tree.lua', - version = '*', - main = 'nvim-tree', - enabled = false, - lazy = false, - dependencies = { 'nvim-tree/nvim-web-devicons' }, - opts = { - renderer = { - icons = { - show = { - file = false, - folder = false, - folder_arrow = true, - git = false, - }, - glyphs = { - default = '󰈤 ', - symlink = '󰌹 ', - bookmark = 'b', - folder = { - arrow_open = '▾', - arrow_closed = '▸', - default = '󰉖 ', - open = '󰷏 ', - empty = '󱞞 ', - symlink = '󰌹 ', - }, - }, - }, - }, - -- on_attach = function(bufnr) - -- end, - }, - keys = { - { - '-', - function() - require('nvim-tree.api').tree.open({ - current_window = true, - path = vim.fn.expand('%:p:h'), - }) - end, - desc = 'NvimTree: open containing directory', - }, - { - 'gt', - function() - require('nvim-tree.api').tree.toggle() - end, - desc = 'NvimTree: toggle', - }, - }, - }, - - { - 'nvim-treesitter/nvim-treesitter', - lazy = false, - build = ':TSUpdateSync', - config = function(_, opts) - local tsconf = require('nvim-treesitter.parsers').get_parser_configs() - tsconf.gotmpl = { - install_info = { - url = 'https://github.com/ngalaiko/tree-sitter-go-template', - files = { 'src/parser.c' }, - }, - filetype = 'gotmpl', - used_by = { 'gotmpl.html', 'gotmpl.yaml', 'gotmpl' }, - } - require('nvim-treesitter.configs').setup(opts) - end, - opts = { - ensure_installed = { - 'bash', - 'bibtex', - 'c', - 'c_sharp', - 'cpp', - 'cmake', - 'comment', - 'css', - 'dockerfile', - 'go', - 'gomod', - 'gowork', - 'hcl', - 'html', - 'java', - 'javascript', - 'json', - 'jsonc', - 'latex', - 'ledger', - 'lua', - 'make', - 'markdown', - 'markdown_inline', - 'ninja', - 'norg', - 'query', - 'regex', - 'rust', - 'scss', - 'toml', - 'typescript', - 'vim', - 'vimdoc', - 'yaml', - 'zig', - 'yuck', -- eww - -- experimental - 'hare', - 'gotmpl', - }, - highlight = { - enable = true, - additional_vim_regex_highlighting = { 'markdown' }, - }, - indent = { - enable = true, - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = 'gnn', - node_incremental = 'grn', - node_decremental = 'grm', - }, - }, - refactor = { - navigation = { - enable = true, - keymaps = { - goto_definition = '', - }, - }, - smart_rename = { - enable = true, - keymaps = { - smart_rename = 'grr', - }, - }, - }, - textobjects = { - select = { - enable = true, - keymaps = { - ['ib'] = '@block.inner', - ['ob'] = '@block.outer', - ['ic'] = '@conditional.inner', - ['oc'] = '@conditional.outer', - ['if'] = '@function.inner', - ['of'] = '@function.outer', - ['il'] = '@loop.inner', - ['ol'] = '@loop.outer', - ['is'] = '@scopename.inner', - ['os'] = '@scopename.outer', - }, - }, - }, - }, - }, - { 'nvim-treesitter/nvim-treesitter-refactor', keys = { '', 'grr' } }, - { - 'nvim-treesitter/nvim-treesitter-textobjects', - keys = { 'ib', 'ob', 'ic', 'oc', 'if', 'of', 'il', 'ol', 'is', 'os' }, - }, - { - 'nvim-treesitter/playground', - cmd = { 'TSPlaygroundToggle', 'TSHighlightCapturesUnderCursor' }, - }, - - { - 'neovim/nvim-lspconfig', - lazy = false, - -- event = 'InsertEnter', - priority = 100, - dependencies = { - { - 'nvim-lua/lsp-status.nvim', - config = function() - local lspstatus = require('lsp-status') - lspstatus.config({ - diagnostics = false, - current_function = false, - status_symbol = '', - }) - lspstatus.register_progress() - end, - }, - }, - config = function() - require('telescope').load_extension('lsp_handlers') - require('internal.lsp').setup() - end, - }, - - { - 'hrsh7th/nvim-cmp', - event = { 'InsertEnter', 'CmdlineEnter' }, - dependencies = { - -- 'hrsh7th/cmp-buffer', - 'hrsh7th/cmp-cmdline', - 'hrsh7th/cmp-path', - 'hrsh7th/cmp-nvim-lua', - 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-nvim-lsp-document-symbol', - 'hrsh7th/cmp-nvim-lsp-signature-help', - 'saadparwaiz1/cmp_luasnip', - 'f3fora/cmp-spell', - }, - config = function() - local cmp = require('cmp') - local luasnip = require('luasnip') - cmp.setup({ - experimental = { - ghost_text = { hl_group = 'NonText' }, - native_menu = false, - }, - -- disable completion in comments - enabled = function() - local ok, enable = pcall(function() - local ctx = require('cmp.config.context') - if vim.api.nvim_get_mode().mode == 'i' then - if ctx.in_treesitter_capture('comment') or ctx.in_syntax_group('Comment') then - return false - end - if vim.opt.filetype:get() == 'TelescopePrompt' then - return false - end - end - return true - end) - return not ok or enable - end, - -- performance = { - -- max_view_entries = 20, - -- }, - preselect = cmp.PreselectMode.Item, - window = { - completion = { - scrollbar = true, - border = 'none', - }, - documentation = { - border = 'solid', - }, - }, - completion = { - autocomplete = false, - }, - sorting = { - comparators = { - cmp.config.compare.offset, - cmp.config.compare.exact, - cmp.config.compare.recently_used, - require("clangd_extensions.cmp_scores"), - cmp.config.compare.kind, - cmp.config.compare.sort_text, - cmp.config.compare.length, - cmp.config.compare.order, - }, - }, - mapping = { - [''] = cmp.mapping.complete({ reason = cmp.ContextReason.Auto }), - [''] = cmp.mapping.complete({ reason = cmp.ContextReason.Auto }), - [''] = cmp.mapping.confirm({ select = true }), - [''] = cmp.mapping.select_next_item({ behavior = require('cmp.types').cmp.SelectBehavior.Select }), - [''] = cmp.mapping.select_prev_item({ behavior = require('cmp.types').cmp.SelectBehavior.Select }), - [''] = cmp.mapping.confirm({ select = true }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - -- NOTE: poor mans replacement for cmp.confirm without expanding snippet - cmp.select_next_item({ behavior = require('cmp.types').cmp.SelectBehavior.Insert }) - cmp.close() - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { 'i', 's' }), - -- map c-j/k for luasnip choice nodes - [''] = cmp.mapping(function(fallback) - if luasnip.choice_active() then - luasnip.change_choice(1) - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if luasnip.choice_active() then - luasnip.change_choice(-1) - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - }, - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) - end, - }, - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'nvim_lsp_signature_help' }, - { name = 'luasnip' }, - { name = 'nvim_lua' }, - }, { - -- { name = 'neorg' }, - -- { name = 'orgmode' }, - { name = 'spell', keyword_length = 3, max_item_count = 5 }, - { name = 'path' }, - -- { name = 'buffer', keyword_length = 3 }, - }), - formatting = { - fields = { 'kind', 'abbr', 'menu' }, - format = function(entry, item) - local menus = { - nvim_lsp = '░ lsp', - luasnip = '░ snip', - nvim_lua = '░ nvim', - -- orgmode = '░ org', - spell = '░ spell', - path = '░ path', - buffer = '░ buf', - } - item.kind = require('internal.lsp_symbols')[item.kind] or '' - item.menu = menus[entry.source.name] - local maxw = vim.api.nvim_win_get_width(0) - 25 - item.abbr = string.sub(item.abbr, 1, (#item.abbr > maxw) and maxw or #item.abbr) - return item - end, - expandable_indicator = true, - }, - }) - cmp.setup.cmdline({ '/', '?', '@' }, { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = 'nvim_lsp_document_symbol' }, - -- { name = 'buffer' } - }), - formatting = { - fields = { 'abbr', 'menu' }, - }, - }) - cmp.setup.cmdline(':', { - mapping = { - [''] = cmp.mapping({ - c = function() - vim.cmd.Telescope('command_history') - end, - }), - [''] = cmp.mapping({ - c = cmp.mapping.select_next_item({ behavior = require('cmp.types').cmp.SelectBehavior.Insert }), - }), - [''] = cmp.mapping({ - c = cmp.mapping.select_prev_item({ behavior = require('cmp.types').cmp.SelectBehavior.Insert }), - }), - }, - sources = cmp.config.sources({ - { name = 'path' }, - }, { - { name = 'cmdline' }, - }), - formatting = { - fields = { 'abbr', 'menu' }, - }, - }) - -- insert `(` after selecting function/method items - cmp.event:on( - 'confirm_done', - require('nvim-autopairs.completion.cmp').on_confirm_done({ - map_char = { tex = '' }, - }) - ) - end, - }, - - { - 'L3MON4D3/LuaSnip', - config = function() - require('internal.snips') - end, - }, - - { - 'nvim-telescope/telescope.nvim', - cmd = 'Telescope', - dependencies = { - 'nvim-lua/popup.nvim', - 'nvim-lua/plenary.nvim', - { - 'nvim-telescope/telescope-fzf-native.nvim', - build = 'make', - config = function() - require('telescope').load_extension('fzf') - end, - }, - { - 'nvim-telescope/telescope-ui-select.nvim', - config = function() - require('telescope').load_extension('ui-select') - end, - }, - 'gbrlsnchs/telescope-lsp-handlers.nvim', - }, - config = function() - require('telescope').setup({ - defaults = { - prompt_prefix = '', - selection_caret = '⯈ ', - sorting_strategy = 'ascending', - preview = false, - results_title = false, - layout_strategy = 'bottom_pane', - layout_config = { - -- preview_cutoff = 1, - -- height = 20, - }, - border = true, - borderchars = { - preview = { '─', '│', '─', '│', '┌', '┐', '┘', '└' }, - prompt = { '─', '', '', '', '╾', '╼', '', '' }, - results = { '' }, - }, - file_previewer = require('telescope.previewers').vim_buffer_cat.new, - grep_previewer = require('telescope.previewers').vim_buffer_vimgrep.new, - qflist_previewer = require('telescope.previewers').vim_buffer_qflist.new, - mappings = { - i = { - [''] = require('telescope.actions.layout').toggle_preview, - }, - n = { - [''] = require('telescope.actions.layout').toggle_preview, - [';'] = function() - vim.cmd.Telescope('resume') - end, - }, - }, - }, - pickers = { - buffers = { - sort_mru = true, - mappings = { - i = { - [""] = require('telescope.actions').delete_buffer, - } - } - } - }, - extensions = { - ['fzf'] = { - fuzzy = true, - override_generic_sorter = true, - override_file_sorter = true, - case_mode = 'smart_case', - }, - ['lsp_handlers'] = { - disable = { - -- ['textDocument/codeAction'] = true, - }, - }, - ['ui-select'] = { - require('telescope.themes').get_cursor({ - initial_mode = 'normal', - previewer = false, - }), - }, - }, - }) - end, - keys = { - { - ';Q', - function() - require('telescope.builtin').quickfix() - end, - desc = 'quickfix', - }, - { - ';C', - function() - require('telescope.builtin').loclist() - end, - desc = 'loclist', - }, - { - ';H', - function() - require('telescope.builtin').help_tags() - end, - desc = 'help_tags', - }, - { - ';b', - function() - require('telescope.builtin').buffers() - end, - desc = 'buffer', - }, - { - ';c', - function() - require('telescope.builtin').commands() - end, - desc = 'commands', - }, - { - ';f', - function() - require('telescope.builtin').fd() - end, - desc = 'fd', - }, - { - ';g', - function() - require('telescope.builtin').live_grep() - end, - desc = 'grep', - }, - { - ';h', - function() - require('telescope.builtin').command_history() - end, - desc = 'command history', - }, - { - ';bf', - function() - require('telescope.builtin').current_buffer_fuzzy_find() - end, - desc = 'buffer', - }, - { - ';o', - function() - require('telescope.builtin').oldfiles() - end, - desc = 'oldfiles', - }, - { - ';d', - function() - require('telescope.builtin').diagnostics() - end, - desc = 'diagnostics', - }, - { - ';j', - function() - require('telescope.builtin').jumplist() - end, - desc = 'jumplist', - }, - { - ';v', - function() - require('telescope.builtin').find_files({ - prompt_title = 'vimrc', - previewer = false, - search_dirs = { - vim.fn.stdpath('config'), - vim.fn.stdpath('data') .. '/lazy', - } - }) - end, - desc = 'vim config', - }, - { - 'gw', - function() - require('internal.cursor').word(function(s) - require('telescope.builtin').grep_string({ search = s }) - end) - end, - desc = 'grep for word under cursor', - }, - }, - }, - - { - 'norcalli/nvim-colorizer.lua', - lazy = false, - config = function() - require('colorizer').setup(nil, { - name = true, - RRGGBB = true, - RRGGBBAA = false, - rgb_fn = true, - hsl_fn = true, - mode = 'background', - }) - end, - build = [[git cherry-pick patch]], - }, - - { 'gentoo/gentoo-syntax', lazy = false }, - - { - 'NMAC427/guess-indent.nvim', - lazy = false, - opts = { - auto_cmd = true, - filetype_exclude = { 'netrw', 'tutor', 'dirbuf', 'nvimtree' }, - buftype_exclude = { 'help', 'nofile', 'terminal', 'prompt' }, - }, - }, - - { - 'echasnovski/mini.align', - version = false, - opts = {}, - keys = { 'ga', 'gA' } - }, - - { - url = 'https://git.sr.ht/~robertgzr/spinner.nvim', - opts = { - spinner = { '⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏' }, - interval = 120, -- spinner frame rate in ms - }, - }, - - { - 'stevearc/aerial.nvim', - cmd = { 'AerialOpen', 'AerialToggle' }, - keys = { { '', vim.cmd.AerialToggle, desc = 'Toggle aerial' } }, - opts = { - backends = { 'lsp', 'treesitter', 'markdown' }, - filter_kind = { - -- default: - 'Class', - 'Constructor', - 'Enum', - 'Function', - 'Interface', - 'Module', - 'Method', - 'Struct', - -- custom: - 'Constant', - 'Variable', - }, - icons = require('internal.lsp_symbols'), - close_automatic_events = { 'unsupported' }, - placement = 'edge', - open_automatic = false, - -- open_automatic = function(bufnr) - -- return vim.api.nvim_buf_line_count(bufnr) > 200 - -- and package.loaded.aerial.num_symbols(bufnr) > 4 - -- and not package.loaded.aerial.was_closed() - -- end, - default_keybinds = false, - show_guides = true, - }, - }, - - { - 'SmiteshP/nvim-navic', - opts = { - icons = require('internal.lsp_symbols'), - }, - }, - - -- {'kosayoda/nvim-lightbulb', - -- config = { - -- ignore = {'null-ls'}, - -- sign = { enabled = false }, - -- virtual_text = { enabled = false, text = '← 󰌵' }, - -- status_text = { enabled = true, text = '󰌵', text_unavailable = '' }, - -- autocmd = { enabled = true }, - -- }, - -- init = function() - -- vim.fn.sign_define({{name='LightBulbSign', text='󰌵', texthl='LightBulbSign'}}) - -- end, - -- }, - - { - 'weilbith/nvim-code-action-menu', - event = 'VeryLazy', - config = function() - vim.lsp.handlers['textDocument/codeAction'] = - require('code_action_menu').open_code_action_menu - end, - }, - - { - 'jose-elias-alvarez/null-ls.nvim', - enabled = false, - ft = { - 'sh', - 'bash', - 'lua', - 'rust', - 'c', - 'cpp', - 'css', - 'scss', - 'html', - 'javascript', - 'markdown', - }, - dependencies = { 'nvim-lua/plenary.nvim' }, - config = function() - local nls = require('null-ls') - local nls_h = require('null-ls.helpers') - - local beautifier = nls_h.make_builtin({ - name = 'beautifier', - method = nls.methods.FORMATTING, - generator_opts = { - args = { '--file', '-', '--editorconfig' }, - to_stdin = true, - }, - env = { - ['PATH'] = (vim.env.HOME .. '/.yarn/bin') .. ':' .. vim.env.PATH, - }, - factory = nls_h.formatter_factory, - }) - - nls.setup({ - debug = true, - on_attach = require('internal.lsp').my_attach, - sources = { - nls.builtins.diagnostics.shellcheck, - nls.builtins.formatting.shfmt, - -- nls.builtins.formatting.yapf, -- python - nls.builtins.formatting.clang_format, - nls.builtins.formatting.rustfmt, - nls.builtins.formatting.stylua, - -- nls.builtins.formatting.gofumpt, - -- nls.builtins.formatting.json_tool, - -- nls.builtins.formatting.mdformat, - - -- custom sources - beautifier.with({ filetypes = { 'html', 'gotmpl.html' }, command = 'html-beautify' }), - beautifier.with({ filetypes = { 'css', 'scss' }, command = 'css-beautify' }), - beautifier.with({ filetypes = { 'javascript' }, command = 'js-beautify' }), - }, - }) - end, - }, - - { - 'mfussenegger/nvim-dap', - dependencies = { - 'nvim-telescope/telescope-dap.nvim', - 'rcarriga/nvim-dap-ui', - }, - config = function() - require('telescope').load_extension('dap') - require('internal.dap') - end, - keys = { - 'd', - }, - }, - { 'farmergreg/vim-lastplace', event = 'VeryLazy' }, -- restore last cursor position (and handle many edge cases) - { 'tpope/vim-surround', event = 'VeryLazy' }, - { 'tpope/vim-repeat', event = 'VeryLazy' }, -- extend '.' to plugins - { 'michaeljsmith/vim-indent-object', event = 'VeryLazy' }, -- indentation text-objects - -- {'kshenoy/vim-signature'}, -- toggle, display and navigate marks - -- {'rhysd/conflict-marker.vim'}, - -- {'kassio/neoterm'}, - - { - 'kristijanhusak/orgmode.nvim', - ft = 'org', - build = function() - require('orgmode').setup_ts_grammar() - vim.cmd.TSUpdate() - end, - opts = { - org_agenda_files = { vim.env.HOME .. '/documents/org/*.org' }, - org_default_notes_file = vim.env.HOME .. '/documents/org/todo.org', - org_todo_keywords = { 'TODO', 'DONE' }, - -- org_indent_mode = 'noindent', - org_agenda_templates = { - t = { - description = 'Todo', - template = '* TODO %?', - }, - n = { - description = 'Note', - template = '* %?', - target = vim.env.HOME .. '/documents/org/notes.org', - }, - }, - mappings = { - agenda = { - org_agenda_close = nil, - }, - }, - }, - -- keys = { - -- { mode = 's', ';O', function() - -- local pickers = require('telescope.pickers') - -- local finders = require('telescope.finders') - -- pickers.new(opts, { - -- prompt_title = 'Orgmode', - -- finder = finders.new_table(require('orgmode.config'):get_all_files()), - -- }):find() - -- end }, - -- }, - }, - - { - 'nvim-neorg/neorg', - enabled = false, - ft = 'norg', - cmd = { 'Neorg' }, - build = ':Neorg sync-parsers', - dependencies = { - 'nvim-lua/plenary.nvim', - 'nvim-neorg/neorg-telescope', - 'nvim-treesitter/nvim-treesitter', - }, - init = function() - -- vim.cmd [[autocmd BufRead,BufNewFile *.norg setlocal filetype=norg]], - end, - opts = { - load = { - ['core.defaults'] = {}, - ['core.keybinds'] = { - config = { default_keybinds = true }, - }, - ['core.norg.concealer'] = { - config = { icons = { todo = { enabled = true } } }, - }, - ['core.norg.dirman'] = { - config = { - workspaces = { - default = '$HOME/documents/neorg/default', - work = '$HOME/documents/neorg/work', - gtd = '$HOME/documents/neorg/gtd', - }, - }, - }, - ['core.norg.completion'] = { - config = { engine = 'nvim-cmp' }, - }, - ['core.integrations.telescope'] = {}, - ['core.norg.qol.todo_items'] = {}, - ['core.presenter'] = {}, - ['core.gtd.base'] = { - config = { workspace = 'gtd' }, - }, - }, - }, - }, - - { - 'zk-org/zk-nvim', - cmd = { 'ZkNew', 'ZkNotes' }, - ft = { 'markdown', 'neorg' }, - config = function() - require('telescope').load_extension('zk') - require('zk').setup({ - picker = 'telescope', - lsp = { - config = { - cmd = { 'zk', 'lsp', '--log', '/tmp/zk-lsp.log' }, - on_attach = require('internal.lsp').my_attach, - on_exit = require('internal.lsp').my_exit, - capabilities = require('internal.lsp').capabilities(), - }, - auto_attach = { - enabled = true, - filetypes = { 'markdown' }, - }, - }, - }) - end, - keys = { - { - ';zn', - vim.cmd.ZkNotes, - desc = 'zk notes', - }, - { - ';zb', - vim.cmd.ZkBacklinks, - desc = 'zk backlinks', - }, - { - ';zt', - vim.cmd.ZkTags, - desc = 'zk tags', - }, - { - ';zl', - vim.cmd.ZkLinks, - desc = 'zk links', - }, - { - ';zN', - function() - - end, - desc = 'zk new note', - }, - }, - }, - - -- {'rhysd/vim-grammarous', - -- ft = {'markdown', 'latex', 'tex'} - -- }, - - { - 'lervag/vimtex', - enabled = false, - ft = { 'latex', 'tex' }, - config = function() - local g = vim.g - g.tex_flavor = 'latex' - g.vimtex_compiler_enabled = 0 - g.vimtex_compiler_method = 'tectonic' - g.vimtex_compiler_tectonic = "{'executable': 'tectonic'}" - g.vimtex_view_method = 'zathura' - end, - }, - - { - 'preservim/vim-markdown', - ft = 'markdown', - enabled = true, - config = function() - vim.g.vim_markdown_frontmatter = 0 -- handled by tre-sitter - vim.g.vim_markdown_strikethrough = 1 - vim.g.vim_markdown_conceal_code_blocks = 0 -- doesn't work due to tree-sitter: https://github.com/nvim-treesitter/nvim-treesitter/issues/2825 - vim.g.vim_markdown_no_default_key_mappings = 1 - end, - }, - - { - 'https://git.sr.ht/~p00f/clangd_extensions.nvim', - }, - - { - 'folke/zen-mode.nvim', - dependencies = { - { - 'folke/twilight.nvim', - opts = { - context = 15, - dimming = { - alpha = 0.3, - color = { 'Normal', '#ffffff' }, - }, - }, - }, - }, - cmd = { 'ZenMode' }, - opts = { - window = { - -- backdrop = 1, - -- width = 0.3, - -- height = 1, - options = { - number = false, - list = false, - }, - }, - plugins = { - options = { - enabled = true, - ruler = false, - showcmd = false, - }, - twilight = { enabled = true }, - gitsigns = { enabled = false }, - }, - }, - }, - - { - 'folke/which-key.nvim', - event = 'VeryLazy', - opts = { - icons = { separator = '→ ', group = '🞱 ' }, - triggers = { '', '', ';', 'g', '[', ']' }, - }, - }, - - { - 'goolord/alpha-nvim', - enabled = false, - cmd = 'Alpha', - config = function() - local MAX_WIDTH = 80 - local alpha = require('alpha') - local them = require('alpha.themes.theta') - local button = function(...) - local b = require('alpha.themes.dashboard').button(...) - b.opts = vim.tbl_extend('force', b.opts, { - hl = 'Normal', - width = MAX_WIDTH, - }) - return b - end - local fit_path = function(path, max_width) - local Path = require('plenary.path') - path = vim.fn.fnamemodify(path, ':.') - if vim.fn.strdisplaywidth(path) > max_width then - path = Path.new(path):shorten(1, { -2, -1 }) - end - if vim.fn.strdisplaywidth(path) > max_width then - path = '_ ' .. path:sub((vim.fn.strdisplaywidth(path) - max_width), -1) - end - return path - end - local hr = function(margin, max_width, label, opts) - max_width = max_width - (2 * margin) - label = label and (' ' .. label .. ' ') or '' - opts = vim.tbl_extend('force', opts or {}, { position = 'center', hl = 'Comment' }) - return { - type = 'text', - opts = opts, - val = function() - local label_len = vim.fn.strdisplaywidth(label) - -- exit here if we're not showing a label - if label_len == 0 then - return string.rep(' ', margin) - .. string.rep('─', max_width) - .. string.rep(' ', margin) - end - if label_len > max_width then - return error('overfull box: ' .. label) - end - max_width = max_width - label_len - return string.rep(' ', margin) - .. string.rep('─', max_width / 2) - .. label - .. string.rep('─', max_width / 2) - .. string.rep(' ', margin) - end, - } - end - local fortune = function(margin, max_width) - max_width = max_width - (margin * 2) - -- local Job = require('plenary.job') - -- local ok, j = pcall(Job.new, Job, { - -- command = 'sh', - -- args = {'-c', 'fortune ' .. vim.env.HOME..'/devel/projects/zig/fortune/fortunes' .. ' | fmt -w ' .. max_width}, - -- enable_recording = true, - -- }) - -- if not ok then return {} end - -- local lines, exit_code = j:sync() - -- if not exit_code == 0 then return {} end - -- local val = {} - -- for i = 1, #lines do - -- if vim.fn.strdisplaywidth(lines[i]) > max_width then - -- return error('overful box: ' .. lines[i]) - -- end - -- table.insert(val, - -- (string.rep(' ', margin) .. lines[i] .. string.rep(' ', margin))) - -- end - -- if vim.trim(val[#val]) == '' then table.remove(val, #val) end - return { - type = 'text', - val = 'noop', - opts = { - position = 'center', - hl = 'AlphaFortune', - }, - } - end - local mru = function(max_width) - return { - type = 'group', - val = function() - local items = {} - - -- initialize the oldfiles table - local oldfiles = {} - local cwd = vim.uv.cwd() - for _, v in pairs(vim.v.oldfiles) do - if #oldfiles == 10 then - break - end - if vim.startswith(v, cwd) and (vim.fn.filereadable(v) == 1) then - table.insert(oldfiles, v) - end - end - -- exit early if there's nothing to show - if not oldfiles or #oldfiles == 0 then - return {} - end - - table.insert(items, hr(0, max_width, 'MRU: ' .. fit_path(cwd, max_width))) - table.insert(items, { type = 'padding', val = 1 }) - for i, fn in pairs(oldfiles) do - table.insert( - items, - button( - tostring(i - 1), -- keybind is - fit_path(fn, max_width), - ':edit ' .. fn .. ' ' - ) - ) - end - return items - end, - opts = { - position = 'center', - }, - } - end - local buffers = function(max_width) - return { - type = 'group', - val = function() - local items = {} - - -- get listed buffers - local bufnrs = vim.tbl_filter(function(bufnr) - if 1 ~= vim.fn.buflisted(bufnr) then - return false - end - return true - end, vim.api.nvim_list_bufs()) - - --sort by last_used - table.sort(bufnrs, function(a, b) - return vim.fn.getbufinfo(a)[1].lastused > vim.fn.getbufinfo(b)[1].lastused - end) - - -- exit early if there's nothing to show - if not bufnrs or #bufnrs == 0 then - return {} - end - - table.insert(items, { type = 'padding', val = 1 }) - table.insert(items, hr(0, max_width, 'Buffers')) - table.insert(items, { type = 'padding', val = 1 }) - - for _, bufnr in ipairs(bufnrs) do - local bufpath = - require('plenary.path').new(vim.fn.getbufinfo(bufnr)[1].name):shorten(1, { -2, -1 }) - table.insert(items, button('b' .. bufnr, bufpath, ':b' .. bufnr .. '')) - end - return items - end, - opts = { - position = 'center', - }, - } - end - them.config.layout = { - { type = 'padding', val = 2 }, - require('alpha.themes.dashboard').section.header, - { type = 'padding', val = 1 }, - fortune(5, MAX_WIDTH), - { type = 'padding', val = 1 }, - hr(0, MAX_WIDTH), - { type = 'padding', val = 1 }, - { - type = 'group', - val = { - button('e', '󰈔 new', [[ene startinsert]]), - button('r', '󰈸 live grep', [[lua require('internal.misc').live_grep()]]), - button('f', '󰝰 find files', [[lua require('internal.misc').find_files()]]), - button('m', '󰥔 mru', [[lua require('telescope.builtin').oldfiles()]]), - button( - 'o', - '󰃶 orgmode', - [[lua require('orgmode').action('agenda.prompt')]] - ), - button( - 't', - '󰃶 todos', - [[lua require('telescope._extensions.todo-comments').exports.todo {cwd=vim.env.ZK_NOTEBOOK_DIR}]] - ), - button('u', '󰚰 update plugins', [[lua require('lazy').update()]]), - button( - 'v', - '󰂓 edit config', - [[lua require('telescope.builtin').find_files {search_dirs={vim.env.HOME..'/.vim/'}}]] - ), - }, - }, - { type = 'padding', val = 1 }, - mru(MAX_WIDTH), - buffers(MAX_WIDTH), - } - alpha.setup(them.config) - end, - keys = { - { 'a', vim.cmd.Alpha, desc = 'alpha' }, - }, - }, - - { - 'linrongbin16/gitlinker.nvim', - cmd = { 'GitLink' }, - dependencies = { 'nvim-lua/plenary.nvim' }, - opts = { - message = true, - }, - keys = { - { - 'gl', - vim.cmd.GitLink, - desc = 'gitlinker -> clipboard', - }, - }, - }, - - { - 'rhysd/git-messenger.vim', - cmd = { 'GitMessenger' }, - config = function() - -- vim.g.git_messenger_include_diff = false - vim.g.git_messenger_always_into_popup = true - vim.g.git_messenger_close_on_cursor_moved = true - vim.g.git_messenger_no_default_mappings = true - end, - keys = { - { 'gb', vim.cmd.GitMessenger, desc = 'blame (git-messenger)' }, - }, - }, - - { - 'folke/todo-comments.nvim', - lazy = false, - cmd = { 'TodoTelescope' }, - config = { - keywords = { - FIX = { icon = '󰃤' }, - TODO = { icon = '󰸞' }, - HACK = { icon = '󰈸' }, - WARN = { icon = '󱇎' }, - PERF = { icon = '󰅒' }, - NOTE = { icon = '󰐃' }, - TEST = { icon = '󰂓' }, - }, - search = { - pattern = [[\b(KEYWORDS)(|\(.+\)):]], - }, - highlight = { - keyword = "bg", - pattern = [[(KEYWORDS)]], - } - }, - keys = { - { ';t', vim.cmd.TodoTelescope, desc = 'todo-comments' }, - { "]t", function() require("todo-comments").jump_next() end, desc = "Next todo comment" }, - { "[t", function() require("todo-comments").jump_prev() end, desc = "Previous todo comment" }, - }, - }, - - { - 'cbochs/grapple.nvim', - dependencies = { 'nvim-lua/plenary.nvim' }, - cmd = { 'GrapplePopup' }, - opts = { - icons = false, - popup_options = { - border = 'none', - }, - }, - keys = { - { - 'ml', - function() - require('grapple').toggle_tags() - end, - desc = 'grapple: show tags', - }, - { - 'ms', - function() - require('grapple').popup_scopes() - end, - desc = 'grapple: show scopes', - }, - { - 'mm', - function() - require('grapple').toggle() - end, - desc = 'grapple: anonymous tag', - }, - { - 'mn', - function() - require('grapple').cycle_forward() - end, - desc = 'grapple: next tag', - }, - { - 'mp', - function() - require('grapple').cycle_backward() - end, - desc = 'grapple: prev tag', - }, - }, - }, - - { - 'tjdevries/sg.nvim', - enabled = false, - lazy = false, - build = 'cargo build --workspace', - dependencies = { 'nvim-lua/plenary.nvim' }, - config = function() - require('sg').setup({ - on_attach = require('internal.lsp').my_attach, - }) - end, - keys = { - { - 's', - function() - require('sg.telescope').fuzzy_search_results() - end, - desc = 'sg.nvim: fuzzy search results', - }, - }, - }, - - { - url = 'https://git.sr.ht/~robertgzr/karafuru', - dev = true, - lazy = false, - enabled = false, - priority = 1000, - cond = (vim.opt.background:get() == 'dark'), - config = function(plugin) - vim.opt.rtp:append(plugin.dir .. '/vim') - vim.cmd.colorscheme('karafuru') - end, - }, - - { - 'yorik1984/newpaper.nvim', - lazy = false, - enabled = false, - priority = 1000, - cond = (vim.opt.background:get() == 'light'), - config = function() - vim.cmd.colorscheme('newpaper') - end, - }, - - { - 'nyoom-engineering/oxocarbon.nvim', - lazy = false, - enabled = false, - priority = 1000, - cond = (vim.opt.background:get() == 'dark'), - config = function() - vim.opt.background = 'dark' - vim.cmd.colorscheme('oxocarbon') - end, - }, - - { - 'mcchrish/zenbones.nvim', - dependencies = { 'rktjmp/lush.nvim' }, - lazy = false, - enabled = false, - priority = 1000, - config = function() - vim.opt.termguicolors = true - local scheme = 'tokyobones' - vim.g[scheme] = { - lighten_non_text = 20, - transparent_background = (vim.opt.background:get() == 'dark'), - } - vim.cmd.colorscheme(scheme) - end, - }, - - -- quarantine - { - 'zbirenbaum/copilot.lua', - enabled = false, - cmd = { 'Copilot' }, - opts = { - panel = { auto_refresh = true }, - suggestion = { auto_trigger = true }, - }, - }, - { - 'Kicamon/markdown-table-mode.nvim', - enabled = true, - ft = { 'markdown' }, - }, -} - -require('lazy').setup(pluginspec, { - defaults = { lazy = true }, - dev = { path = '~/src' }, -}) diff --git a/.vim/lua/telescope/_extensions/jobs.lua b/.vim/lua/telescope/_extensions/jobs.lua deleted file mode 100644 index be55a47..0000000 --- a/.vim/lua/telescope/_extensions/jobs.lua +++ /dev/null @@ -1,84 +0,0 @@ -local job = require('internal.job') - -local pickers = require('telescope.pickers') -local finders = require('telescope.finders') -local conf = require('telescope.config').values -local actions = require('telescope.actions') -local action_state = require('telescope.actions.state') -local entry_display = require('telescope.pickers.entry_display') - -local function job_entry_maker(_) - return function(j) - local displayer = entry_display.create({ - separator = ' ', - items = { - { width = 8 }, - { remaining = true }, - }, - }) - local make_display = function(e) - return displayer({ - { e.value.pid, 'TelescopeResultsNumber' }, - (e.value.command .. ' ' .. table.concat(e.value.args, ' ')), - }) - end - return { - value = j, - display = make_display, - ordinal = tostring(j.pid), - } - end -end - -local function list_jobs(opts) - local jobs = {} - for _, j in pairs(job.current_jobs) do - table.insert(jobs, j) - end - if #jobs == 0 then - vim.notify('no jobs') - return - end - - opts = vim.tbl_extend('force', { prompt_title = 'Jobs' }, opts or {}) - pickers - .new(opts, { - finder = finders.new_table({ - results = jobs, - entry_maker = job_entry_maker(opts), - }), - sorter = conf.generic_sorter(opts), - attach_mappings = function(prompt_bufnr, _) - actions.select_default:replace(function() - local entry = action_state.get_selected_entry() - if not entry then - return - end - actions.close(prompt_bufnr) - vim.ui.select( - { 'Terminate', 'Kill', 'Show', 'Cancel' }, - { prompt = 'Select an action:' }, - function(choice) - if choice == 'Cancel' then - return - elseif choice == 'Show' then - vim.fn.getqflist({ id = entry.value.pid }) - elseif choice == 'Kill' then - entry.value.handle:kill('sigkill') - elseif choice == 'Terminate' then - entry.value.handle:kill('sigterm') - end - end - ) - end) - return true - end, - }) - :find() -end - -return require('telescope').register_extension({ - exports = { - jobs = list_jobs, - }, -}) diff --git a/.vim/plugin/_globals.lua b/.vim/plugin/_globals.lua new file mode 100644 index 0000000..5bf99a4 --- /dev/null +++ b/.vim/plugin/_globals.lua @@ -0,0 +1,3 @@ +_G.feedkeys = function(keys) + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(keys, true, false, true), 'n', true) +end diff --git a/.vim/plugin/auto.lua b/.vim/plugin/auto.lua new file mode 100644 index 0000000..ab4e159 --- /dev/null +++ b/.vim/plugin/auto.lua @@ -0,0 +1,38 @@ +local augroup = vim.api.nvim_create_augroup +local autocmd = vim.api.nvim_create_autocmd + +do + local group = augroup('EasyQuit', { clear = true }) + autocmd('FileType', { + pattern = { + 'help', + 'qf', + 'dap-float', + 'gitsigns-blame', + 'git', + }, + callback = function() + vim.keymap.set('n', 'q', 'close', { silent = true, buffer = 0 }) + end, + group = group, + }) + autocmd('FileType', { + pattern = { 'gitgraph' }, + callback = function() + vim.keymap.set('n', 'q', 'bdel!', { silent = true, buffer = 0 }) + end, + group = group, + }) + autocmd('FileType', { + pattern = { 'DiffviewFiles' }, + callback = function() + vim.keymap.set('n', 'q', 'tabclose', { silent = true, buffer = 0 }) + end, + group = group, + }) + autocmd('TermClose', { + pattern = { 'term://*' }, + command = [[ if !v:event.status | exe 'bdelete! '..expand('') | endif ]], + group = group, + }) +end diff --git a/.vim/plugin/colorscheme.lua b/.vim/plugin/colorscheme.lua new file mode 100644 index 0000000..240737e --- /dev/null +++ b/.vim/plugin/colorscheme.lua @@ -0,0 +1,23 @@ +vim.opt.background = 'dark' + +-- setup color-scheme detection via desktop portal apis +vim.api.nvim_create_autocmd('UIEnter', { + once = true, + callback = function() + local job = require('plenary.job'):new({ + command = 'porta', + args = { 'settings', 'org.freedesktop.appearance', 'color-scheme' }, + enable_recording = true, + }) + local res, exitcode = job:sync() + if exitcode == 0 and #res == 1 then + if res[1] == 'prefer-light' then + vim.opt.background = 'light' + else + vim.opt.background = 'dark' + end + end + end, +}) + +vim.api.nvim_set_hl(0, 'ColorColumn', { link = 'CursorColumn', force = true }) diff --git a/.vim/plugin/diagnostics.lua b/.vim/plugin/diagnostics.lua new file mode 100644 index 0000000..70deec3 --- /dev/null +++ b/.vim/plugin/diagnostics.lua @@ -0,0 +1,59 @@ +vim.diagnostic.config({ + signs = { + text = { + [vim.diagnostic.severity.ERROR] = '✗', + [vim.diagnostic.severity.WARN] = '▷', + [vim.diagnostic.severity.INFO] = 'ℹ', + [vim.diagnostic.severity.HINT] = '🞶', + }, + linehl = { + [vim.diagnostic.severity.ERROR] = 'Search', + -- [vim.diagnostic.severity.WARN] = '', + -- [vim.diagnostic.severity.INFO] = '', + -- [vim.diagnostic.severity.HINT] = '', + }, + numhl = { + [vim.diagnostic.severity.ERROR] = 'DiagnosticSignError', + [vim.diagnostic.severity.WARN] = 'DiagnosticSignWarn', + [vim.diagnostic.severity.INFO] = 'DiagnosticSignInfo', + [vim.diagnostic.severity.HINT] = 'DiagnosticSignHint', + }, + }, + underline = { + severity = { min = vim.diagnostic.severity.HINT }, + }, + float = { + severity = { min = vim.diagnostic.severity.HINT }, + }, + virtual_text = { + severity = { min = vim.diagnostic.severity.HINT }, + }, + severity_sort = true, +}) + +local commonhl = { undercurl = true, force = true } +vim.api.nvim_set_hl(0, 'DiagnosticUnderlineError', commonhl) +vim.api.nvim_set_hl(0, 'DiagnosticUnderlineWarn', commonhl) +vim.api.nvim_set_hl(0, 'DiagnosticUnderlineInfo', commonhl) +vim.api.nvim_set_hl(0, 'DiagnosticUnderlineHint', commonhl) + +vim.keymap.set('n', '[d', function() + vim.diagnostic.goto_next() +end, { desc = 'diagnostic: next' }) +vim.keymap.set('n', ']d', function() + vim.diagnostic.goto_prev() +end, { desc = 'diagnostic: prev' }) +vim.keymap.set('n', 'DD', vim.diagnostic.open_float, { desc = 'diagnostic: current line' }) +vim.keymap.set('n', 'td', function() + if not _G.diagnostic_hidden then + -- vim.diagnostic.hide(nil, 0) + vim.diagnostic.config({ virtual_text = false }) + else + -- vim.diagnostic.show(nil, 0) + vim.diagnostic.config({ virtual_text = true }) + end + _G.diagnostic_hidden = not _G.diagnostic_hidden +end, { desc = 'diagnostic: toggle' }) +vim.keymap.set('n', 'tD', function() + vim.diagnostic.enable(not vim.diagnostic.is_enabled()) +end, { desc = 'diagnostic: toggle' }) diff --git a/.vim/plugin/hardmode.lua b/.vim/plugin/hardmode.lua new file mode 100644 index 0000000..f18a5ef --- /dev/null +++ b/.vim/plugin/hardmode.lua @@ -0,0 +1,10 @@ +-- hard mode means we're not using the arrow keys! + +local bail = function() + vim.cmd([[silent! echohl ErrorMsg | echo "HARD MODE: hjkl operation only" | echohl None]]) +end + +vim.keymap.set({ 'v', 'i' }, '', bail) +vim.keymap.set({ 'v', 'i' }, '', bail) +vim.keymap.set({ 'v', 'i' }, '', bail) +vim.keymap.set({ 'v', 'i' }, '', bail) diff --git a/.vim/plugin/keymaps.lua b/.vim/plugin/keymaps.lua new file mode 100644 index 0000000..c48b1d7 --- /dev/null +++ b/.vim/plugin/keymaps.lua @@ -0,0 +1,29 @@ +local set = vim.keymap.set + +set('n', 'gb', 'bnext', { desc = 'Next buffer' }) +set('n', 'gB', 'bprevious', { desc = 'Prev buffer' }) + +set('n', ';yp', function() + local payload = (vim.fn.expand('%:p') .. ':' .. vim.fn.line('.')) + vim.fn.setreg('+', payload) + vim.notify(payload) +end, { desc = 'Yank current buffer path and line number' }) +set('n', ';yP', function() + local payload = vim.fn.expand('%:p') + vim.fn.setreg('+', payload) + vim.notify(payload) +end, { desc = 'Yank current buffer path' }) +set('n', ';yn', function() + local payload = vim.fs.basename(vim.fn.expand('%:p')) + vim.fn.setreg('+', payload) + vim.notify(payload) +end, { desc = 'Yank current buffer name' }) + +set('t', '', [[ ]], { desc = 'Terminal: Exit INSERT mode' }) + +set('v', '<', '', '>gv', { desc = 'outdent' }) + +set('n', '', 'nohlsearch', { desc = 'Clear search highlights' }) +set('n', '', 'normal! za', { desc = 'Toggle fold under cursor' }) +set('n', '', 'normal! zA', { desc = 'Toggle fold under cursor (recursive)' }) diff --git a/.vim/plugin/options.lua b/.vim/plugin/options.lua new file mode 100644 index 0000000..a25a646 --- /dev/null +++ b/.vim/plugin/options.lua @@ -0,0 +1,27 @@ +local opt = vim.opt + +opt.number = true +opt.cursorline = true + +-- connect system clipboard +opt.clipboard:prepend({ 'unnamedplus' }) + +-- preview supported ops in split buffer +opt.inccommand = 'split' + +-- show whitespace indicators +opt.listchars:append({ trail = '¬', tab = '> ' }) +opt.showbreak = '↪ ' + +-- show indicator and wrap text at 80 chars +opt.colorcolumn = '+1' +opt.textwidth = 79 +opt.wrap = true + +opt.conceallevel = 2 +opt.concealcursor = nil + +-- use treesitter to determine folds +opt.foldmethod = 'expr' +opt.foldexpr = 'v:lua.vim.treesitter.foldexpr()' +opt.foldlevel = 99 diff --git a/.vim/plugin/statuscolumn.lua b/.vim/plugin/statuscolumn.lua new file mode 100644 index 0000000..06e8988 --- /dev/null +++ b/.vim/plugin/statuscolumn.lua @@ -0,0 +1,11 @@ +function _G.statuscolumn() + local sc = '' + + sc = sc .. [[%l%r%s%C]] + + sc = sc .. '│' + + return sc +end + +-- vim.opt.statuscolumn = '%{%v:lua.statuscolumn()%}' diff --git a/.vim/plugin/statusline.lua b/.vim/plugin/statusline.lua new file mode 100644 index 0000000..fed6d33 --- /dev/null +++ b/.vim/plugin/statusline.lua @@ -0,0 +1,152 @@ +function _G.statusline() + local bufnr = vim.fn.bufnr() or 0 + local hi = statusline_color(vim.fn.mode()) + + local sl = hi + -- sl = sl .. statusline_append([[ ⢷]], 'StatusLineIcon', hi) + + sl = sl .. [[%-h%-w%-q%-f %-m%-r]] + + sl = sl .. statusline_append(statusline_git(bufnr, hi), 'StatusLineGit', hi) + + sl = sl .. statusline_append(statusline_grapple(bufnr, hi), 'StatusLineGrapple', hi) + + sl = sl .. [[ %= ]] -- spacer + + sl = sl .. statusline_append(statusline_lsp_diagnostics(bufnr, hi), 'StatusLineDiagnostics', hi) + + sl = sl .. statusline_append(statusline_dap(bufnr, hi), 'StatusLineDap', hi) + + -- sl = sl .. [[ %= ]] -- spacer + + sl = sl .. statusline_append(statusline_spinner(bufnr, hi), 'StatusLineJobs', hi) + + sl = sl .. [[%-l:%-v --%p%%-- %-Y]] + + return sl +end + +function _G.statusline_color(mode) + local hi = '%*' + if mode == 'i' then + -- hi = '%#StatusLineInsert#' + elseif mode == 'c' then + -- hi = '%#StatusLineCommand#' + elseif mode == 'v' or mode == 'V' or mode == '' then + hi = '%#StatusLineVisual#' + elseif mode == 'R' or mode == 'Rv' then + hi = '%#StatusLineReplace#' + end + -- return '%{g:actual_curwin==win_getid()?'.. hi ..':%#StatusLineNC#}' + return hi +end + +-- does item highlighting and conditionnal spacing +function _G.statusline_append(element, hi, default_hi, opts) + if not element or element == '' then + return '' + end + opts = opts or { append_space = true } + + if hi ~= nil then + hi = '%#' .. hi .. '#' + end + if not (default_hi == '%*') then + hi = default_hi + end + local el = hi .. element .. default_hi + if opts.append_space then + el = el .. ' ' + end + return el +end + +function _G.statusline_combine_hi(outer_name, inner_name) + local outer = vim.api.nvim_get_hl(0, { name = outer_name, create = false }) + local inner = vim.api.nvim_get_hl(0, { name = inner_name, create = false }) + -- try to find a predefined hl + local name = (outer_name .. inner_name) + if vim.api.nvim_get_hl(0, { name = name, create = false }) then + return name + end + -- generate one new one automatically + name = ('autohi_' .. outer_name .. inner_name) + vim.api.nvim_get_hl(0, { name = name, create = true }) + local hi = vim.tbl_extend('force', inner, { bg = inner.fg }, { fg = outer.bg }) + vim.api.nvim_set_hl(0, name, hi) + return name +end + +function _G.statusline_lsp_diagnostics(bufnr, default_hi) + local signs = vim.diagnostic.config().signs.text or {} + local error_num = vim.diagnostic.get(bufnr, { severity = vim.diagnostic.severity.ERROR }) + local warn_num = vim.diagnostic.get(bufnr, { severity = vim.diagnostic.severity.WARN }) + + local s = '' + if #error_num > 0 then + local errs = signs[vim.diagnostic.severity.ERROR] .. ' ' .. #error_num + s = s + .. statusline_append(errs, statusline_combine_hi('StatusLine', 'DiagnosticError'), default_hi) + end + if #warn_num > 0 then + local warns = signs[vim.diagnostic.severity.WARN] .. ' ' .. #warn_num + s = s + .. statusline_append(warns, statusline_combine_hi('StatusLine', 'DiagnosticWarn'), default_hi) + end + return vim.trim(s) +end + +function _G.statusline_git(_, hi) + if vim.b.gitsigns_status and vim.b.gitsigns_status ~= '' then + return statusline_append('[' .. vim.b.gitsigns_status .. ']', 'StatusLineGitChanges', hi) + end +end + +function _G.statusline_grapple(_, _) + local g = package.loaded.grapple + if not g then + return '' + end + return g.statusline() + -- if not g or not g.exists({ buffer = bufnr }) then + -- return '' + -- end + -- return '➥ ' .. g.key({ buffer = bufnr }) +end + +function _G.statusline_spinner(bufnr, _) + local sp = package.loaded.spinner + if not sp then + return '' + end + return sp.status(bufnr) +end + +function _G.statusline_dap(_, _) + local dap = package.loaded.dap + if not dap then + return '' + end + local s = dap.status() + if s == '' then + return s + end + return '[DAP: ' .. s .. ']' +end + +local hi = function(name, opts) + vim.api.nvim_set_hl(0, name, opts) +end + +local statusline = vim.api.nvim_get_hl(0, { name = 'StatusLine', create = false }) +hi('StatusLineDiagnosticError', { fg = 'NvimDarkRed', bg = statusline.bg, bold = true }) +hi('StatusLineDiagnosticWarn', { fg = 'NvimDarkYellow', bg = statusline.bg, bold = true }) + +vim.opt.statusline = '%{%v:lua.statusline()%}' + +-- WINBAR -- +-- vim.opt.winbar = [[%h%w%q%f %-m %-r %= %#WinBarCwd#%{%getcwd()%}%*]] -- keep it simple +-- function _G.winbar() +-- return [[%<%F %-m %-r]] +-- end +-- vim.opt.winbar = '%{%v:lua.winbar()%}' diff --git a/.vim/plugin/syncbg.lua b/.vim/plugin/syncbg.lua new file mode 100644 index 0000000..d9243f0 --- /dev/null +++ b/.vim/plugin/syncbg.lua @@ -0,0 +1,53 @@ +-- this plugin registers two autocmds that trigger when openeing and closing vim, setting the +-- background of the terminal to the color used by our colorscheme using CSI control codes. + +local state = {} + +-- get tty +local tty_handle = io.popen('tty') +if tty_handle == nil then + return +end +local tty = tty_handle:read('*a') +tty_handle:close() +if tty:find('not a tty') then + error('not a tty') +end +state.tty = tty + +-- register update hook +vim.api.nvim_create_autocmd({ 'ColorScheme', 'UIEnter', 'VimResume' }, { + callback = function() + if state.tty == nil then + return + end + + if not state.normal then + -- get colorscheme Normal highlight + local normal = vim.api.nvim_get_hl(0, { name = 'Normal', create = false }) + if normal.bg == nil then + return + end + -- cache old value for use with VimResume + state.normal = normal + end + + -- emit CSI to change terminal background to Normal.bg + os.execute( + 'printf "\\033]11;' .. string.format('#%06x', state.normal.bg) .. '\\007" > ' .. state.tty + ) + + -- set colorscheme Normal.bg to NONE, making it transparent + vim.cmd([[hi Normal ctermbg=NONE guibg=NONE]]) + end, +}) + +-- register reset hook +vim.api.nvim_create_autocmd({ 'UILeave' }, { + callback = function() + if state.tty == nil then + return + end + os.execute('printf "\\033]111\\007" > ' .. state.tty) + end, +}) diff --git a/.vim/plugin/termopen.lua b/.vim/plugin/termopen.lua new file mode 100644 index 0000000..68b9d8d --- /dev/null +++ b/.vim/plugin/termopen.lua @@ -0,0 +1,59 @@ +local function 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 = { ' ', '─', ' ', ' ', ' ', '─', ' ', ' ' }, + }) + vim.api.nvim_set_current_win(win) + + -- spawn the command + vim.fn.termopen(opts.cmd, { + 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 + +-- provide user commands +vim.api.nvim_create_user_command('Termopen', function(a) + termopen({ cmd = a.fargs }) +end, { nargs = '*' }) + +-- alias +vim.api.nvim_create_user_command('T', function(a) + termopen({ cmd = a.fargs }) +end, { nargs = '*' }) + +-- helper to spawn &makeprg +vim.api.nvim_create_user_command('Make', function(a) + local cmd = vim.split(vim.o.makeprg, ' ') + cmd = vim.tbl_map(function(p) + p, _ = string.gsub(p, [[%$%*]], a.args) + p, _ = vim.fn.expand(p) + return p + end, cmd) + termopen({ cmd = cmd }) +end, { nargs = '*' }) diff --git a/.vim/plugin/undo.lua b/.vim/plugin/undo.lua new file mode 100644 index 0000000..aed6195 --- /dev/null +++ b/.vim/plugin/undo.lua @@ -0,0 +1,10 @@ +-- persistent undo + +local undodir = vim.fn.stdpath('cache') .. '/undodir' + +if vim.fn.isdirectory(undodir) == 0 then + vim.fn.mkdir(undodir, 'p', '0700') +end + +vim.g.undodir = undodir +vim.opt.undofile = true diff --git a/.vim/snippets/.licenses/agpl-3.0 b/.vim/snippets/.licenses/agpl-3.0 deleted file mode 100644 index 2beb9e1..0000000 --- a/.vim/snippets/.licenses/agpl-3.0 +++ /dev/null @@ -1,662 +0,0 @@ - GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -our General Public Licenses are intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - - A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - - The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - - An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU Affero General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Remote Network Interaction; Use with the GNU General Public License. - - Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your version -supports such interaction) an opportunity to receive the Corresponding -Source of your version by providing access to the Corresponding Source -from a network server at no charge, through some standard or customary -means of facilitating copying of software. This Corresponding Source -shall include the Corresponding Source for any work covered by version 3 -of the GNU General Public License that is incorporated pursuant to the -following paragraph. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the work with which it is combined will remain governed by version -3 of the GNU General Public License. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU Affero General Public License from time to time. Such new versions -will be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU Affero General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU Affero General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU Affero General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a "Source" link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for the -specific requirements. - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU AGPL, see -. - diff --git a/.vim/snippets/.licenses/cc0-1.0 b/.vim/snippets/.licenses/cc0-1.0 deleted file mode 100644 index 670154e..0000000 --- a/.vim/snippets/.licenses/cc0-1.0 +++ /dev/null @@ -1,116 +0,0 @@ -CC0 1.0 Universal - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator and -subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for the -purpose of contributing to a commons of creative, cultural and scientific -works ("Commons") that the public can reliably and without fear of later -claims of infringement build upon, modify, incorporate in other works, reuse -and redistribute as freely as possible in any form whatsoever and for any -purposes, including without limitation commercial purposes. These owners may -contribute to the Commons to promote the ideal of a free culture and the -further production of creative, cultural and scientific works, or to gain -reputation or greater distribution for their Work in part through the use and -efforts of others. - -For these and/or other purposes and motivations, and without any expectation -of additional consideration or compensation, the person associating CC0 with a -Work (the "Affirmer"), to the extent that he or she is an owner of Copyright -and Related Rights in the Work, voluntarily elects to apply CC0 to the Work -and publicly distribute the Work under its terms, with knowledge of his or her -Copyright and Related Rights in the Work and the meaning and intended legal -effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not limited -to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, communicate, - and translate a Work; - - ii. moral rights retained by the original author(s) and/or performer(s); - - iii. publicity and privacy rights pertaining to a person's image or likeness - depicted in a Work; - - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - - v. rights protecting the extraction, dissemination, use and reuse of data in - a Work; - - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation thereof, - including any amended or successor version of such directive); and - - vii. other similar, equivalent or corresponding rights throughout the world - based on applicable law or treaty, and any national implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention of, -applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and -unconditionally waives, abandons, and surrenders all of Affirmer's Copyright -and Related Rights and associated claims and causes of action, whether now -known or unknown (including existing as well as future claims and causes of -action), in the Work (i) in all territories worldwide, (ii) for the maximum -duration provided by applicable law or treaty (including future time -extensions), (iii) in any current or future medium and for any number of -copies, and (iv) for any purpose whatsoever, including without limitation -commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes -the Waiver for the benefit of each member of the public at large and to the -detriment of Affirmer's heirs and successors, fully intending that such Waiver -shall not be subject to revocation, rescission, cancellation, termination, or -any other legal or equitable action to disrupt the quiet enjoyment of the Work -by the public as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason be -judged legally invalid or ineffective under applicable law, then the Waiver -shall be preserved to the maximum extent permitted taking into account -Affirmer's express Statement of Purpose. In addition, to the extent the Waiver -is so judged Affirmer hereby grants to each affected person a royalty-free, -non transferable, non sublicensable, non exclusive, irrevocable and -unconditional license to exercise Affirmer's Copyright and Related Rights in -the Work (i) in all territories worldwide, (ii) for the maximum duration -provided by applicable law or treaty (including future time extensions), (iii) -in any current or future medium and for any number of copies, and (iv) for any -purpose whatsoever, including without limitation commercial, advertising or -promotional purposes (the "License"). The License shall be deemed effective as -of the date CC0 was applied by Affirmer to the Work. Should any part of the -License for any reason be judged legally invalid or ineffective under -applicable law, such partial invalidity or ineffectiveness shall not -invalidate the remainder of the License, and in such case Affirmer hereby -affirms that he or she will not (i) exercise any of his or her remaining -Copyright and Related Rights in the Work or (ii) assert any associated claims -and causes of action with respect to the Work, in either case contrary to -Affirmer's express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - - b. Affirmer offers the Work as-is and makes no representations or warranties - of any kind concerning the Work, express, implied, statutory or otherwise, - including without limitation warranties of title, merchantability, fitness - for a particular purpose, non infringement, or the absence of latent or - other defects, accuracy, or the present or absence of errors, whether or not - discoverable, all to the greatest extent permissible under applicable law. - - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without limitation - any person's Copyright and Related Rights in the Work. Further, Affirmer - disclaims responsibility for obtaining any necessary consents, permissions - or other rights required for any use of the Work. - - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to this - CC0 or use of the Work. - -For more information, please see - diff --git a/.vim/snippets/.licenses/gpl-3.0 b/.vim/snippets/.licenses/gpl-3.0 deleted file mode 100644 index 53d1f3d..0000000 --- a/.vim/snippets/.licenses/gpl-3.0 +++ /dev/null @@ -1,675 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. - diff --git a/.vim/snippets/.licenses/mit b/.vim/snippets/.licenses/mit deleted file mode 100644 index d7099c7..0000000 --- a/.vim/snippets/.licenses/mit +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) {year} {copyright} - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/.vim/snippets/all.lua b/.vim/snippets/all.lua index 0d0e3e6..6dfe009 100644 --- a/.vim/snippets/all.lua +++ b/.vim/snippets/all.lua @@ -1,17 +1,21 @@ ---@diagnostic disable: undefined-global -local todo_comment = function(keys) - local choices = vim.tbl_map(function(e) - return t(e) - end, keys) - table.insert(choices, i(0)) - return comment({ c(1, choices), t(': ') }) -end - return { - -- s('my', user_email), + -- mini symbols + s('check', t([[✔]])), + s('cross', t([[✖]])), + s('...', t([[…]])), + + s( + 'memail', + c(1, { + t([[robert@gnzler.de]]), + t([[robert@gnzler.io]]), + }) + ), s('mename', t([[Robert Günzler]])), s('date', exec([[date --rfc-email]])), + s( 'today', f(function() @@ -25,52 +29,27 @@ return { end, {}) ), - -- todo comments - s('todo', todo_comment({ 'TODO', 'NOTE', 'FIXME' })), - s( - { trig = '#!', name = 'Shell script skeleton' }, - fmt( - [=[ - #!/bin/sh - - set -e - [ -n "$DEBUG" ] && set -x - [ -n "$DESC" ] && desc() {{ - printf "{}" - exit 0 - }} - - ]=], - { i(1, 'what does this script do') } - ), - { - callbacks = { - [-1] = { - [require('luasnip.util.events').enter] = function(_, _) - vim.opt_local.filetype = 'sh' - end, - }, - }, - } + 'license', + d(1, function() + local choices = {} + for _, path in + ipairs( + vim.fn.glob(vim.fn.stdpath('config') .. '/snippets/license_*.txt', false, true, false) + ) + do + choices[#choices + 1] = f(function(_, _, uargs) + return vim.fn.readfile(uargs) + end, {}, { user_args = { path } }) + end + return sn(nil, { c(1, choices, { name = 'FOSS licenses' }) }) + end, nil) ), - -- mini symbols - s('check', t([[✔]])), - s('cross', t([[✖]])), - - -- licenses (SPDX header) - s({ trig = 'spdx-mit', name = 'MIT license' }, comment({ t([[SPDX-License-Identifier: MIT]]) })), - s( - { trig = 'spdx-gpl-3.0', name = 'MIT license' }, - comment({ t([[SPDX-License-Identifier: GPL-3.0]]) }) - ), - s( - { trig = 'spdx-agpl-3.0', name = 'MIT license' }, - comment({ t([[SPDX-License-Identifier: AGPL-3.0]]) }) - ), s( - { trig = 'spdx-cc0-1.0', name = 'MIT license' }, - comment({ t([[SPDX-License-Identifier: CC0-1.0]]) }) + 'todo', + d(1, function() + return sn(nil, fmt(string.format(vim.bo.commentstring, ' TODO: {} '), { i(1) })) + end, nil) ), } diff --git a/.vim/snippets/cmake.lua b/.vim/snippets/cmake.lua deleted file mode 100644 index 946fab7..0000000 --- a/.vim/snippets/cmake.lua +++ /dev/null @@ -1,26 +0,0 @@ ----@diagnostic disable: undefined-global -return { - s( - { trig = 'debugvar', desc = 'cmake_print_variables' }, - fmt( - [=[ - include(CMakePrintHelpers) - cmake_print_variables({}) - ]=], - { i(1) } - ) - ), - s( - { trig = 'debugprop', desc = 'cmake_print_properties' }, - fmt( - [=[ - include(CMakePrintHelpers) - cmake_print_properties( - TARGETS {} - PROPERTIES {} - ) - ]=], - { i(1), i(2) } - ) - ), -} diff --git a/.vim/snippets/gitcommit.lua b/.vim/snippets/gitcommit.lua deleted file mode 100644 index 8e8e18f..0000000 --- a/.vim/snippets/gitcommit.lua +++ /dev/null @@ -1,6 +0,0 @@ ----@diagnostic disable: undefined-global -return { - s('sign', fmt([[Signed-off-by: {}]], { sn(1, user_email) })), - s('change', fmt([[Change-type: {}]], { c(1, { t('patch'), t('minor'), t('major') }) })), - s('coauth', fmt([[Co-authored-by: {}]], { i(1) })), -} diff --git a/.vim/snippets/go.lua b/.vim/snippets/go.lua deleted file mode 100644 index 7b3bb71..0000000 --- a/.vim/snippets/go.lua +++ /dev/null @@ -1,35 +0,0 @@ -return { - s( - { trig = 'package main', name = 'Go skeleton' }, - fmt( - [[ - package main - - func main() {{ - {} - }} - ]], - { i(0, 'println("hello world!")') } - ) - ), - s( - { trig = 'package test', name = 'Go test skeleton' }, - fmt( - [[ - package main - - import ( - "testing" - ) - - func Test{}(t *testing.T) {{ - {} - }} - ]], - { - i(1, 'Foobar'), - i(0, 't.Logf("Hello world")'), - } - ) - ), -} diff --git a/.vim/snippets/html.lua b/.vim/snippets/html.lua new file mode 100644 index 0000000..07c2c09 --- /dev/null +++ b/.vim/snippets/html.lua @@ -0,0 +1,51 @@ +---@diagnostic disable: undefined-global +return { + s( + 'html:5', + fmt( + [[ + + + + + + + + + + + + {title} + + + + {body} + + + + ]], + { + title = i(1, 'my title'), + style = i(2, 'style.css'), + script = i(3, 'main.js'), + body = i(0), + } + ) + ), + s('anchor', fmt([[{}]], { i(1), i(2) })), + s( + 'journal', + fmt( + [[ +
+

{}

+

{}

+
+ ]], + { + i(1, os.date('%Y-%m-%d, %a')), + i(0), + } + ) + ), +} diff --git a/.vim/snippets/javascript.lua b/.vim/snippets/javascript.lua new file mode 100644 index 0000000..4c7b8e3 --- /dev/null +++ b/.vim/snippets/javascript.lua @@ -0,0 +1,26 @@ +---@diagnostic disable: undefined-global + +local jsdoc_s = function(ctx, snip) + return s(ctx, snip, { + show_condition = cond.ts('comment'), + }) +end + +return { + s({ trig = 'jsdoc', name = 'JSDoc comment' }, { + t('/**'), + nl(), + t(' * '), + i(1), + nl(), + t(' */'), + }), + jsdoc_s( + { trig = 'param', name = 'JSDoc @param' }, + { t('@param '), t('{'), i(1), t('}'), t(' '), i(2) } + ), + jsdoc_s( + { trig = 'return', name = 'JSDoc @return' }, + { t('@return '), t('{'), i(1), t('}'), t(' ') } + ), +} diff --git a/.vim/snippets/license_eupl.txt b/.vim/snippets/license_eupl.txt new file mode 100644 index 0000000..4153cd3 --- /dev/null +++ b/.vim/snippets/license_eupl.txt @@ -0,0 +1,287 @@ + EUROPEAN UNION PUBLIC LICENCE v. 1.2 + EUPL © the European Union 2007, 2016 + +This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined +below) which is provided under the terms of this Licence. Any use of the Work, +other than as authorised under this Licence is prohibited (to the extent such +use is covered by a right of the copyright holder of the Work). + +The Work is provided under the terms of this Licence when the Licensor (as +defined below) has placed the following notice immediately following the +copyright notice for the Work: + + Licensed under the EUPL + +or has expressed by any other means his willingness to license under the EUPL. + +1. Definitions + +In this Licence, the following terms have the following meaning: + +- ‘The Licence’: this Licence. + +- ‘The Original Work’: the work or software distributed or communicated by the + Licensor under this Licence, available as Source Code and also as Executable + Code as the case may be. + +- ‘Derivative Works’: the works or software that could be created by the + Licensee, based upon the Original Work or modifications thereof. This Licence + does not define the extent of modification or dependence on the Original Work + required in order to classify a work as a Derivative Work; this extent is + determined by copyright law applicable in the country mentioned in Article 15. + +- ‘The Work’: the Original Work or its Derivative Works. + +- ‘The Source Code’: the human-readable form of the Work which is the most + convenient for people to study and modify. + +- ‘The Executable Code’: any code which has generally been compiled and which is + meant to be interpreted by a computer as a program. + +- ‘The Licensor’: the natural or legal person that distributes or communicates + the Work under the Licence. + +- ‘Contributor(s)’: any natural or legal person who modifies the Work under the + Licence, or otherwise contributes to the creation of a Derivative Work. + +- ‘The Licensee’ or ‘You’: any natural or legal person who makes any usage of + the Work under the terms of the Licence. + +- ‘Distribution’ or ‘Communication’: any act of selling, giving, lending, + renting, distributing, communicating, transmitting, or otherwise making + available, online or offline, copies of the Work or providing access to its + essential functionalities at the disposal of any other natural or legal + person. + +2. Scope of the rights granted by the Licence + +The Licensor hereby grants You a worldwide, royalty-free, non-exclusive, +sublicensable licence to do the following, for the duration of copyright vested +in the Original Work: + +- use the Work in any circumstance and for all usage, +- reproduce the Work, +- modify the Work, and make Derivative Works based upon the Work, +- communicate to the public, including the right to make available or display + the Work or copies thereof to the public and perform publicly, as the case may + be, the Work, +- distribute the Work or copies thereof, +- lend and rent the Work or copies thereof, +- sublicense rights in the Work or copies thereof. + +Those rights can be exercised on any media, supports and formats, whether now +known or later invented, as far as the applicable law permits so. + +In the countries where moral rights apply, the Licensor waives his right to +exercise his moral right to the extent allowed by law in order to make effective +the licence of the economic rights here above listed. + +The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to +any patents held by the Licensor, to the extent necessary to make use of the +rights granted on the Work under this Licence. + +3. Communication of the Source Code + +The Licensor may provide the Work either in its Source Code form, or as +Executable Code. If the Work is provided as Executable Code, the Licensor +provides in addition a machine-readable copy of the Source Code of the Work +along with each copy of the Work that the Licensor distributes or indicates, in +a notice following the copyright notice attached to the Work, a repository where +the Source Code is easily and freely accessible for as long as the Licensor +continues to distribute or communicate the Work. + +4. Limitations on copyright + +Nothing in this Licence is intended to deprive the Licensee of the benefits from +any exception or limitation to the exclusive rights of the rights owners in the +Work, of the exhaustion of those rights or of other applicable limitations +thereto. + +5. Obligations of the Licensee + +The grant of the rights mentioned above is subject to some restrictions and +obligations imposed on the Licensee. Those obligations are the following: + +Attribution right: The Licensee shall keep intact all copyright, patent or +trademarks notices and all notices that refer to the Licence and to the +disclaimer of warranties. The Licensee must include a copy of such notices and a +copy of the Licence with every copy of the Work he/she distributes or +communicates. The Licensee must cause any Derivative Work to carry prominent +notices stating that the Work has been modified and the date of modification. + +Copyleft clause: If the Licensee distributes or communicates copies of the +Original Works or Derivative Works, this Distribution or Communication will be +done under the terms of this Licence or of a later version of this Licence +unless the Original Work is expressly distributed only under this version of the +Licence — for example by communicating ‘EUPL v. 1.2 only’. The Licensee +(becoming Licensor) cannot offer or impose any additional terms or conditions on +the Work or Derivative Work that alter or restrict the terms of the Licence. + +Compatibility clause: If the Licensee Distributes or Communicates Derivative +Works or copies thereof based upon both the Work and another work licensed under +a Compatible Licence, this Distribution or Communication can be done under the +terms of this Compatible Licence. For the sake of this clause, ‘Compatible +Licence’ refers to the licences listed in the appendix attached to this Licence. +Should the Licensee's obligations under the Compatible Licence conflict with +his/her obligations under this Licence, the obligations of the Compatible +Licence shall prevail. + +Provision of Source Code: When distributing or communicating copies of the Work, +the Licensee will provide a machine-readable copy of the Source Code or indicate +a repository where this Source will be easily and freely available for as long +as the Licensee continues to distribute or communicate the Work. + +Legal Protection: This Licence does not grant permission to use the trade names, +trademarks, service marks, or names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the copyright notice. + +6. Chain of Authorship + +The original Licensor warrants that the copyright in the Original Work granted +hereunder is owned by him/her or licensed to him/her and that he/she has the +power and authority to grant the Licence. + +Each Contributor warrants that the copyright in the modifications he/she brings +to the Work are owned by him/her or licensed to him/her and that he/she has the +power and authority to grant the Licence. + +Each time You accept the Licence, the original Licensor and subsequent +Contributors grant You a licence to their contributions to the Work, under the +terms of this Licence. + +7. Disclaimer of Warranty + +The Work is a work in progress, which is continuously improved by numerous +Contributors. It is not a finished work and may therefore contain defects or +‘bugs’ inherent to this type of development. + +For the above reason, the Work is provided under the Licence on an ‘as is’ basis +and without warranties of any kind concerning the Work, including without +limitation merchantability, fitness for a particular purpose, absence of defects +or errors, accuracy, non-infringement of intellectual property rights other than +copyright as stated in Article 6 of this Licence. + +This disclaimer of warranty is an essential part of the Licence and a condition +for the grant of any rights to the Work. + +8. Disclaimer of Liability + +Except in the cases of wilful misconduct or damages directly caused to natural +persons, the Licensor will in no event be liable for any direct or indirect, +material or moral, damages of any kind, arising out of the Licence or of the use +of the Work, including without limitation, damages for loss of goodwill, work +stoppage, computer failure or malfunction, loss of data or any commercial +damage, even if the Licensor has been advised of the possibility of such damage. +However, the Licensor will be liable under statutory product liability laws as +far such laws apply to the Work. + +9. Additional agreements + +While distributing the Work, You may choose to conclude an additional agreement, +defining obligations or services consistent with this Licence. However, if +accepting obligations, You may act only on your own behalf and on your sole +responsibility, not on behalf of the original Licensor or any other Contributor, +and only if You agree to indemnify, defend, and hold each Contributor harmless +for any liability incurred by, or claims asserted against such Contributor by +the fact You have accepted any warranty or additional liability. + +10. Acceptance of the Licence + +The provisions of this Licence can be accepted by clicking on an icon ‘I agree’ +placed under the bottom of a window displaying the text of this Licence or by +affirming consent in any other similar way, in accordance with the rules of +applicable law. Clicking on that icon indicates your clear and irrevocable +acceptance of this Licence and all of its terms and conditions. + +Similarly, you irrevocably accept this Licence and all of its terms and +conditions by exercising any rights granted to You by Article 2 of this Licence, +such as the use of the Work, the creation by You of a Derivative Work or the +Distribution or Communication by You of the Work or copies thereof. + +11. Information to the public + +In case of any Distribution or Communication of the Work by means of electronic +communication by You (for example, by offering to download the Work from a +remote location) the distribution channel or media (for example, a website) must +at least provide to the public the information requested by the applicable law +regarding the Licensor, the Licence and the way it may be accessible, concluded, +stored and reproduced by the Licensee. + +12. Termination of the Licence + +The Licence and the rights granted hereunder will terminate automatically upon +any breach by the Licensee of the terms of the Licence. + +Such a termination will not terminate the licences of any person who has +received the Work from the Licensee under the Licence, provided such persons +remain in full compliance with the Licence. + +13. Miscellaneous + +Without prejudice of Article 9 above, the Licence represents the complete +agreement between the Parties as to the Work. + +If any provision of the Licence is invalid or unenforceable under applicable +law, this will not affect the validity or enforceability of the Licence as a +whole. Such provision will be construed or reformed so as necessary to make it +valid and enforceable. + +The European Commission may publish other linguistic versions or new versions of +this Licence or updated versions of the Appendix, so far this is required and +reasonable, without reducing the scope of the rights granted by the Licence. New +versions of the Licence will be published with a unique version number. + +All linguistic versions of this Licence, approved by the European Commission, +have identical value. Parties can take advantage of the linguistic version of +their choice. + +14. Jurisdiction + +Without prejudice to specific agreement between parties, + +- any litigation resulting from the interpretation of this License, arising + between the European Union institutions, bodies, offices or agencies, as a + Licensor, and any Licensee, will be subject to the jurisdiction of the Court + of Justice of the European Union, as laid down in article 272 of the Treaty on + the Functioning of the European Union, + +- any litigation arising between other parties and resulting from the + interpretation of this License, will be subject to the exclusive jurisdiction + of the competent court where the Licensor resides or conducts its primary + business. + +15. Applicable Law + +Without prejudice to specific agreement between parties, + +- this Licence shall be governed by the law of the European Union Member State + where the Licensor has his seat, resides or has his registered office, + +- this licence shall be governed by Belgian law if the Licensor has no seat, + residence or registered office inside a European Union Member State. + +Appendix + +‘Compatible Licences’ according to Article 5 EUPL are: + +- GNU General Public License (GPL) v. 2, v. 3 +- GNU Affero General Public License (AGPL) v. 3 +- Open Software License (OSL) v. 2.1, v. 3.0 +- Eclipse Public License (EPL) v. 1.0 +- CeCILL v. 2.0, v. 2.1 +- Mozilla Public Licence (MPL) v. 2 +- GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3 +- Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for + works other than software +- European Union Public Licence (EUPL) v. 1.1, v. 1.2 +- Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong + Reciprocity (LiLiQ-R+). + +The European Commission may update this Appendix to later versions of the above +licences without producing a new version of the EUPL, as long as they provide +the rights granted in Article 2 of this Licence and protect the covered Source +Code from exclusive appropriation. + +All other changes or additions to this Appendix require the production of a new +EUPL version. diff --git a/.vim/snippets/license_mit0.txt b/.vim/snippets/license_mit0.txt new file mode 100644 index 0000000..a5f0b4b --- /dev/null +++ b/.vim/snippets/license_mit0.txt @@ -0,0 +1,18 @@ +MIT No Attribution + +Copyright 2024 Robert Günzler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/.vim/snippets/lua.lua b/.vim/snippets/lua.lua deleted file mode 100644 index 6e9e58a..0000000 --- a/.vim/snippets/lua.lua +++ /dev/null @@ -1,25 +0,0 @@ ----@diagnostic disable: undefined-global -return { - s( - 'plug', - fmt( - [[ - {{ - '{}', - enabled = true, - {}, - opts = {{ - {} - }}, - }}, - ]], - { - i(1, 'username/repo'), - c(2, { - fmt([[cmd = {{'{}'}}]], { i(1, 'Cmd') }), - }), - i(3), - } - ) - ), -} diff --git a/.vim/snippets/mail.lua b/.vim/snippets/mail.lua index a9ccfc6..e41dc0f 100644 --- a/.vim/snippets/mail.lua +++ b/.vim/snippets/mail.lua @@ -1,11 +1,10 @@ ---@diagnostic disable: undefined-global return { - s( - { trig = 'sehr', desc = 'Sehr geehrte ...' }, - t([[Sehr geehrte Damen und Herren,]]) - ), - s( - { trig = 'mfg', desc = 'Mit freundlichen Grüßen' }, - t([[Mit freundlichen Grüßen,]]) - ), + s('Sehr geehrte', { + t('Sehr geehrte Damen und Herren,\n'), + t('\n'), + i(0), + t('\n'), + t('Mit freundlichen Grüßen,\n'), + }), } diff --git a/.vim/snippets/markdown.lua b/.vim/snippets/markdown.lua new file mode 100644 index 0000000..221f301 --- /dev/null +++ b/.vim/snippets/markdown.lua @@ -0,0 +1,20 @@ +---@diagnostic disable: undefined-global +return { + s( + 'bugs', + fmt( + [[ +## bugs, help, patches? + +submit them to my [public-inbox](https://lists.sr.ht/~robertgzr/public-inbox) by sending an email to [~robertgzr/public-inbox@lists.sr.ht](mailto:~robertgzr/public-inbox@lists.sr.ht?Subject=%5B{proj}%5D%20) +]], + { proj = i(1, 'project name') } + ) + ), + + s('date', { + t(''), + i(1), + t(''), + }), +} diff --git a/.vim/snippets/sh.lua b/.vim/snippets/sh.lua deleted file mode 100644 index e8ba23b..0000000 --- a/.vim/snippets/sh.lua +++ /dev/null @@ -1,39 +0,0 @@ ----@diagnostic disable: undefined-global -return { - s( - { trig = 'getopts', desc = 'getopts skeleton' }, - fmt( - [=[ - while getopts h{} opt; do - case ${{opt}} in - h | ?) - printf "usage: %s [-h]\n" "$(basename "$0")" - printf "\n" - exit 2 - ;; - esac - done - shift $((OPTIND - 1)) - ]=], - { i(1) } - ) - ), - - s( - { trig = 'usage' }, - fmt( - [=[ - usage() {{ - printf "usage: %s{}" "$(basename "$0")\n" - printf "\n" - {} - printf "\n" - }} - ]=], - { - i(1, ' []'), - i(2, 'printf " -{}\n"'), - } - ) - ), -} diff --git a/.vim/snippets/text.lua b/.vim/snippets/text.lua deleted file mode 100644 index 9fca88f..0000000 --- a/.vim/snippets/text.lua +++ /dev/null @@ -1,26 +0,0 @@ ----@diagnostic disable: undefined-global -return { - s('test', t('test inserted')), - -- licenses (full-text) - s( - { trig = 'license-mit', name = 'MIT license' }, - file_contents(vim.fn.stdpath('config') .. '/snippets/.licenses/mit', { - year = f(function() - return os.date('%Y') - end, {}), - copyright = sn(1, user_email), - }) - ), - s( - { trig = 'license-gpl-3.0', name = 'GPL-3.0 license' }, - file_contents(vim.fn.stdpath('config') .. '/snippets/.licenses/gpl-3.0', {}) - ), - s( - { trig = 'license-agpl-3.0', name = 'AGPL-3.0 license' }, - file_contents(vim.fn.stdpath('config') .. '/snippets/.licenses/agpl-3.0', {}) - ), - s( - { trig = 'license-cc0-1.0', name = 'CC-Zero-1.0 license' }, - file_contents(vim.fn.stdpath('config') .. '/snippets/.licenses/cc0-1.0', {}) - ), -} diff --git a/.vim/snippets/zig.lua b/.vim/snippets/zig.lua new file mode 100644 index 0000000..3a7d12f --- /dev/null +++ b/.vim/snippets/zig.lua @@ -0,0 +1,13 @@ +---@diagnostic disable: undefined-global +return { + s('str', t('[]const u8')), + s('fn_C', fmt('fn {}({}) callconv(.C) {}', { i(0), i(1), i(2) })), + s('debug', { + t('std.log.debug("'), + i(1, '{any}'), + t('", .{'), + i(2), + t('});'), + i(0), + }), +} -- cgit 1.4.1