Skip to content

Commit

Permalink
fix(nvim, i3): cmp-git works in gh's files, plus more
Browse files Browse the repository at this point in the history
- 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)",
       },
+      {
+        "<leader>hB",
+        function() require("gitsigns").blame() end,
+        desc = "Git blame buffer (gitsigns)",
+      },
       {
         "<leader>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" }, "<leader>P" },
           MkdnToggleToDo = { { "n", "v" }, "<leader>m<Tab>" },
           MkdnUpdateNumbering = { "n", "<leader>mn" },
-          MkdnMoveSource = { "n", "<leader>mR" },
+          MkdnMoveSource = { "n", "<leader>mrn" },
           MkdnTableNewRowBelow = { "n", "<leader>mir" },
           MkdnTableNewRowAbove = { "n", "<leader>miR" },
           MkdnTableNewColAfter = { "n", "<leader>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
+; gbprod/tree-sitter-gitcommit#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"
  • Loading branch information
benelan committed Jul 29, 2024
1 parent 524860b commit 23b69f8
Show file tree
Hide file tree
Showing 16 changed files with 147 additions and 50 deletions.
39 changes: 39 additions & 0 deletions .Xresources
Original file line number Diff line number Diff line change
@@ -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
7 changes: 3 additions & 4 deletions .config/i3/config
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
#
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions .config/nvim/lazy-lock.json
Original file line number Diff line number Diff line change
@@ -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" },
Expand All @@ -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" },
Expand All @@ -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" },
Expand All @@ -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" }
}
3 changes: 2 additions & 1 deletion .config/nvim/lua/jamin/lsp_servers/tsserver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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]
},
},
},
Expand Down
45 changes: 37 additions & 8 deletions .config/nvim/lua/jamin/plugins/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},

-----------------------------------------------------------------------------
Expand Down Expand Up @@ -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
Expand All @@ -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,
},
},
Expand Down
4 changes: 4 additions & 0 deletions .config/nvim/lua/jamin/plugins/debug.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions .config/nvim/lua/jamin/plugins/git.lua
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ return {
function() require("gitsigns").blame_line({ full = true }) end,
desc = "Git blame line (gitsigns)",
},
{
"<leader>hB",
function() require("gitsigns").blame() end,
desc = "Git blame buffer (gitsigns)",
},
{
"<leader>htb",
function() require("gitsigns").toggle_current_line_blame() end,
Expand Down
17 changes: 15 additions & 2 deletions .config/nvim/lua/jamin/plugins/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion .config/nvim/lua/jamin/plugins/notes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -45,7 +46,7 @@ return {
MkdnCreateLinkFromClipboard = { { "n", "v" }, "<leader>P" },
MkdnToggleToDo = { { "n", "v" }, "<leader>m<Tab>" },
MkdnUpdateNumbering = { "n", "<leader>mn" },
MkdnMoveSource = { "n", "<leader>mR" },
MkdnMoveSource = { "n", "<leader>mrn" },
MkdnTableNewRowBelow = { "n", "<leader>mir" },
MkdnTableNewRowAbove = { "n", "<leader>miR" },
MkdnTableNewColAfter = { "n", "<leader>mic" },
Expand Down
1 change: 1 addition & 0 deletions .config/nvim/lua/jamin/plugins/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 5 additions & 15 deletions .config/nvim/lua/jamin/plugins/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {} },
Expand All @@ -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,
Expand All @@ -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",
Expand Down Expand Up @@ -89,7 +86,6 @@ return {
return {
ensure_installed = res.treesitter_parsers,
indent = { enable = true },
autotag = { enable = true },
query_linter = { enable = true },

highlight = {
Expand Down Expand Up @@ -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,
},
}
12 changes: 6 additions & 6 deletions .config/nvim/lua/jamin/plugins/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,23 @@ 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
end,
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
Expand Down
Loading

0 comments on commit 23b69f8

Please sign in to comment.