From 23b69f8669a6b0d416f12db1cf7680b15186137a Mon Sep 17 00:00:00 2001 From: Ben Elan Date: Tue, 23 Jul 2024 01:24:30 -0700 Subject: [PATCH] fix(nvim, i3): cmp-git works in gh's files, plus more MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix monitor and mouse annoyances in i3wm - Fix i3lock setup - Get cmp-git working in markdown files created by `gh`. - Disable cmp-git in markdown files not created by `gh`. - Resolve treesitter-text-objects lazy loading issue - Add back the treesitter query for line length in git commit buffers - Various other small improvements diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index eae3dcbd..1948ec58 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,7 +1,7 @@ { "CopilotChat.nvim": { "branch": "canary", "commit": "92bc7b5e564c23b12b2ed41dd7657fdafe39d95f" }, "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, - "SchemaStore.nvim": { "branch": "main", "commit": "623df28bf9a2661d9d5a0f391bf30bdd8f8de62b" }, + "SchemaStore.nvim": { "branch": "main", "commit": "4abc1ab13ad5031049864cba0bfaec06a908e7e5" }, "cellular-automaton.nvim": { "branch": "main", "commit": "11aea08aa084f9d523b0142c2cd9441b8ede09ed" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-dictionary": { "branch": "main", "commit": "7144ce4bb2abc61a474cfdb3bb652a9ae82079e4" }, @@ -18,7 +18,7 @@ "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" }, "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, "gitsigns.nvim": { "branch": "main", "commit": "f4928ba14eb6c667786ac7d69927f6aee6719f1e" }, - "gp.nvim": { "branch": "main", "commit": "25ef1e5839669c3cf4c15b12646c54afbaff1aea" }, + "gp.nvim": { "branch": "main", "commit": "827d5e32ff7b7108cf8e476b4d7d16a72ec5f293" }, "harpoon": { "branch": "harpoon2", "commit": "e76cb03c420bb74a5900a5b3e1dde776156af45f" }, "lazy.nvim": { "branch": "main", "commit": "839f9e78e78dc935b1188fb16583365991739c51" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, @@ -38,7 +38,7 @@ "nvim-lspconfig": { "branch": "master", "commit": "fa6c2a64100c6f692bbec29bbbc8ec2663c9e869" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, "nvim-rulebook": { "branch": "main", "commit": "a962cc98bf1a5ba564358396b386f1d938b53366" }, - "nvim-treesitter": { "branch": "master", "commit": "debf5816eee21b7d51025ef17ba0647386226cb5" }, + "nvim-treesitter": { "branch": "master", "commit": "9d252d00210ed8d43197ef048daa94e6dc821bd6" }, "nvim-treesitter-context": { "branch": "master", "commit": "8198ad4b01ca64b6f5c7a7253f52df3fe329be46" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, "nvim-web-devicons": { "branch": "master", "commit": "e612de3d3a41a6b7be47f51e956dddabcbf419d9" }, @@ -51,7 +51,7 @@ "telescope.nvim": { "branch": "master", "commit": "79552ef8488cb492e0f9d2bf3b4e808f57515e35" }, "treesj": { "branch": "main", "commit": "275f83c81a5a1f5ae23c1eac30c4ac28beebbca2" }, "trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" }, - "ts-comments.nvim": { "branch": "main", "commit": "8c21ae09c34ef8b82f2c6d2a87f57c3da33bb5e5" }, + "ts-comments.nvim": { "branch": "main", "commit": "0090cacf89bc52e4eddb911bc6c33b12411b95f7" }, "typescript-tools.nvim": { "branch": "master", "commit": "f8c2e0b36b651c85f52ad5c5373ff8b07adc15a7" }, "vim-dirtytalk": { "branch": "master", "commit": "aa57ba902b04341a04ff97214360f56856493583" }, "vim-flog": { "branch": "master", "commit": "36c60cbdb69c169ee44c085ce8d3f2f035a8658e" }, diff --git a/.config/nvim/lua/jamin/plugins/completion.lua b/.config/nvim/lua/jamin/plugins/completion.lua index 83585fab..26de4611 100644 --- a/.config/nvim/lua/jamin/plugins/completion.lua +++ b/.config/nvim/lua/jamin/plugins/completion.lua @@ -30,10 +30,21 @@ return { { "petertriho/cmp-git", ft = { "markdown", "gitcommit", "octo" }, - opts = { - filetypes = { "markdown", "gitcommit", "octo" }, - github = { issues = { state = "all" }, pull_requests = { state = "all" } }, - }, + opts = { filetypes = { "markdown", "gitcommit", "octo" } }, + config = function(_, opts) + require("cmp_git").setup(opts) + + -- The gh cli creates markdown files in `/tmp` when creating/editing issues/prs/comments. Not + -- sure why, but cwd ends up being `/tmp` when gh opens the editor. That prevents cmp-git from + -- working, since it doesn't know the repo to query for completion items. + vim.api.nvim_create_autocmd("FileType", { + pattern = { "markdown" }, + group = vim.api.nvim_create_augroup("jamin_git_cmp_gh_hack", {}), + callback = function(ev) + if string.match(ev.file, "/tmp/%d+%.md") then vim.cmd.cd("-") end + end, + }) + end, }, ----------------------------------------------------------------------------- @@ -228,7 +239,16 @@ return { { name = "luasnip", group_index = 1 }, { name = "nvim_lsp", group_index = 1 }, { name = "path", group_index = 1 }, - { name = "git", group_index = 1 }, + { + name = "git", + entry_filter = function(_, ctx) + return not ( + ctx.filetype == "markdown" + and not string.match(vim.api.nvim_buf_get_name(ctx.bufnr), "/tmp/%d+%.md") + ) + end, + group_index = 1, + }, { name = "buffer", group_index = 1, keyword_length = 2 }, { name = "tmux", group_index = 1, keyword_length = 2 }, -- only show ripgrep/spell/dictionary if there are no results from other sources diff --git a/.config/nvim/lua/jamin/plugins/git.lua b/.config/nvim/lua/jamin/plugins/git.lua index 6243cf12..301157b7 100644 --- a/.config/nvim/lua/jamin/plugins/git.lua +++ b/.config/nvim/lua/jamin/plugins/git.lua @@ -231,6 +231,11 @@ return { function() require("gitsigns").blame_line({ full = true }) end, desc = "Git blame line (gitsigns)", }, + { + "hB", + function() require("gitsigns").blame() end, + desc = "Git blame buffer (gitsigns)", + }, { "htb", function() require("gitsigns").toggle_current_line_blame() end, diff --git a/.config/nvim/lua/jamin/plugins/notes.lua b/.config/nvim/lua/jamin/plugins/notes.lua index 7cd5522e..d409dd5e 100644 --- a/.config/nvim/lua/jamin/plugins/notes.lua +++ b/.config/nvim/lua/jamin/plugins/notes.lua @@ -27,6 +27,7 @@ return { return { filetypes = { md = true, rmd = true, mdx = true, markdown = true }, to_do = { symbols = { " ", "x" } }, + silent = true, links = { style = link_style, transform_explicit = function(text) return text:gsub(" ", "-"):lower() end, @@ -45,7 +46,7 @@ return { MkdnCreateLinkFromClipboard = { { "n", "v" }, "P" }, MkdnToggleToDo = { { "n", "v" }, "m" }, MkdnUpdateNumbering = { "n", "mn" }, - MkdnMoveSource = { "n", "mR" }, + MkdnMoveSource = { "n", "mrn" }, MkdnTableNewRowBelow = { "n", "mir" }, MkdnTableNewRowAbove = { "n", "miR" }, MkdnTableNewColAfter = { "n", "mic" }, diff --git a/.config/nvim/lua/jamin/plugins/treesitter.lua b/.config/nvim/lua/jamin/plugins/treesitter.lua index 71534a28..5929d82b 100644 --- a/.config/nvim/lua/jamin/plugins/treesitter.lua +++ b/.config/nvim/lua/jamin/plugins/treesitter.lua @@ -10,10 +10,6 @@ return { opts = { use_default_keymaps = false, max_join_length = 500 }, }, - ----------------------------------------------------------------------------- - -- more text objects - { "nvim-treesitter/nvim-treesitter-textobjects", lazy = true }, - ----------------------------------------------------------------------------- -- set commentstring based on treesitter node { "folke/ts-comments.nvim", event = "VeryLazy", opts = {} }, @@ -29,8 +25,6 @@ return { opts = { multiline_threshold = 1, max_lines = 6, - mode = "cursor", - -- separator = "─", }, config = function(_, opts) @@ -58,6 +52,9 @@ return { -- syntax tree parser/highlighter engine { "nvim-treesitter/nvim-treesitter", + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", -- more text objects + }, build = ":TSUpdate", cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" }, event = "BufReadPost", @@ -89,7 +86,6 @@ return { return { ensure_installed = res.treesitter_parsers, indent = { enable = true }, - autotag = { enable = true }, query_linter = { enable = true }, highlight = { @@ -185,13 +181,7 @@ return { config = function(_, opts) require("nvim-treesitter.configs").setup(opts) - vim.schedule( - function() - require("lazy").load({ - plugins = { "nvim-treesitter-textobjects", "nvim-treesitter-context" }, - }) - end - ) + vim.schedule(function() require("lazy").load({ plugins = { "nvim-treesitter-context" } }) end) end, }, } diff --git a/.config/nvim/lua/jamin/resources.lua b/.config/nvim/lua/jamin/resources.lua index 192e8539..8bbc00d0 100644 --- a/.config/nvim/lua/jamin/resources.lua +++ b/.config/nvim/lua/jamin/resources.lua @@ -123,7 +123,9 @@ M.mason_packages = { M.treesitter_parsers = { "astro", "bash", + "comment", "css", + -- "csv", "diff", "dockerfile", "git_rebase", @@ -134,13 +136,14 @@ M.treesitter_parsers = { -- "gowork", "graphql", "html", - "http", + -- "http", -- "ini", "javascript", "jsdoc", "json", "json5", "jsonc", + -- "jq", -- "latex", "lua", "luadoc", diff --git a/.config/nvim/queries/gitcommit/highlights.scm b/.config/nvim/queries/gitcommit/highlights.scm new file mode 100644 index 00000000..fdc5247a --- /dev/null +++ b/.config/nvim/queries/gitcommit/highlights.scm @@ -0,0 +1,10 @@ +; extends +; https://github.com/gbprod/tree-sitter-gitcommit/pull/68 + +((subject) @comment.warning + (#vim-match? @comment.warning ".\{50,}") + (#offset! @comment.warning 0 50 0 0)) + +((message_line) @comment.warning + (#vim-match? @comment.warning ".\{72,}") + (#offset! @comment.warning 0 72 0 0)) diff --git a/.dotfiles/shell/exports.sh b/.dotfiles/shell/exports.sh index 26a5bd14..d41ca39e 100644 --- a/.dotfiles/shell/exports.sh +++ b/.dotfiles/shell/exports.sh @@ -210,13 +210,14 @@ if supports fff; then fi # https://github.com/meiji163/gh-notify -export GH_NOTIFY_MARK_READ_KEY="alt-backspace" -export GH_NOTIFY_MARK_ALL_READ_KEY="ctrl-delete" -export GH_NOTIFY_OPEN_BROWSER_KEY="ctrl-o" export GH_NOTIFY_COMMENT_KEY="alt-c" export GH_NOTIFY_VIEW_DIFF_KEY="alt-d" export GH_NOTIFY_VIEW_PATCH_KEY="alt-D" +export GH_NOTIFY_TOGGLE_PREVIEW_KEY="alt-p" export GH_NOTIFY_RESIZE_PREVIEW_KEY="alt-P" +export GH_NOTIFY_MARK_READ_KEY="alt-x" +export GH_NOTIFY_MARK_ALL_READ_KEY="alt-backspace" +export GH_NOTIFY_OPEN_BROWSER_KEY="ctrl-o" # my tools {{{1 supports matpat && export MATPAT_OPEN_CMD="$BROWSER" --- .Xresources | 39 ++++++++++++++++ .config/i3/config | 7 ++- .config/nvim/lazy-lock.json | 16 +++---- .../nvim/lua/jamin/lsp_servers/tsserver.lua | 3 +- .config/nvim/lua/jamin/plugins/completion.lua | 45 +++++++++++++++---- .config/nvim/lua/jamin/plugins/debug.lua | 4 ++ .config/nvim/lua/jamin/plugins/git.lua | 5 +++ .config/nvim/lua/jamin/plugins/lsp.lua | 17 ++++++- .config/nvim/lua/jamin/plugins/notes.lua | 3 +- .config/nvim/lua/jamin/plugins/test.lua | 1 + .config/nvim/lua/jamin/plugins/treesitter.lua | 20 +++------ .config/nvim/lua/jamin/plugins/ui.lua | 12 ++--- .config/nvim/lua/jamin/resources.lua | 6 ++- .config/nvim/queries/gitcommit/highlights.scm | 10 +++++ .config/waybar/config | 2 +- .dotfiles/shell/exports.sh | 7 +-- 16 files changed, 147 insertions(+), 50 deletions(-) create mode 100644 .Xresources create mode 100644 .config/nvim/queries/gitcommit/highlights.scm diff --git a/.Xresources b/.Xresources new file mode 100644 index 00000000..bb4d9dbe --- /dev/null +++ b/.Xresources @@ -0,0 +1,39 @@ +! -1 is default +Xft.dpi: 96 +Xft.autohint: 0 +Xft.antialias: 1 +Xft.hinting: 1 +Xft.hintstyle: hintslight +Xft.lcdfilter: lcddefault +Xft.rgba: rgb + +! https://github.com/morhetz/gruvbox-contrib/blob/master/xresources/gruvbox-dark.xresources + +! hard contrast: *background: #1d2021 +*background: #282828 +! soft contrast: *background: #32302f +*foreground: #ebdbb2 +! Black + DarkGrey +*color0: #282828 +*color8: #928374 +! DarkRed + Red +*color1: #cc241d +*color9: #fb4934 +! DarkGreen + Green +*color2: #98971a +*color10: #b8bb26 +! DarkYellow + Yellow +*color3: #d79921 +*color11: #fabd2f +! DarkBlue + Blue +*color4: #458588 +*color12: #83a598 +! DarkMagenta + Magenta +*color5: #b16286 +*color13: #d3869b +! DarkCyan + Cyan +*color6: #689d6a +*color14: #8ec07c +! LightGrey + White +*color7: #a89984 +*color15: #ebdbb2 diff --git a/.config/i3/config b/.config/i3/config index 3eb205a9..49687564 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -7,8 +7,6 @@ # Mod1 is Alt, Mod4 is Super set $mod Mod4 -set $lock 'i3lock -efc 000000 --nofork' - # Define names for default workspaces for which we configure key bindings later on. # We use variables to avoid repeating the names in multiple places. set $ws1 "01" @@ -153,7 +151,7 @@ bindsym $mod+Shift+r restart bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'Exiting i3 will end the X session, are you sure?' -B 'Yes, exit i3' 'i3-msg exit'" # lock and suspend -bindsym $mod+Escape exec loginctl lock session +bindsym $mod+Escape exec loginctl lock-session bindsym $mod+Shift+Escape exec systemctl suspend # resize window (you can also use the mouse for that) @@ -306,6 +304,7 @@ client.urgent $red $red $white $black $red # smaller window borders for_window [all] border pixel 1 +focus_follows_mouse no ### Startup processes {{{1 # @@ -330,7 +329,7 @@ exec --no-startup-id blueman-applet # xss-lock grabs a logind suspend inhibit lock and will use i3lock to lock the # screen before suspend. Use loginctl lock-session to lock your screen. -exec --no-startup-id xss-lock --transfer-sleep-lock -- $lock +exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock -efc 000000 --nofork # Idle hook for locking session # https://gitlab.com/jD91mZM2/xidlehook diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index eae3dcbd..5a9cd1e1 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,7 +1,7 @@ { - "CopilotChat.nvim": { "branch": "canary", "commit": "92bc7b5e564c23b12b2ed41dd7657fdafe39d95f" }, + "CopilotChat.nvim": { "branch": "canary", "commit": "f7861cb7d0ea46d57f67595876c8d2835eae29a2" }, "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, - "SchemaStore.nvim": { "branch": "main", "commit": "623df28bf9a2661d9d5a0f391bf30bdd8f8de62b" }, + "SchemaStore.nvim": { "branch": "main", "commit": "4abc1ab13ad5031049864cba0bfaec06a908e7e5" }, "cellular-automaton.nvim": { "branch": "main", "commit": "11aea08aa084f9d523b0142c2cd9441b8ede09ed" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-dictionary": { "branch": "main", "commit": "7144ce4bb2abc61a474cfdb3bb652a9ae82079e4" }, @@ -18,14 +18,14 @@ "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" }, "friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" }, "gitsigns.nvim": { "branch": "main", "commit": "f4928ba14eb6c667786ac7d69927f6aee6719f1e" }, - "gp.nvim": { "branch": "main", "commit": "25ef1e5839669c3cf4c15b12646c54afbaff1aea" }, + "gp.nvim": { "branch": "main", "commit": "827d5e32ff7b7108cf8e476b4d7d16a72ec5f293" }, "harpoon": { "branch": "harpoon2", "commit": "e76cb03c420bb74a5900a5b3e1dde776156af45f" }, - "lazy.nvim": { "branch": "main", "commit": "839f9e78e78dc935b1188fb16583365991739c51" }, + "lazy.nvim": { "branch": "main", "commit": "c02268ac6e6aab92249d020d75efc588bd9d24fa" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "58bc9119ca273c0ce5a66fad1927ef0f617bd81b" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "mkdnflow.nvim": { "branch": "main", "commit": "0fa1e682e35d46cd1a0102cedd05b0283e41d18d" }, - "neogen": { "branch": "main", "commit": "6de0add4805165317ab7d3d36b5cef48b1b865f3" }, + "neogen": { "branch": "main", "commit": "4a2f68d3eae0018b04132f1d4590e51484043354" }, "neotest": { "branch": "master", "commit": "32ff2ac21135a372a42b38ae131e531e64833bd3" }, "neotest-jest": { "branch": "main", "commit": "514fd4eae7da15fd409133086bb8e029b65ac43f" }, "neotest-vitest": { "branch": "main", "commit": "353364aa05b94b09409cbef21b79c97c5564e2ce" }, @@ -38,7 +38,7 @@ "nvim-lspconfig": { "branch": "master", "commit": "fa6c2a64100c6f692bbec29bbbc8ec2663c9e869" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, "nvim-rulebook": { "branch": "main", "commit": "a962cc98bf1a5ba564358396b386f1d938b53366" }, - "nvim-treesitter": { "branch": "master", "commit": "debf5816eee21b7d51025ef17ba0647386226cb5" }, + "nvim-treesitter": { "branch": "master", "commit": "9d252d00210ed8d43197ef048daa94e6dc821bd6" }, "nvim-treesitter-context": { "branch": "master", "commit": "8198ad4b01ca64b6f5c7a7253f52df3fe329be46" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, "nvim-web-devicons": { "branch": "master", "commit": "e612de3d3a41a6b7be47f51e956dddabcbf419d9" }, @@ -51,12 +51,12 @@ "telescope.nvim": { "branch": "master", "commit": "79552ef8488cb492e0f9d2bf3b4e808f57515e35" }, "treesj": { "branch": "main", "commit": "275f83c81a5a1f5ae23c1eac30c4ac28beebbca2" }, "trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" }, - "ts-comments.nvim": { "branch": "main", "commit": "8c21ae09c34ef8b82f2c6d2a87f57c3da33bb5e5" }, + "ts-comments.nvim": { "branch": "main", "commit": "0090cacf89bc52e4eddb911bc6c33b12411b95f7" }, "typescript-tools.nvim": { "branch": "master", "commit": "f8c2e0b36b651c85f52ad5c5373ff8b07adc15a7" }, "vim-dirtytalk": { "branch": "master", "commit": "aa57ba902b04341a04ff97214360f56856493583" }, "vim-flog": { "branch": "master", "commit": "36c60cbdb69c169ee44c085ce8d3f2f035a8658e" }, "vim-gnupg": { "branch": "main", "commit": "f9b608f29003dfde6450931dc0f495a912973a88" }, "vim-log-highlighting": { "branch": "master", "commit": "1037e26f3120e6a6a2c0c33b14a84336dee2a78f" }, "vim-projectionist": { "branch": "master", "commit": "3736bd4a5f23b30821cbb892385bb1f1b0088cfc" }, - "zk-nvim": { "branch": "main", "commit": "15e24e96cb90889ebd12b5dbe800a958c716f520" } + "zk-nvim": { "branch": "main", "commit": "dbf4eeab55b08856c9d6b6722dbff39630bb35eb" } } diff --git a/.config/nvim/lua/jamin/lsp_servers/tsserver.lua b/.config/nvim/lua/jamin/lsp_servers/tsserver.lua index dc528767..2bb903df 100644 --- a/.config/nvim/lua/jamin/lsp_servers/tsserver.lua +++ b/.config/nvim/lua/jamin/lsp_servers/tsserver.lua @@ -95,13 +95,14 @@ return { settings = { typescript = language_settings, javascript = language_settings, - completions = { completeFunctionCalls = true }, + completions = { completeFunctionCalls = false }, implicitProjectConfiguration = { checkJs = true }, diagnostics = { -- https://github.com/microsoft/TypeScript/blob/main/src/compiler/diagnosticMessages.json ignoredCodes = { 80001, -- File is a CommonJS module; it may be converted to an ES module. [Suggestion] 80005, -- 'require' call may be converted to an import. [Suggestion] + 80006, -- This may be converted to an async function. [Suggestion] }, }, }, diff --git a/.config/nvim/lua/jamin/plugins/completion.lua b/.config/nvim/lua/jamin/plugins/completion.lua index 83585fab..a528ef56 100644 --- a/.config/nvim/lua/jamin/plugins/completion.lua +++ b/.config/nvim/lua/jamin/plugins/completion.lua @@ -30,10 +30,21 @@ return { { "petertriho/cmp-git", ft = { "markdown", "gitcommit", "octo" }, - opts = { - filetypes = { "markdown", "gitcommit", "octo" }, - github = { issues = { state = "all" }, pull_requests = { state = "all" } }, - }, + opts = { filetypes = { "markdown", "gitcommit", "octo" } }, + config = function(_, opts) + require("cmp_git").setup(opts) + + -- The gh cli creates markdown files in `/tmp` when creating/editing issues/prs/comments. Not + -- sure why, but cwd ends up being `/tmp` when gh opens the editor. That prevents cmp-git from + -- working, since it doesn't know the repo to query for completion items. + vim.api.nvim_create_autocmd("FileType", { + pattern = { "markdown" }, + group = vim.api.nvim_create_augroup("jamin_git_cmp_gh_hack", {}), + callback = function(ev) + if string.match(ev.file, "/tmp/%d+%.md") then vim.cmd.cd("-") end + end, + }) + end, }, ----------------------------------------------------------------------------- @@ -228,7 +239,21 @@ return { { name = "luasnip", group_index = 1 }, { name = "nvim_lsp", group_index = 1 }, { name = "path", group_index = 1 }, - { name = "git", group_index = 1 }, + { + name = "git", + entry_filter = function(_, ctx) + if not ctx.filetype == "markdown" then return true end + + local bufpath = vim.api.nvim_buf_get_name(ctx.bufnr) + local bufname = string.lower(vim.fs.basename(bufpath)) + local enable_files = { "contributing.md", "changelog.md", "readme.md" } + + return vim.list_contains(enable_files, bufname) + -- the gh cli creates files in /tmp when editing issues/prs/comments + or string.match(bufpath, "/tmp/%d+%.md") + end, + group_index = 1, + }, { name = "buffer", group_index = 1, keyword_length = 2 }, { name = "tmux", group_index = 1, keyword_length = 2 }, -- only show ripgrep/spell/dictionary if there are no results from other sources @@ -243,9 +268,13 @@ return { end, option = { enable_in_context = function() - return require("cmp.config.context").in_treesitter_capture("spell") - or require("cmp.config.context").in_syntax_group("Comment") - or vim.tbl_contains(res.filetypes.writing, vim.bo.filetype) + local has_cmp_ctx, cmp_ctx = pcall(require, "cmp.config.context") + return has_cmp_ctx + and ( + cmp_ctx.in_treesitter_capture("spell") + or cmp_ctx.in_syntax_group("Comment") + or vim.tbl_contains(res.filetypes.writing, vim.bo.filetype) + ) end, }, }, diff --git a/.config/nvim/lua/jamin/plugins/debug.lua b/.config/nvim/lua/jamin/plugins/debug.lua index f7a40b5d..6119121a 100644 --- a/.config/nvim/lua/jamin/plugins/debug.lua +++ b/.config/nvim/lua/jamin/plugins/debug.lua @@ -193,6 +193,10 @@ return { local dap = require("dap") vim.g.loaded_dap = true + require("dap.ext.vscode").json_decode = function(str) + return vim.json.decode(require("plenary.json").json_strip_comments(str, {})) + end + ------------------------------------------------------------------------- -- Adapters ------------------------------------------------------------------------- diff --git a/.config/nvim/lua/jamin/plugins/git.lua b/.config/nvim/lua/jamin/plugins/git.lua index 6243cf12..301157b7 100644 --- a/.config/nvim/lua/jamin/plugins/git.lua +++ b/.config/nvim/lua/jamin/plugins/git.lua @@ -231,6 +231,11 @@ return { function() require("gitsigns").blame_line({ full = true }) end, desc = "Git blame line (gitsigns)", }, + { + "hB", + function() require("gitsigns").blame() end, + desc = "Git blame buffer (gitsigns)", + }, { "htb", function() require("gitsigns").toggle_current_line_blame() end, diff --git a/.config/nvim/lua/jamin/plugins/lsp.lua b/.config/nvim/lua/jamin/plugins/lsp.lua index 87df4a6a..9f50a45c 100644 --- a/.config/nvim/lua/jamin/plugins/lsp.lua +++ b/.config/nvim/lua/jamin/plugins/lsp.lua @@ -372,12 +372,25 @@ return { dependencies = { "neovim/nvim-lspconfig" }, opts = function() local has_ts, ts = pcall(require, "jamin.lsp_servers.tsserver") + local has_tst, api = pcall(require, "typescript-tools.api") + + local handlers = has_tst + and has_ts + and { + ["textDocument/publishDiagnostics"] = api.filter_diagnostics( + ts.settings.diagnostics.ignoredCodes or {} + ), + } + or {} + return { + handlers = handlers, settings = { expose_as_code_action = "all", - tsserver_file_preferences = has_ts and ts.init_options.preferences or {}, - complete_function_calls = ts.settings.completions.completeFunctionCalls or true, jsx_close_tag = { enable = true }, + tsserver_file_preferences = has_ts and ts.init_options.preferences or {}, + complete_function_calls = has_ts and ts.settings.completions.completeFunctionCalls + or false, }, } end, diff --git a/.config/nvim/lua/jamin/plugins/notes.lua b/.config/nvim/lua/jamin/plugins/notes.lua index 7cd5522e..d409dd5e 100644 --- a/.config/nvim/lua/jamin/plugins/notes.lua +++ b/.config/nvim/lua/jamin/plugins/notes.lua @@ -27,6 +27,7 @@ return { return { filetypes = { md = true, rmd = true, mdx = true, markdown = true }, to_do = { symbols = { " ", "x" } }, + silent = true, links = { style = link_style, transform_explicit = function(text) return text:gsub(" ", "-"):lower() end, @@ -45,7 +46,7 @@ return { MkdnCreateLinkFromClipboard = { { "n", "v" }, "P" }, MkdnToggleToDo = { { "n", "v" }, "m" }, MkdnUpdateNumbering = { "n", "mn" }, - MkdnMoveSource = { "n", "mR" }, + MkdnMoveSource = { "n", "mrn" }, MkdnTableNewRowBelow = { "n", "mir" }, MkdnTableNewRowAbove = { "n", "miR" }, MkdnTableNewColAfter = { "n", "mic" }, diff --git a/.config/nvim/lua/jamin/plugins/test.lua b/.config/nvim/lua/jamin/plugins/test.lua index 44ab174f..c0487d56 100644 --- a/.config/nvim/lua/jamin/plugins/test.lua +++ b/.config/nvim/lua/jamin/plugins/test.lua @@ -32,6 +32,7 @@ return { require("neotest").setup({ output = { open_on_run = true }, + status = { virtual_text = true }, icons = require("jamin.resources").icons.test, adapters = { has_go and go or nil, diff --git a/.config/nvim/lua/jamin/plugins/treesitter.lua b/.config/nvim/lua/jamin/plugins/treesitter.lua index 71534a28..ebaed060 100644 --- a/.config/nvim/lua/jamin/plugins/treesitter.lua +++ b/.config/nvim/lua/jamin/plugins/treesitter.lua @@ -10,10 +10,6 @@ return { opts = { use_default_keymaps = false, max_join_length = 500 }, }, - ----------------------------------------------------------------------------- - -- more text objects - { "nvim-treesitter/nvim-treesitter-textobjects", lazy = true }, - ----------------------------------------------------------------------------- -- set commentstring based on treesitter node { "folke/ts-comments.nvim", event = "VeryLazy", opts = {} }, @@ -29,13 +25,11 @@ return { opts = { multiline_threshold = 1, max_lines = 6, - mode = "cursor", - -- separator = "─", }, config = function(_, opts) require("treesitter-context").setup(opts) - vim.api.nvim_set_hl(0, "TreesitterContext", { link = "Normal" }) + -- vim.api.nvim_set_hl(0, "TreesitterContext", { link = "Normal" }) vim.api.nvim_set_hl(0, "TreesitterContextLineNumber", { link = "Normal" }) vim.api.nvim_set_hl(0, "TreesitterContextSeparator", { link = "Folded" }) end, @@ -58,6 +52,9 @@ return { -- syntax tree parser/highlighter engine { "nvim-treesitter/nvim-treesitter", + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", -- more text objects + }, build = ":TSUpdate", cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" }, event = "BufReadPost", @@ -89,7 +86,6 @@ return { return { ensure_installed = res.treesitter_parsers, indent = { enable = true }, - autotag = { enable = true }, query_linter = { enable = true }, highlight = { @@ -185,13 +181,7 @@ return { config = function(_, opts) require("nvim-treesitter.configs").setup(opts) - vim.schedule( - function() - require("lazy").load({ - plugins = { "nvim-treesitter-textobjects", "nvim-treesitter-context" }, - }) - end - ) + vim.schedule(function() require("lazy").load({ plugins = { "nvim-treesitter-context" } }) end) end, }, } diff --git a/.config/nvim/lua/jamin/plugins/ui.lua b/.config/nvim/lua/jamin/plugins/ui.lua index c260442a..3e20a173 100644 --- a/.config/nvim/lua/jamin/plugins/ui.lua +++ b/.config/nvim/lua/jamin/plugins/ui.lua @@ -172,11 +172,11 @@ return { desc = "LSP definitions/references/etc (trouble)", }, { - "]d", + "]x", function() - if require("trouble").is_open({ mode = "diagnostics" }) then + if require("trouble").is_open({}) then ---@diagnostic disable-next-line: missing-parameter - require("trouble").next({ mode = "diagnostics", jump = true }) + require("trouble").next({ jump = true }) else vim.diagnostic.goto_next({ float = true }) end @@ -184,11 +184,11 @@ return { desc = "Next diagnostic (trouble)", }, { - "[d", + "[x", function() - if require("trouble").is_open({ mode = "diagnostics" }) then + if require("trouble").is_open({}) then ---@diagnostic disable-next-line: missing-parameter - require("trouble").prev({ mode = "diagnostics", jump = true }) + require("trouble").prev({ jump = true }) else vim.diagnostic.goto_prev({ float = true }) end diff --git a/.config/nvim/lua/jamin/resources.lua b/.config/nvim/lua/jamin/resources.lua index 192e8539..df65eb1b 100644 --- a/.config/nvim/lua/jamin/resources.lua +++ b/.config/nvim/lua/jamin/resources.lua @@ -25,6 +25,7 @@ M.filetypes = { "floggraph", "fugitive", "fugitiveblame", + "gitsigns.blame", "harpoon", "help", "lazy", @@ -123,7 +124,9 @@ M.mason_packages = { M.treesitter_parsers = { "astro", "bash", + "comment", "css", + -- "csv", "diff", "dockerfile", "git_rebase", @@ -134,13 +137,14 @@ M.treesitter_parsers = { -- "gowork", "graphql", "html", - "http", + -- "http", -- "ini", "javascript", "jsdoc", "json", "json5", "jsonc", + -- "jq", -- "latex", "lua", "luadoc", diff --git a/.config/nvim/queries/gitcommit/highlights.scm b/.config/nvim/queries/gitcommit/highlights.scm new file mode 100644 index 00000000..fdc5247a --- /dev/null +++ b/.config/nvim/queries/gitcommit/highlights.scm @@ -0,0 +1,10 @@ +; extends +; https://github.com/gbprod/tree-sitter-gitcommit/pull/68 + +((subject) @comment.warning + (#vim-match? @comment.warning ".\{50,}") + (#offset! @comment.warning 0 50 0 0)) + +((message_line) @comment.warning + (#vim-match? @comment.warning ".\{72,}") + (#offset! @comment.warning 0 72 0 0)) diff --git a/.config/waybar/config b/.config/waybar/config index cf3883d5..4491a73b 100644 --- a/.config/waybar/config +++ b/.config/waybar/config @@ -231,7 +231,7 @@ "tooltip": false, "format-alt-click": "click-right", "exec": "music info", - "exec-if": "command -v music >/dev/null 2>&1", + "exec-if": "command -v music >/dev/null 2>&1 && [ \"$(music info)\" != \"Nothing Playing\" ]", "on-click": "music toggle", "on-click-middle": "music rofi" diff --git a/.dotfiles/shell/exports.sh b/.dotfiles/shell/exports.sh index 26a5bd14..d41ca39e 100644 --- a/.dotfiles/shell/exports.sh +++ b/.dotfiles/shell/exports.sh @@ -210,13 +210,14 @@ if supports fff; then fi # https://github.com/meiji163/gh-notify -export GH_NOTIFY_MARK_READ_KEY="alt-backspace" -export GH_NOTIFY_MARK_ALL_READ_KEY="ctrl-delete" -export GH_NOTIFY_OPEN_BROWSER_KEY="ctrl-o" export GH_NOTIFY_COMMENT_KEY="alt-c" export GH_NOTIFY_VIEW_DIFF_KEY="alt-d" export GH_NOTIFY_VIEW_PATCH_KEY="alt-D" +export GH_NOTIFY_TOGGLE_PREVIEW_KEY="alt-p" export GH_NOTIFY_RESIZE_PREVIEW_KEY="alt-P" +export GH_NOTIFY_MARK_READ_KEY="alt-x" +export GH_NOTIFY_MARK_ALL_READ_KEY="alt-backspace" +export GH_NOTIFY_OPEN_BROWSER_KEY="ctrl-o" # my tools {{{1 supports matpat && export MATPAT_OPEN_CMD="$BROWSER"