diff options
Diffstat (limited to '.config')
| -rw-r--r-- | .config/nvim/after/ftplugin/markdown.lua | 14 | ||||
| -rw-r--r-- | .config/nvim/init.lua | 44 | ||||
| -rw-r--r-- | .config/nvim/lua/dotfiles/follow.lua | 13 | ||||
| -rw-r--r-- | .config/nvim/plugin/00-plugin.lua | 26 | ||||
| -rw-r--r-- | .config/nvim/plugin/50-completion.lua | 5 | ||||
| -rw-r--r-- | .config/nvim/plugin/50-git.lua | 6 | ||||
| -rw-r--r-- | .config/nvim/plugin/50-lsp.lua | 10 | ||||
| -rw-r--r-- | .config/nvim/plugin/50-markdown.lua | 7 | ||||
| -rw-r--r-- | .config/nvim/plugin/50-netrw.lua | 6 | ||||
| -rw-r--r-- | .config/nvim/plugin/50-notes.lua | 59 | ||||
| -rw-r--r-- | .config/nvim/plugin/50-session.lua | 3 | ||||
| -rw-r--r-- | .config/nvim/plugin/50-spell.lua | 12 | ||||
| -rw-r--r-- | .config/nvim/plugin/50-tabline.lua | 15 | ||||
| -rw-r--r-- | .config/nvim/plugin/50-transform_text.lua | 8 |
14 files changed, 176 insertions, 52 deletions
diff --git a/.config/nvim/after/ftplugin/markdown.lua b/.config/nvim/after/ftplugin/markdown.lua index 972e9b1..1ac7200 100644 --- a/.config/nvim/after/ftplugin/markdown.lua +++ b/.config/nvim/after/ftplugin/markdown.lua @@ -107,5 +107,15 @@ local function uncheck_checklist_item() vim.api.nvim_buf_set_lines(0, start_row - 1, end_row, false, lines) end -vim.api.nvim_buf_create_user_command(0, "MarkdownCheck", check_checklist_item, { desc = "Check checklist item" }) -vim.api.nvim_buf_create_user_command(0, "MarkdownUncheck", uncheck_checklist_item, { desc = "Uncheck checklist item" }) +vim.api.nvim_buf_create_user_command( + 0, + "MarkdownCheck", + check_checklist_item, + { desc = "Check checklist item" } +) +vim.api.nvim_buf_create_user_command( + 0, + "MarkdownUncheck", + uncheck_checklist_item, + { desc = "Uncheck checklist item" } +) diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index f2f577c..e806097 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -23,7 +23,10 @@ vim.opt.winbar = "%#WinBarCwd#%{fnamemodify(getcwd(),':~')}%* | %#WinBarFilePath local function show_buf_diff_orig() local bname = vim.api.nvim_buf_get_name(0) if not vim.uv.fs_stat(bname) then - vim.notify("Cannot diff with original because " .. bname .. " doesn't exist", vim.log.levels.WARN) + vim.notify( + "Cannot diff with original because " .. bname .. " doesn't exist", + vim.log.levels.WARN + ) return end local cwin = vim.api.nvim_get_current_win() @@ -34,7 +37,10 @@ local function show_buf_diff_orig() vim.notify("Could not copy file: " .. err, vim.log.levels.ERROR) return end - vim.cmd.split({ temp, mods = { vertical = vim.api.nvim_win_get_width(0) >= vim.o.textwidth * 2, keepalt = true } }) + vim.cmd.split({ + temp, + mods = { vertical = vim.api.nvim_win_get_width(0) >= vim.o.textwidth * 2, keepalt = true }, + }) vim.cmd.diffthis() vim.opt_local.bufhidden = "wipe" vim.opt_local.buftype = "nofile" @@ -99,7 +105,11 @@ vim.api.nvim_create_autocmd({ "FileChangedShell" }, { -- Commands (there's more in the different plugins) ------------------------------------------------------------------------------------------------------------------------ -vim.api.nvim_create_user_command("DiffOrig", show_buf_diff_orig, { desc = "Show diff between current buffer and file" }) +vim.api.nvim_create_user_command( + "DiffOrig", + show_buf_diff_orig, + { desc = "Show diff between current buffer and file" } +) ------------------------------------------------------------------------------------------------------------------------ -- Keymaps (there's more in the different plugins) @@ -109,14 +119,24 @@ vim.api.nvim_create_user_command("DiffOrig", show_buf_diff_orig, { desc = "Show -- Miscellaneous vim.keymap.set("n", "<M-z>", "zA", { desc = "Toggle fold (recursively) under cursor" }) -vim.keymap.set("n", "ZR", vim.cmd.SessionRestart, { desc = "Save and load default session and restart" }) +vim.keymap.set( + "n", + "ZR", + vim.cmd.SessionRestart, + { desc = "Save and load default session and restart" } +) vim.keymap.set("n", "ZZ", vim.cmd.SessionExitSave, { desc = "Save to default session and exit" }) vim.keymap.set("n", "ZQ", vim.cmd.SessionExitNoSave, { desc = "Quit without saving session" }) vim.keymap.set("t", "<C-\\><C-\\>", "<C-\\><C-n>", { desc = "Exit terminal mode" }) vim.keymap.set("n", "<Leader>mm", "<Cmd>messages<CR>", { desc = "Show all messages" }) vim.keymap.set("n", "<Leader>mc", "<Cmd>messages clear<CR>", { desc = "Clear all messages" }) vim.keymap.set("n", "<Leader>lh", vim.cmd.LspHintToggle, { desc = "Toggle inlay hints (LSP)" }) -vim.keymap.set("n", "<Leader>y+", "<Cmd>let @+ = expand('%:p')<CR>", { desc = "Copy file path to clipboard" }) +vim.keymap.set( + "n", + "<Leader>y+", + "<Cmd>let @+ = expand('%:p')<CR>", + { desc = "Copy file path to clipboard" } +) -- These two mappings work well together to start command mode and insert from history in two keystrokes. vim.keymap.set("n", "<C-p>", ":", { desc = "Enter command mode" }) vim.keymap.set("c", "<C-p>", "<Up>", { desc = "Insert previous history entry" }) @@ -159,9 +179,19 @@ vim.keymap.set("n", "<Leader>w|", "<C-W>|", { desc = "Set window width" }) -- Tabpages vim.keymap.set("n", "<M-t>", "<Cmd>tabnew<CR>", { desc = "Create new tabpage" }) vim.keymap.set("n", "<C-w>t", "<Cmd>tabclose<CR>", { desc = "Delete current tabpage" }) -vim.keymap.set({ "n", "i", "t" }, "<M-p>", "<Cmd>tabnext #<CR>", { desc = "Move to last accessed tab page" }) +vim.keymap.set( + { "n", "i", "t" }, + "<M-p>", + "<Cmd>tabnext #<CR>", + { desc = "Move to last accessed tab page" } +) vim.keymap.set({ "n", "i", "t" }, "<M-n>", "<Cmd>tabnext<CR>", { desc = "Move to next tab page" }) -vim.keymap.set({ "n", "i", "t" }, "<M-b>", "<Cmd>tabprevious<CR>", { desc = "Move to previous tab page" }) +vim.keymap.set( + { "n", "i", "t" }, + "<M-b>", + "<Cmd>tabprevious<CR>", + { desc = "Move to previous tab page" } +) vim.keymap.set("n", "<C-w>>", "<Cmd>tabmove +1<CR>", { desc = "Move tab to next position" }) vim.keymap.set("n", "<C-w><", "<Cmd>tabmove -1<CR>", { desc = "Move tab to next position" }) -- Scrolling diff --git a/.config/nvim/lua/dotfiles/follow.lua b/.config/nvim/lua/dotfiles/follow.lua index 51c9972..e1cf109 100644 --- a/.config/nvim/lua/dotfiles/follow.lua +++ b/.config/nvim/lua/dotfiles/follow.lua @@ -24,7 +24,10 @@ function M.register_handler(fn) end local function get_visual_selection() - return table.concat(vim.fn.getregion(vim.fn.getpos("v"), vim.fn.getpos("."), { type = vim.fn.mode() }), "\n") + return table.concat( + vim.fn.getregion(vim.fn.getpos("v"), vim.fn.getpos("."), { type = vim.fn.mode() }), + "\n" + ) end -- Returns a suitable target for `vim.cmd.edit()` by looking for a Markdown link under the cursor. @@ -56,7 +59,10 @@ local function get_markdown_link_target() return match end end - vim.notify("No link destination found for link label [" .. label .. "]", vim.log.levels.ERROR) + vim.notify( + "No link destination found for link label [" .. label .. "]", + vim.log.levels.ERROR + ) return nil end @@ -76,7 +82,8 @@ local function get_markdown_link_target() if child:type() == "link_destination" then return text elseif - child:type() == "link_label" or (link_node:type() == "shortcut_link" and child:type() == "link_text") + child:type() == "link_label" + or (link_node:type() == "shortcut_link" and child:type() == "link_text") then -- shortcut_link text don't include the `[]` unlike link_label if link_node:type() ~= "shortcut_link" then diff --git a/.config/nvim/plugin/00-plugin.lua b/.config/nvim/plugin/00-plugin.lua index 55e5a1c..584fe8e 100644 --- a/.config/nvim/plugin/00-plugin.lua +++ b/.config/nvim/plugin/00-plugin.lua @@ -5,17 +5,17 @@ -- vim.pack.add({ - "https://github.com/airblade/vim-gitgutter", -- Show git status in the gutter - "https://github.com/ibhagwan/fzf-lua", -- Fuzzy finder - "https://github.com/jbyuki/one-small-step-for-vimkind", -- DAP adapter for Neovim Lua - "https://github.com/maxmx03/solarized.nvim", -- Solarized color scheme - "https://github.com/MeanderingProgrammer/render-markdown.nvim", -- Markdown rendering - "https://github.com/mfussenegger/nvim-dap", -- DAP (Debug Adapter Protocol) client - "https://github.com/neovim/nvim-lspconfig", -- LSP server configurations - "https://github.com/nvim-lualine/lualine.nvim", -- Status line - "https://github.com/nvim-tree/nvim-web-devicons", -- File-type icons (lualine, fzf-lua, render-markdown) - "https://github.com/nvim-treesitter/nvim-treesitter", -- Parsers, highlighting (treesitter, markdown) - "https://github.com/qadzek/link.vim", -- Tidy URLs into a dedicated section (markdown) - "https://github.com/tpope/vim-surround", -- Manipulate delimiters - "https://github.com/windwp/nvim-autopairs", -- Insert matching delimiters + "https://github.com/airblade/vim-gitgutter", + "https://github.com/ibhagwan/fzf-lua", + "https://github.com/jbyuki/one-small-step-for-vimkind", + "https://github.com/maxmx03/solarized.nvim", + "https://github.com/MeanderingProgrammer/render-markdown.nvim", + "https://github.com/mfussenegger/nvim-dap", + "https://github.com/neovim/nvim-lspconfig", + "https://github.com/nvim-lualine/lualine.nvim", + "https://github.com/nvim-tree/nvim-web-devicons", + "https://github.com/nvim-treesitter/nvim-treesitter", + "https://github.com/qadzek/link.vim", + "https://github.com/tpope/vim-surround", + "https://github.com/windwp/nvim-autopairs", }) diff --git a/.config/nvim/plugin/50-completion.lua b/.config/nvim/plugin/50-completion.lua index f21b1f4..620d9bd 100644 --- a/.config/nvim/plugin/50-completion.lua +++ b/.config/nvim/plugin/50-completion.lua @@ -87,7 +87,10 @@ snippet.expand = function(input) local ok = pcall(orig_expand, input) if not ok then insert_plain(strip_snippet(input)) - vim.notify("Snippet parse failed, inserted as plain text: " .. vim.inspect(input), vim.log.levels.WARN) + vim.notify( + "Snippet parse failed, inserted as plain text: " .. vim.inspect(input), + vim.log.levels.WARN + ) end end diff --git a/.config/nvim/plugin/50-git.lua b/.config/nvim/plugin/50-git.lua index 513074f..8bebef1 100644 --- a/.config/nvim/plugin/50-git.lua +++ b/.config/nvim/plugin/50-git.lua @@ -70,7 +70,11 @@ local git_blame_toggle = (function() end end)() -vim.api.nvim_create_user_command("GitBlame", git_blame_toggle, { desc = "Open/enter git blame window" }) +vim.api.nvim_create_user_command( + "GitBlame", + git_blame_toggle, + { desc = "Open/enter git blame window" } +) -- The original mappings from the plugin are broken vim.keymap.set("n", "]c", "<Cmd>GitGutterNextHunk<CR>", { desc = "Next git hunk" }) diff --git a/.config/nvim/plugin/50-lsp.lua b/.config/nvim/plugin/50-lsp.lua index 215dfcb..41229e5 100644 --- a/.config/nvim/plugin/50-lsp.lua +++ b/.config/nvim/plugin/50-lsp.lua @@ -22,12 +22,18 @@ vim.api.nvim_create_autocmd("LspAttach", { if client:supports_method("textDocument/completion") then vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true }) else - vim.notify("Client " .. client.name .. " does not support completion", vim.log.levels.WARN) + vim.notify( + "Client " .. client.name .. " does not support completion", + vim.log.levels.WARN + ) end if client:supports_method("textDocument/inlayHint") then vim.lsp.inlay_hint.enable(true, { bufnr = 0 }) else - vim.notify("Client " .. client.name .. " does not support inlay hints", vim.log.levels.WARN) + vim.notify( + "Client " .. client.name .. " does not support inlay hints", + vim.log.levels.WARN + ) end end, }) diff --git a/.config/nvim/plugin/50-markdown.lua b/.config/nvim/plugin/50-markdown.lua index a785aaa..cc415f4 100644 --- a/.config/nvim/plugin/50-markdown.lua +++ b/.config/nvim/plugin/50-markdown.lua @@ -14,7 +14,12 @@ require("nvim-treesitter").install({ local markdown_textwidth = vim.g.dotfiles.textwidth.markdown require("render-markdown").setup({ heading = { width = "block", min_width = markdown_textwidth }, - code = { position = "center", sign = false, width = "block", min_width = markdown_textwidth / 2 }, + code = { + position = "center", + sign = false, + width = "block", + min_width = markdown_textwidth / 2, + }, dash = { width = markdown_textwidth }, win_options = { conceallevel = { rendered = 2 } }, }) diff --git a/.config/nvim/plugin/50-netrw.lua b/.config/nvim/plugin/50-netrw.lua index f4787cd..7a5e090 100644 --- a/.config/nvim/plugin/50-netrw.lua +++ b/.config/nvim/plugin/50-netrw.lua @@ -22,4 +22,8 @@ vim.g.netrw_liststyle = 3 -- 3: list style vim.g.netrw_winsize = -30 -- 30 columns wide vim.g.netrw_banner = 0 -- No banner -vim.api.nvim_create_user_command("GotoExplorer", explore, { desc = "Open/close/focus netrw window" }) +vim.api.nvim_create_user_command( + "GotoExplorer", + explore, + { desc = "Open/close/focus netrw window" } +) diff --git a/.config/nvim/plugin/50-notes.lua b/.config/nvim/plugin/50-notes.lua index 907a2bf..4dda9f4 100644 --- a/.config/nvim/plugin/50-notes.lua +++ b/.config/nvim/plugin/50-notes.lua @@ -2,13 +2,22 @@ if vim.env.NOTES_DIR == nil then vim.notify("NOTES_DIR is not set", vim.log.levels.ERROR) return end -vim.g.notes_dir = vim.env.NOTES_DIR:sub(-1) == "/" and vim.env.NOTES_DIR:sub(1, -2) or vim.env.NOTES_DIR +vim.g.notes_dir = vim.env.NOTES_DIR:sub(-1) == "/" and vim.env.NOTES_DIR:sub(1, -2) + or vim.env.NOTES_DIR local notes_dir = vim.g.notes_dir local tagfile = vim.fs.joinpath(vim.fn.stdpath("state"), "notes-tags") local function generate_tags() - vim.system({ "ctags", "--languages=Markdown", "--tag-relative=no", "--recurse", "-f", tagfile, notes_dir }) + vim.system({ + "ctags", + "--languages=Markdown", + "--tag-relative=no", + "--recurse", + "-f", + tagfile, + notes_dir, + }) end -- Completion of all `*.md` note names (relative to the notes dir, extension stripped). @@ -171,7 +180,13 @@ local function update_all_notes(rewriter) local new_text new_text, n = rewriter(text) if n > 0 then - vim.api.nvim_buf_set_lines(b, 0, -1, false, vim.split(new_text, "\n", { plain = true })) + vim.api.nvim_buf_set_lines( + b, + 0, + -1, + false, + vim.split(new_text, "\n", { plain = true }) + ) if not was_modified then -- buffer matched disk; keep it that way vim.api.nvim_buf_call(b, function() vim.cmd("silent! write!") @@ -248,18 +263,28 @@ local function rename_current_note(new_rel) end) generate_tags() - vim.notify(string.format("Renamed to %s — updated %d link(s) in %d file(s)", new_rel, link_count, file_count)) + vim.notify( + string.format( + "Renamed to %s — updated %d link(s) in %d file(s)", + new_rel, + link_count, + file_count + ) + ) end vim.api.nvim_create_user_command("NotesRename", function(opts) if opts.args ~= "" then rename_current_note(opts.args) else - vim.ui.input({ prompt = "Rename note to: ", default = note_name(vim.api.nvim_buf_get_name(0)) }, function(input) - if input and input ~= "" then - rename_current_note(input) + vim.ui.input( + { prompt = "Rename note to: ", default = note_name(vim.api.nvim_buf_get_name(0)) }, + function(input) + if input and input ~= "" then + rename_current_note(input) + end end - end) + ) end end, { nargs = "?", desc = "Rename current note and update wiki-links" }) @@ -320,7 +345,12 @@ local function rename_current_section(new_head) generate_tags() vim.notify( - string.format("Renamed section to %s — updated %d link(s) in %d file(s)", new_head, link_count, file_count) + string.format( + "Renamed section to %s — updated %d link(s) in %d file(s)", + new_head, + link_count, + file_count + ) ) end @@ -329,11 +359,14 @@ vim.api.nvim_create_user_command("NotesRenameSection", function(opts) rename_current_section(opts.args) else local heading = heading_at_cursor(vim.api.nvim_get_current_buf()) - vim.ui.input({ prompt = "Rename section to: ", default = heading and heading.text }, function(input) - if input and input ~= "" then - rename_current_section(input) + vim.ui.input( + { prompt = "Rename section to: ", default = heading and heading.text }, + function(input) + if input and input ~= "" then + rename_current_section(input) + end end - end) + ) end end, { nargs = "*", desc = "Rename the heading at the cursor and update wiki-links" }) diff --git a/.config/nvim/plugin/50-session.lua b/.config/nvim/plugin/50-session.lua index 39b4c09..a297504 100644 --- a/.config/nvim/plugin/50-session.lua +++ b/.config/nvim/plugin/50-session.lua @@ -96,7 +96,8 @@ local function restore_man_windows(manpages) vim.cmd.edit({ args = { info.name } }) end) local buf = vim.api.nvim_win_get_buf(win) - local line = math.max(1, math.min(info.line or 1, vim.api.nvim_buf_line_count(buf))) + local line = + math.max(1, math.min(info.line or 1, vim.api.nvim_buf_line_count(buf))) vim.api.nvim_win_set_cursor(win, { line, 0 }) end end diff --git a/.config/nvim/plugin/50-spell.lua b/.config/nvim/plugin/50-spell.lua index 59bcc92..a25bcff 100644 --- a/.config/nvim/plugin/50-spell.lua +++ b/.config/nvim/plugin/50-spell.lua @@ -25,8 +25,16 @@ vim.opt.spellfile = { -- Spellfiles for zg, zw, z=, etc } vim.api.nvim_create_user_command("SpellToggle", toggle_spell, { desc = "Toggle spell checking" }) -vim.api.nvim_create_user_command("SpellSetEn", set_spell_en, { desc = "Set spell language to English" }) -vim.api.nvim_create_user_command("SpellSetFr", set_spell_fr, { desc = "Set spell language to French" }) +vim.api.nvim_create_user_command( + "SpellSetEn", + set_spell_en, + { desc = "Set spell language to English" } +) +vim.api.nvim_create_user_command( + "SpellSetFr", + set_spell_fr, + { desc = "Set spell language to French" } +) vim.api.nvim_create_user_command( "SpellSetEnFr", set_spell_en_fr, diff --git a/.config/nvim/plugin/50-tabline.lua b/.config/nvim/plugin/50-tabline.lua index b2f2488..a784c72 100644 --- a/.config/nvim/plugin/50-tabline.lua +++ b/.config/nvim/plugin/50-tabline.lua @@ -6,8 +6,16 @@ local function set_wincount_hl() local title = vim.api.nvim_get_hl(0, { name = "Title", link = false }) local tabline = vim.api.nvim_get_hl(0, { name = "TabLine", link = false }) local tablinesel = vim.api.nvim_get_hl(0, { name = "TabLineSel", link = false }) - vim.api.nvim_set_hl(0, "dotfiles.TabLineSelIcon", { fg = tabline.fg, bg = tablinesel.bg, bold = true }) - vim.api.nvim_set_hl(0, "dotfiles.TabLineWinCount", { fg = title.fg, bg = tabline.bg, bold = true, italic = true }) + vim.api.nvim_set_hl( + 0, + "dotfiles.TabLineSelIcon", + { fg = tabline.fg, bg = tablinesel.bg, bold = true } + ) + vim.api.nvim_set_hl( + 0, + "dotfiles.TabLineWinCount", + { fg = title.fg, bg = tabline.bg, bold = true, italic = true } + ) vim.api.nvim_set_hl( 0, "dotfiles.TabLineSelWinCount", @@ -40,7 +48,8 @@ function GetTabLine() local selected_label, modified_label = "▶ ", "[+] " local win_info = ( - is_current and "%#dotfiles.TabLineSelIcon# " .. selected_label or "%#dotfiles.TabLineWinCount# " + is_current and "%#dotfiles.TabLineSelIcon# " .. selected_label + or "%#dotfiles.TabLineWinCount# " ) .. (is_current and "%#dotfiles.TabLineSelWinCount#" or "%#dotfiles.TabLineWinCount#") .. (#wins >= 10 and ">9" or tostring(#wins)) diff --git a/.config/nvim/plugin/50-transform_text.lua b/.config/nvim/plugin/50-transform_text.lua index 9ec74d5..6786ba2 100644 --- a/.config/nvim/plugin/50-transform_text.lua +++ b/.config/nvim/plugin/50-transform_text.lua @@ -1,5 +1,8 @@ local function get_visual_selection_text() - return table.concat(vim.fn.getregion(vim.fn.getpos("v"), vim.fn.getpos("."), { type = vim.fn.mode() }), "\n") + return table.concat( + vim.fn.getregion(vim.fn.getpos("v"), vim.fn.getpos("."), { type = vim.fn.mode() }), + "\n" + ) end local function delete_visual_selection() @@ -7,7 +10,8 @@ local function delete_visual_selection() local eovisual_pos, cur_pos = vim.fn.getpos("v"), vim.fn.getpos(".") local region = vim.fn.getregionpos(eovisual_pos, cur_pos, { type = mode })[1] local start_row, start_col = unpack(region[1], 2, 3) - local end_row, end_col = mode == "v" and region[2][2] or math.max(eovisual_pos[2], cur_pos[2]), region[2][3] + local end_row, end_col = + mode == "v" and region[2][2] or math.max(eovisual_pos[2], cur_pos[2]), region[2][3] vim.api.nvim_buf_set_text(0, start_row - 1, start_col - 1, end_row - 1, end_col, {}) end |
