From fa689ac58023613f34e297d9eb15e03f4bc7d2c2 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 7 May 2026 20:11:53 -0400 Subject: [PATCH] add supermaven (opt-in only) --- .gitignore | 1 + fnl/plugins/init.fnl | 20 +++++++++++++++++--- fnl/supermaven-blink.fnl | 38 ++++++++++++++++++++++++++++++++++++++ lazy-lock.json | 1 + 4 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 fnl/supermaven-blink.fnl diff --git a/.gitignore b/.gitignore index 5962235..786c137 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ undodir lua/config/ lua/plugins/ lua/lisp-school.lua +lua/supermaven-blink.lua # Clojure/LSP tooling .clj-kondo/ diff --git a/fnl/plugins/init.fnl b/fnl/plugins/init.fnl index 6b41cfb..071a713 100644 --- a/fnl/plugins/init.fnl +++ b/fnl/plugins/init.fnl @@ -171,13 +171,27 @@ {lhs "aa" rhs "ClaudeCodeDiffAccept" :desc "Accept diff"} {lhs "ad" rhs "ClaudeCodeDiffDeny" :desc "Deny diff"}]} + ;; Supermaven - AI code completion + {repo "supermaven-inc/supermaven-nvim" + :event "InsertEnter" + :opts {:disable_inline_completion true}} + ;; blink.cmp - Fast completion engine with LSP support {repo "saghen/blink.cmp" :version "*" :event ["InsertEnter" "CmdlineEnter"] - :opts {:keymap {:preset "super-tab"} - :completion {:documentation {:auto_show true}} - :sources {:default ["lsp" "path" "buffer"]}}} + :dependencies ["supermaven-inc/supermaven-nvim"] + :opts {:keymap {:preset "super-tab" + "" [(fn [cmp] (cmp.show {:providers ["supermaven"]})) :fallback] + "" [:select_and_accept :snippet_forward :fallback] + "" [:select_and_accept :fallback]} + :completion {:trigger {:show_on_keyword false + :show_on_trigger_character false} + :list {:selection {:preselect true :auto_insert false}} + :documentation {:auto_show true}} + :sources {:default ["lsp" "supermaven" "path" "buffer"] + :providers {:supermaven {:name "Supermaven" + :module "supermaven-blink"}}}}} ;; gitsigns.nvim - Git diff signs in the sign column {repo "lewis6991/gitsigns.nvim" diff --git a/fnl/supermaven-blink.fnl b/fnl/supermaven-blink.fnl new file mode 100644 index 0000000..cd58e94 --- /dev/null +++ b/fnl/supermaven-blink.fnl @@ -0,0 +1,38 @@ +(local M {}) + +(fn M.new [] + (setmetatable {} {:__index M})) + +(fn M.get_completions [self ctx callback] + (let [(ok preview) (pcall require :supermaven-nvim.completion_preview)] + (if (not ok) + (callback {:is_incomplete_backward false :is_incomplete_forward false :items []}) + (let [inst (preview:get_inlay_instance)] + (if (or (= inst nil) (= inst.is_active false)) + (callback {:is_incomplete_backward false :is_incomplete_forward false :items []}) + (let [text inst.completion_text + lines (vim.split text "\n" {:plain true}) + raw-label (: (. lines 1) :gsub "^%s*" "") + label (if (> (length raw-label) 40) + (.. (raw-label:sub 1 20) " ... " (raw-label:sub -15)) + raw-label) + row (- (. ctx.cursor 1) 1) + col-start (math.max (- (. ctx.cursor 2) (or inst.prior_delete 0)) 0) + col-end (vim.fn.col "$") + range {:start {:line row :character col-start} + :end {:line row :character col-end}}] + (callback {:is_incomplete_backward false + :is_incomplete_forward false + :items [{:label label + :kind (. vim.lsp.protocol.CompletionItemKind :Text) + :insertTextFormat (if (> (length lines) 1) 2 1) + :textEdit {:newText text :insert range :replace range} + :documentation {:kind :markdown + :value (.. "```" vim.bo.filetype "\n" text "\n```")}}]}))))))) + +(fn M.execute [self ctx item resolve default-impl] + (pcall (fn [] (: (require :supermaven-nvim.completion_preview) :dispose_inlay))) + (default-impl) + (resolve)) + +M diff --git a/lazy-lock.json b/lazy-lock.json index 6156c4e..ea8d93b 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -12,6 +12,7 @@ "nvim-treesitter": { "branch": "main", "commit": "f8bbc3177d929dc86e272c41cc15219f0a7aa1ac" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, "snacks.nvim": { "branch": "main", "commit": "ad9ede6a9cddf16cedbd31b8932d6dcdee9b716e" }, + "supermaven-nvim": { "branch": "main", "commit": "07d20fce48a5629686aefb0a7cd4b25e33947d50" }, "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, "tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" }, "vim-repeat": { "branch": "master", "commit": "65846025c15494983dafe5e3b46c8f88ab2e9635" },