diff --git a/.config/nix/modules/ghostty.nix b/.config/nix/modules/ghostty.nix index aafacdb..62b4aff 100644 --- a/.config/nix/modules/ghostty.nix +++ b/.config/nix/modules/ghostty.nix @@ -19,6 +19,8 @@ in mouse-hide-while-typing = true macos-titlebar-style = tabs unfocused-split-opacity = 1 + window-height = 50 + window-width = 178 window-padding-x = 0 window-padding-y = 0 window-padding-balance = true diff --git a/.config/nix/modules/shell.nix b/.config/nix/modules/shell.nix index df4526f..7223326 100644 --- a/.config/nix/modules/shell.nix +++ b/.config/nix/modules/shell.nix @@ -86,7 +86,9 @@ shellAbbrs = { a = "ambr"; b = "bun"; - d = "delta"; + d = "docker"; + de = "delta"; + dc = "docker compose"; df = "h git"; g = "git"; i = "iex"; diff --git a/.config/nvim/TODO.md b/.config/nvim/TODO.md index 1bcf929..cc8bfb2 100644 --- a/.config/nvim/TODO.md +++ b/.config/nvim/TODO.md @@ -1,6 +1,6 @@ # TODO -lazy 2cf3d23 +lazy d1529f6 - switch from cmp to blink - dressing to snacks.input + fzf-lua? @@ -8,7 +8,6 @@ lazy 2cf3d23 ## Issues -- conform nix format - gf in terminal does not focus file (opens in background) - neotest output does not auto-scroll in edgy diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index d9d81d2..c1319bc 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,45 +1,41 @@ { - "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, - "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "conform.nvim": { "branch": "master", "commit": "339b3e4519ec49312d34fcfa275aa15bfaa67025" }, + "blink.cmp": { "branch": "main", "commit": "1cc3b1a908fbcfd15451c4772759549724f38524" }, + "conform.nvim": { "branch": "master", "commit": "70019124aa4f2e6838be9fbd2007f6d13b27a96d" }, "dressing.nvim": { "branch": "master", "commit": "3a45525bb182730fe462325c99395529308f431e" }, "edgy.nvim": { "branch": "main", "commit": "7e8dedc39abebe40c289b8012cc89b11c69aa7a0" }, "flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" }, "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, - "gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" }, - "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }, + "gitsigns.nvim": { "branch": "main", "commit": "2eaa30537365f6889c850bd46ef6f18ddf8fac70" }, + "lazy.nvim": { "branch": "main", "commit": "d8f26efd456190241afd1b0f5235fe6fdba13d4a" }, "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, "lush.nvim": { "branch": "main", "commit": "45a79ec4acb5af783a6a29673a999ce37f00497e" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "2daa8921b7afdcfa47419a21ea343c3df6d74fa0" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "97d9f1d3ad205dece6bcafd1d71cf1507608f3c7" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "mini.nvim": { "branch": "main", "commit": "7b210cc5207e36f562f6c1e83200d5dfc0a4451d" }, - "neo-tree.nvim": { "branch": "main", "commit": "2d4094b885ea642f590997e92ffe6415fdc60185" }, - "neotest": { "branch": "master", "commit": "6d3d22cdad49999ef774ebe1bc250a4994038964" }, + "mini.nvim": { "branch": "main", "commit": "bac6c8bb77fe0a872719ea43c39e35c7c695f05e" }, + "neo-tree.nvim": { "branch": "main", "commit": "e6645ecfcba3e064446a6def1c10d788c9873f51" }, + "neotest": { "branch": "master", "commit": "d66cf4e05a116957f0d3a7755a24291c7d1e1f72" }, "neotest-elixir": { "branch": "master", "commit": "c5067bcc3ec6a0bba7b5694fa15aeb17f16aeb3c" }, "neotest-vitest": { "branch": "main", "commit": "3e338b77700853f725856c37ff5a3cf9295bffae" }, "noice.nvim": { "branch": "main", "commit": "eaed6cc9c06aa2013b5255349e4f26a6b17ab70f" }, "nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" }, - "nvim-cmp": { "branch": "main", "commit": "b555203ce4bd7ff6192e759af3362f9d217e8c89" }, - "nvim-dap": { "branch": "master", "commit": "a6070b4e9e9a8ff1bc513c3748eff27080b0f44a" }, - "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" }, - "nvim-dap-virtual-text": { "branch": "master", "commit": "76d80c3d171224315b61c006502a1e30c213a9ab" }, + "nvim-dap": { "branch": "master", "commit": "b768c8d0ce6da614ac17ed097bf2d94e35fe1a58" }, + "nvim-dap-ui": { "branch": "master", "commit": "e94d98649dccb6a3884b66aabc2e07beb279e535" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "df66808cd78b5a97576bbaeee95ed5ca385a9750" }, "nvim-lastplace": { "branch": "main", "commit": "0bb6103c506315044872e0f84b1f736c4172bb20" }, - "nvim-lspconfig": { "branch": "master", "commit": "b54abeb8b90af1cb4592ce937ee95ed8cb457801" }, + "nvim-lspconfig": { "branch": "master", "commit": "88157521e890fe7fdf18bee22438875edd6300a6" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, "nvim-scrollbar": { "branch": "main", "commit": "6994eb9f73d5fdc36ee2c8717940e8c853e51a49" }, - "nvim-snippets": { "branch": "main", "commit": "56b4052f71220144689caaa2e5b66222ba5661eb" }, - "nvim-treesitter": { "branch": "master", "commit": "caba7ef3556079dec03407bcbb290ddc688ea06e" }, - "nvim-treesitter-context": { "branch": "master", "commit": "2bcf700b59bc92850ca83a1c02e86ba832e0fae0" }, + "nvim-treesitter": { "branch": "master", "commit": "8ca76960ae75e0a3bb231402558eb50e79433161" }, + "nvim-treesitter-context": { "branch": "master", "commit": "d0dd7ce5a9d0be1f28086e818e52fdc5c78975df" }, "nvim-ts-autotag": { "branch": "main", "commit": "1cca23c9da708047922d3895a71032bc0449c52d" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, - "snacks.nvim": { "branch": "main", "commit": "98df370703b3c47a297988f3e55ce99628639590" }, + "snacks.nvim": { "branch": "main", "commit": "14e89401da348f5d14509fca164fb7bcec83e597" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" }, - "telescope.nvim": { "branch": "master", "commit": "2eca9ba22002184ac05eddbe47a7fe2d5a384dfc" }, + "telescope.nvim": { "branch": "master", "commit": "415af52339215926d705cccc08145f3782c4d132" }, "trouble.nvim": { "branch": "main", "commit": "46cf952fc115f4c2b98d4e208ed1e2dce08c9bf6" }, "ts-comments.nvim": { "branch": "main", "commit": "872dcfa0418f4a33b7437fb4d9f4e89f2f000d74" }, "twoslash-queries.nvim": { "branch": "main", "commit": "b92622c7b71eceefabd02eef24236041069904b1" }, "vim-repeat": { "branch": "master", "commit": "65846025c15494983dafe5e3b46c8f88ab2e9635" }, - "which-key.nvim": { "branch": "main", "commit": "8ab96b38a2530eacba5be717f52e04601eb59326" } + "which-key.nvim": { "branch": "main", "commit": "1f8d414f61e0b05958c342df9b6a4c89ce268766" } } diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 24bd31a..be3fb9f 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -5,6 +5,131 @@ local have_make = vim.fn.executable("make") == 1 local have_cmake = vim.fn.executable("cmake") == 1 return { + -- blink.cmp (https://github.com/saghen/blink.cmp) + { + "saghen/blink.cmp", + event = "InsertEnter", + version = not vim.g.lazyvim_blink_main and "*", + build = vim.g.lazyvim_blink_main and "cargo build --release", + opts_extend = { + "sources.completion.enabled_providers", + "sources.compat", + "sources.default", + }, + dependencies = { + "rafamadriz/friendly-snippets", + -- add blink.compat to dependencies + { + "saghen/blink.compat", + optional = true, -- make optional so it's only enabled if any extras need it + opts = {}, + version = not vim.g.lazyvim_blink_main and "*", + }, + }, + opts = { + appearance = { + -- 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 = false, + -- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- adjusts spacing to ensure icons are aligned + nerd_font_variant = "mono", + }, + completion = { + accept = { + -- experimental auto-brackets support + auto_brackets = { + enabled = true, + }, + }, + documentation = { + auto_show = true, + auto_show_delay_ms = 200, + }, + ghost_text = { + enabled = vim.g.ai_cmp, + }, + menu = { + draw = { + treesitter = { "lsp" }, + }, + }, + }, + keymap = { + [""] = { "show", "show_documentation", "hide_documentation" }, + [""] = { "accept", "fallback" }, + [""] = { "select_prev", "fallback" }, + [""] = { "select_next", "fallback" }, + [""] = { "scroll_documentation_up", "fallback" }, + [""] = { "scroll_documentation_down", "fallback" }, + [""] = { "snippet_forward", "fallback" }, + [""] = { "snippet_backward", "fallback" }, + }, + snippets = { + expand = function(snippet, _) + return require("util.cmp").expand(snippet) + end, + }, + -- experimental signature help support + signature = { enabled = true }, + sources = { + -- adding any nvim-cmp sources here will enable them + -- with blink.compat + compat = {}, + default = { "lsp", "path", "snippets", "buffer" }, + cmdline = {}, + }, + }, + config = function(_, opts) + -- setup compat sources + local enabled = opts.sources.default + for _, source in ipairs(opts.sources.compat or {}) do + opts.sources.providers[source] = vim.tbl_deep_extend( + "force", + { name = source, module = "blink.compat.source" }, + opts.sources.providers[source] or {} + ) + if type(enabled) == "table" and not vim.tbl_contains(enabled, source) then + table.insert(enabled, source) + end + end + + -- Unset custom prop to pass blink.cmp validation + opts.sources.compat = nil + + -- check if we need to override symbol kinds + for _, provider in pairs(opts.sources.providers or {}) do + if provider.kind then + local CompletionItemKind = require("blink.cmp.types").CompletionItemKind + local kind_idx = #CompletionItemKind + 1 + + CompletionItemKind[kind_idx] = provider.kind + ---@diagnostic disable-next-line: no-unknown + CompletionItemKind[provider.kind] = kind_idx + + local transform_items = provider.transform_items + provider.transform_items = function(ctx, items) + items = transform_items and transform_items(ctx, items) or items + for _, item in ipairs(items) do + item.kind = kind_idx or item.kind + end + return items + end + + -- Unset custom prop to pass blink.cmp validation + provider.kind = nil + end + end + + opts.appearance.kind_icons = vim.tbl_extend("keep", { + Color = "██", -- Use block instead of icon for color items to make swatches more usable + }, icons.kinds) + + require("blink.cmp").setup(opts) + end, + }, + -- conform.nvim (https://github.com/stevearc/conform.nvim) { "stevearc/conform.nvim", @@ -57,6 +182,7 @@ return { json = { "biome" }, jsonc = { "biome" }, lua = { "stylua" }, + nix = { "nixfmt" }, sh = { "shfmt" }, svelte = { "biome" }, typescript = { "biome" }, @@ -834,11 +960,10 @@ return { }, }, lsp = { - -- override markdown rendering so that **cmp** and other plugins use **Treesitter** + -- override markdown rendering so plugins use **Treesitter** override = { ["vim.lsp.util.convert_input_to_markdown_lines"] = true, ["vim.lsp.util.stylize_markdown"] = true, - ["cmp.entry.get_documentation"] = true, }, }, presets = { @@ -875,116 +1000,6 @@ return { end, }, - -- nvim-cmp (https://github.com/hrsh7th/nvim-cmp) - { - "hrsh7th/nvim-cmp", - version = false, -- last release is way too old - event = "InsertEnter", - dependencies = { - -- https://github.com/hrsh7th/cmp-nvim-lsp - "hrsh7th/cmp-nvim-lsp", - -- https://github.com/hrsh7th/cmp-buffer - "hrsh7th/cmp-buffer", - -- https://github.com/hrsh7th/cmp-path - "hrsh7th/cmp-path", - -- https://github.com/garymjr/nvim-snippets - { - "garymjr/nvim-snippets", - opts = { - friendly_snippets = true, - }, - dependencies = { "rafamadriz/friendly-snippets" }, - }, - }, - keys = { - { - "", - function() - return vim.snippet.active({ direction = 1 }) and "lua vim.snippet.jump(1)" or "" - end, - expr = true, - silent = true, - mode = { "i", "s" }, - }, - { - "", - function() - return vim.snippet.active({ direction = -1 }) and "lua vim.snippet.jump(-1)" or "" - end, - expr = true, - silent = true, - mode = { "i", "s" }, - }, - }, - opts = function() - vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) - local cmp = require("cmp") - local defaults = require("cmp.config.default")() - local auto_select = true - return { - auto_brackets = {}, -- configure any filetype to auto add brackets - completion = { - completeopt = "menu,menuone,noinsert" .. (auto_select and "" or ",noselect"), - }, - experimental = { - ghost_text = { - hl_group = "CmpGhostText", - }, - }, - formatting = { - format = function(_, item) - if icons.kinds[item.kind] then - item.kind = icons.kinds[item.kind] .. item.kind - end - - local widths = { - abbr = vim.g.cmp_widths and vim.g.cmp_widths.abbr or 40, - menu = vim.g.cmp_widths and vim.g.cmp_widths.menu or 30, - } - - for key, width in pairs(widths) do - if item[key] and vim.fn.strdisplaywidth(item[key]) > width then - item[key] = vim.fn.strcharpart(item[key], 0, width - 1) .. "…" - end - end - - return item - end, - }, - main = "util.cmp-extra", - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - -- [""] = require("util.cmpx").confirm({ select = auto_select }), - [""] = require("util.cmpx").confirm({ select = auto_select }), - [""] = require("util.cmpx").confirm({ select = true }), - [""] = require("util.cmpx").confirm({ behavior = cmp.ConfirmBehavior.Replace }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - [""] = function(fallback) - cmp.abort() - fallback() - end, - }), - preselect = auto_select and cmp.PreselectMode.Item or cmp.PreselectMode.None, - snippet = { - expand = function(item) - return require("util.cmpx").expand(item.body) - end, - }, - sorting = defaults.sorting, - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "path" }, - { name = "snippets" }, - }, { - { name = "buffer" }, - }), - } - end, - }, - -- nvim-dap (https://github.com/mfussenegger/nvim-dap) { "mfussenegger/nvim-dap", @@ -1316,9 +1331,7 @@ return { }, }, }, - rnix = { - settings = {}, - }, + nil_ls = {}, volar = { init_options = { vue = { @@ -1438,8 +1451,9 @@ return { -- Specify * to use this function as a fallback for any server -- ["*"] = function(server, opts) end, vtsls = function(_, opts) - require("util.lsp").on_attach(function(client, buffer) - client.commands["_typescript.moveToFileRefactoring"] = function(command, ctx) + require("util.lsp").on_attach(function(client, _buf) + client.commands["_typescript.moveToFileRefactoring"] = function(command, _ctx) + ---@diagnostic disable-next-line: deprecated local action, uri, range = unpack(command.arguments) local function move(newf) @@ -1557,12 +1571,12 @@ return { vim.diagnostic.config(vim.deepcopy(opts.diagnostics)) local servers = opts.servers - local has_cmp, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") + local has_blink, blink = pcall(require, "blink.cmp") local capabilities = vim.tbl_deep_extend( "force", {}, vim.lsp.protocol.make_client_capabilities(), - has_cmp and cmp_nvim_lsp.default_capabilities() or {}, + has_blink and blink.get_lsp_capabilities() or {}, opts.capabilities or {} ) @@ -1776,7 +1790,6 @@ return { opts = function() -- Terminal Mappings local function term_nav(dir) - ---@param self snacks.terminal return function(self) return self:is_floating() and "" or vim.schedule(function() @@ -1785,7 +1798,6 @@ return { end end - ---@type snacks.Config return { bigfile = { enabled = true }, dim = { diff --git a/.config/nvim/lua/util/cmpx.lua b/.config/nvim/lua/util/cmpx.lua deleted file mode 100644 index 688b619..0000000 --- a/.config/nvim/lua/util/cmpx.lua +++ /dev/null @@ -1,153 +0,0 @@ ----@class util.cmpx -local M = {} - ----@alias Placeholder {n:number, text:string} - ----@param snippet string ----@param fn fun(placeholder:Placeholder):string ----@return string -function M.snippet_replace(snippet, fn) - return snippet:gsub("%$%b{}", function(m) - local n, name = m:match("^%${(%d+):(.+)}$") - return n and fn({ n = n, text = name }) or m - end) or snippet -end - --- This function resolves nested placeholders in a snippet. ----@param snippet string ----@return string -function M.snippet_preview(snippet) - local ok, parsed = pcall(function() - return vim.lsp._snippet_grammar.parse(snippet) - end) - return ok and tostring(parsed) - or M.snippet_replace(snippet, function(placeholder) - return M.snippet_preview(placeholder.text) - end):gsub("%$0", "") -end - --- This function replaces nested placeholders in a snippet with LSP placeholders. -function M.snippet_fix(snippet) - local texts = {} ---@type table - return M.snippet_replace(snippet, function(placeholder) - texts[placeholder.n] = texts[placeholder.n] or M.snippet_preview(placeholder.text) - return "${" .. placeholder.n .. ":" .. texts[placeholder.n] .. "}" - end) -end - ----@param entry cmp.Entry -function M.auto_brackets(entry) - local cmp = require("cmp") - local Kind = cmp.lsp.CompletionItemKind - local item = entry:get_completion_item() - if vim.tbl_contains({ Kind.Function, Kind.Method }, item.kind) then - local cursor = vim.api.nvim_win_get_cursor(0) - local prev_char = vim.api.nvim_buf_get_text(0, cursor[1] - 1, cursor[2], cursor[1] - 1, cursor[2] + 1, {})[1] - if prev_char ~= "(" and prev_char ~= ")" then - local keys = vim.api.nvim_replace_termcodes("()", false, false, true) - vim.api.nvim_feedkeys(keys, "i", true) - end - end -end - --- This function adds missing documentation to snippets. --- The documentation is a preview of the snippet. ----@param window cmp.CustomEntriesView|cmp.NativeEntriesView -function M.add_missing_snippet_docs(window) - local cmp = require("cmp") - local Kind = cmp.lsp.CompletionItemKind - local entries = window:get_entries() - for _, entry in ipairs(entries) do - if entry:get_kind() == Kind.Snippet then - local item = entry:get_completion_item() - if not item.documentation and item.insertText then - item.documentation = { - kind = cmp.lsp.MarkupKind.Markdown, - value = string.format("```%s\n%s\n```", vim.bo.filetype, M.snippet_preview(item.insertText)), - } - end - end - end -end - --- This is a better implementation of `cmp.confirm`: --- * check if the completion menu is visible without waiting for running sources --- * create an undo point before confirming --- This function is both faster and more reliable. ----@param opts? {select: boolean, behavior: cmp.ConfirmBehavior} -function M.confirm(opts) - local cmp = require("cmp") - opts = vim.tbl_extend("force", { - select = true, - behavior = cmp.ConfirmBehavior.Insert, - }, opts or {}) - return function(fallback) - if cmp.core.view:visible() or vim.fn.pumvisible() == 1 then - require("util.init").create_undo() - if cmp.confirm(opts) then - return - end - end - return fallback() - end -end - -function M.expand(snippet) - -- Native sessions don't support nested snippet sessions. - -- Always use the top-level session. - -- Otherwise, when on the first placeholder and selecting a new completion, - -- the nested session will be used instead of the top-level session. - -- See: https://github.com/LazyVim/LazyVim/issues/3199 - local session = vim.snippet.active() and vim.snippet._session or nil - - local ok, err = pcall(vim.snippet.expand, snippet) - if not ok then - local fixed = M.snippet_fix(snippet) - ok = pcall(vim.snippet.expand, fixed) - - local msg = ok and "Failed to parse snippet,\nbut was able to fix it automatically." - or ("Failed to parse snippet.\n" .. err) - - require("util.init")[ok and "warn" or "error"]( - ([[%s -```%s -%s -```]]):format(msg, vim.bo.filetype, snippet), - { title = "vim.snippet" } - ) - end - - -- Restore top-level session when needed - if session then - vim.snippet._session = session - end -end - ----@param opts cmp.ConfigSchema | {auto_brackets?: string[]} -function M.setup(opts) - for _, source in ipairs(opts.sources) do - source.group_index = source.group_index or 1 - end - - local parse = require("cmp.utils.snippet").parse - require("cmp.utils.snippet").parse = function(input) - local ok, ret = pcall(parse, input) - if ok then - return ret - end - return M.snippet_preview(input) - end - - local cmp = require("cmp") - cmp.setup(opts) - cmp.event:on("confirm_done", function(event) - if vim.tbl_contains(opts.auto_brackets or {}, vim.bo.filetype) then - M.auto_brackets(event.entry) - end - end) - cmp.event:on("menu_opened", function(event) - M.add_missing_snippet_docs(event.window) - end) -end - -return M diff --git a/.config/nvim/lua/util/init.lua b/.config/nvim/lua/util/init.lua index 3c02952..f299c1c 100644 --- a/.config/nvim/lua/util/init.lua +++ b/.config/nvim/lua/util/init.lua @@ -122,10 +122,8 @@ end -- It will also set `silent` to true by default. function M.safe_keymap_set(mode, lhs, rhs, opts) local keys = require("lazy.core.handler").handlers.keys - ---@cast keys LazyKeysHandler local modes = type(mode) == "string" and { mode } or mode - ---@param m string modes = vim.tbl_filter(function(m) return not (keys.have and keys:have(lhs, m)) end, modes) @@ -273,8 +271,6 @@ M.kind_filter = { }, } ----@param buf? number ----@return string[]? function M.get_kind_filter(buf) buf = (buf == nil or buf == 0) and vim.api.nvim_get_current_buf() or buf local ft = vim.bo[buf].filetype @@ -287,7 +283,6 @@ function M.get_kind_filter(buf) if type(M.kind_filter[ft]) == "table" then return M.kind_filter[ft] end - ---@diagnostic disable-next-line: return-type-mismatch return type(M.kind_filter) == "table" and type(M.kind_filter.default) == "table" and M.kind_filter.default or nil end diff --git a/.config/nvim/lua/util/keymaps.lua b/.config/nvim/lua/util/keymaps.lua index 87eec75..2a2ecda 100644 --- a/.config/nvim/lua/util/keymaps.lua +++ b/.config/nvim/lua/util/keymaps.lua @@ -1,12 +1,7 @@ local M = {} ----@type LazyKeysLspSpec[]|nil M._keys = nil ----@alias LazyKeysLspSpec LazyKeysSpec|{has?:string|string[], cond?:fun():boolean} ----@alias LazyKeysLsp LazyKeys|{has?:string|string[], cond?:fun():boolean} - ----@return LazyKeysLspSpec[] function M.get() if M._keys then return M._keys @@ -63,7 +58,6 @@ function M.has(buffer, method) return false end ----@return LazyKeysLsp[] function M.resolve(buffer) local Keys = require("lazy.core.handler.keys") if not Keys.resolve then diff --git a/.config/nvim/lua/util/lsp.lua b/.config/nvim/lua/util/lsp.lua index 6b26741..f765e3c 100644 --- a/.config/nvim/lua/util/lsp.lua +++ b/.config/nvim/lua/util/lsp.lua @@ -1,18 +1,14 @@ ---@class util.lsp local M = {} ----@alias lsp.Client.filter {id?: number, bufnr?: number, name?: string, method?: string, filter?:fun(client: lsp.Client):boolean} - ----@param opts? lsp.Client.filter function M.get_clients(opts) - local ret = {} ---@type vim.lsp.Client[] + local ret = {} if vim.lsp.get_clients then ret = vim.lsp.get_clients(opts) else ---@diagnostic disable-next-line: deprecated ret = vim.lsp.get_active_clients(opts) if opts and opts.method then - ---@param client vim.lsp.Client ret = vim.tbl_filter(function(client) return client.supports_method(opts.method, { bufnr = opts.bufnr }) end, ret) @@ -21,8 +17,6 @@ function M.get_clients(opts) return opts and opts.filter and vim.tbl_filter(opts.filter, ret) or ret end ----@param on_attach fun(client:vim.lsp.Client, buffer) ----@param name? string function M.on_attach(on_attach, name) return vim.api.nvim_create_autocmd("LspAttach", { callback = function(args) @@ -35,7 +29,6 @@ function M.on_attach(on_attach, name) }) end ----@type table>> M._supports_method = {} function M.setup() @@ -58,7 +51,6 @@ function M.setup() M.on_dynamic_capability(M._check_methods) end ----@param client vim.lsp.Client function M._check_methods(client, buffer) -- don't trigger on invalid buffers if not vim.api.nvim_buf_is_valid(buffer) then @@ -86,8 +78,6 @@ function M._check_methods(client, buffer) end end ----@param fn fun(client:vim.lsp.Client, buffer):boolean? ----@param opts? {group?: integer} function M.on_dynamic_capability(fn, opts) return vim.api.nvim_create_autocmd("User", { pattern = "LspDynamicCapability", @@ -102,8 +92,6 @@ function M.on_dynamic_capability(fn, opts) }) end ----@param method string ----@param fn fun(client:vim.lsp.Client, buffer) function M.on_supports_method(method, fn) M._supports_method[method] = M._supports_method[method] or setmetatable({}, { __mode = "k" }) return vim.api.nvim_create_autocmd("User", { @@ -118,13 +106,11 @@ function M.on_supports_method(method, fn) }) end ----@return _.lspconfig.options function M.get_config(server) local configs = require("lspconfig.configs") return rawget(configs, server) end ----@return {default_config:lspconfig.Config} function M.get_raw_config(server) local ok, ret = pcall(require, "lspconfig.configs." .. server) if ok then @@ -151,13 +137,10 @@ function M.disable(server, cond) end) end ----@param opts? LazyFormatter| {filter?: (string|lsp.Client.filter)} function M.formatter(opts) opts = opts or {} local filter = opts.filter or {} filter = type(filter) == "string" and { name = filter } or filter - ---@cast filter lsp.Client.filter - ---@type LazyFormatter local ret = { name = "LSP", primary = true, @@ -167,12 +150,10 @@ function M.formatter(opts) end, sources = function(buf) local clients = M.get_clients(require("util.init").merge({}, filter, { bufnr = buf })) - ---@param client vim.lsp.Client local ret = vim.tbl_filter(function(client) return client.supports_method("textDocument/formatting") or client.supports_method("textDocument/rangeFormatting") end, clients) - ---@param client vim.lsp.Client return vim.tbl_map(function(client) return client.name end, ret) @@ -181,9 +162,6 @@ function M.formatter(opts) return require("util.init").merge(ret, opts) --[[@as LazyFormatter]] end ----@alias lsp.Client.format {timeout_ms?: number, format_options?: table} | lsp.Client.filter - ----@param opts? lsp.Client.format function M.format(opts) opts = vim.tbl_deep_extend( "force", @@ -217,11 +195,6 @@ M.action = setmetatable({}, { end, }) ----@class LspCommand: lsp.ExecuteCommandParams ----@field open? boolean ----@field handler? lsp.Handler - ----@param opts LspCommand function M.execute(opts) local params = { command = opts.command,