mirror of
https://github.com/isabelroses/nvim.git
synced 2025-04-09 13:29:34 +00:00
refactor: swap to blink-cmp
This commit is contained in:
parent
80f6e92882
commit
27a70ea0b3
6 changed files with 217 additions and 454 deletions
120
_sources/generated.json
generated
120
_sources/generated.json
generated
|
@ -61,106 +61,6 @@
|
|||
},
|
||||
"version": "648aca6d33ec011dc3166e7af3b38820d01a71e4"
|
||||
},
|
||||
"cmp-buffer": {
|
||||
"cargoLocks": null,
|
||||
"date": "2022-08-10",
|
||||
"extract": null,
|
||||
"name": "cmp-buffer",
|
||||
"passthru": null,
|
||||
"pinned": false,
|
||||
"src": {
|
||||
"deepClone": false,
|
||||
"fetchSubmodules": false,
|
||||
"leaveDotGit": false,
|
||||
"name": null,
|
||||
"owner": "hrsh7th",
|
||||
"repo": "cmp-buffer",
|
||||
"rev": "3022dbc9166796b644a841a02de8dd1cc1d311fa",
|
||||
"sha256": "sha256-dG4U7MtnXThoa/PD+qFtCt76MQ14V1wX8GMYcvxEnbM=",
|
||||
"type": "github"
|
||||
},
|
||||
"version": "3022dbc9166796b644a841a02de8dd1cc1d311fa"
|
||||
},
|
||||
"cmp-cmdline": {
|
||||
"cargoLocks": null,
|
||||
"date": "2024-03-22",
|
||||
"extract": null,
|
||||
"name": "cmp-cmdline",
|
||||
"passthru": null,
|
||||
"pinned": false,
|
||||
"src": {
|
||||
"deepClone": false,
|
||||
"fetchSubmodules": false,
|
||||
"leaveDotGit": false,
|
||||
"name": null,
|
||||
"owner": "hrsh7th",
|
||||
"repo": "cmp-cmdline",
|
||||
"rev": "d250c63aa13ead745e3a40f61fdd3470efde3923",
|
||||
"sha256": "sha256-iBmXp+gUSMbgfkv7c7RDQAwPq02e07wEnBETP0dWBOo=",
|
||||
"type": "github"
|
||||
},
|
||||
"version": "d250c63aa13ead745e3a40f61fdd3470efde3923"
|
||||
},
|
||||
"cmp-nvim-lsp": {
|
||||
"cargoLocks": null,
|
||||
"date": "2024-12-10",
|
||||
"extract": null,
|
||||
"name": "cmp-nvim-lsp",
|
||||
"passthru": null,
|
||||
"pinned": false,
|
||||
"src": {
|
||||
"deepClone": false,
|
||||
"fetchSubmodules": false,
|
||||
"leaveDotGit": false,
|
||||
"name": null,
|
||||
"owner": "hrsh7th",
|
||||
"repo": "cmp-nvim-lsp",
|
||||
"rev": "99290b3ec1322070bcfb9e846450a46f6efa50f0",
|
||||
"sha256": "sha256-iaihXNCF5bB5MdeoosD/kc3QtpA/QaIDZVLiLIurBSM=",
|
||||
"type": "github"
|
||||
},
|
||||
"version": "99290b3ec1322070bcfb9e846450a46f6efa50f0"
|
||||
},
|
||||
"cmp-path": {
|
||||
"cargoLocks": null,
|
||||
"date": "2022-10-03",
|
||||
"extract": null,
|
||||
"name": "cmp-path",
|
||||
"passthru": null,
|
||||
"pinned": false,
|
||||
"src": {
|
||||
"deepClone": false,
|
||||
"fetchSubmodules": false,
|
||||
"leaveDotGit": false,
|
||||
"name": null,
|
||||
"owner": "hrsh7th",
|
||||
"repo": "cmp-path",
|
||||
"rev": "91ff86cd9c29299a64f968ebb45846c485725f23",
|
||||
"sha256": "sha256-thppiiV3wjIaZnAXmsh7j3DUc6ceSCvGzviwFUnoPaI=",
|
||||
"type": "github"
|
||||
},
|
||||
"version": "91ff86cd9c29299a64f968ebb45846c485725f23"
|
||||
},
|
||||
"cmp_luasnip": {
|
||||
"cargoLocks": null,
|
||||
"date": "2024-11-04",
|
||||
"extract": null,
|
||||
"name": "cmp_luasnip",
|
||||
"passthru": null,
|
||||
"pinned": false,
|
||||
"src": {
|
||||
"deepClone": false,
|
||||
"fetchSubmodules": false,
|
||||
"leaveDotGit": false,
|
||||
"name": null,
|
||||
"owner": "saadparwaiz1",
|
||||
"repo": "cmp_luasnip",
|
||||
"rev": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90",
|
||||
"sha256": "sha256-86lKQPPyqFz8jzuLajjHMKHrYnwW6+QOcPyQEx6B+gw=",
|
||||
"type": "github"
|
||||
},
|
||||
"version": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90"
|
||||
},
|
||||
"copilot-lua": {
|
||||
"cargoLocks": null,
|
||||
"date": "2024-12-22",
|
||||
|
@ -605,26 +505,6 @@
|
|||
},
|
||||
"version": "caf85560cfcfa62ad3a4c15433db4a8f9ddf934a"
|
||||
},
|
||||
"nvim-cmp": {
|
||||
"cargoLocks": null,
|
||||
"date": "2024-12-20",
|
||||
"extract": null,
|
||||
"name": "nvim-cmp",
|
||||
"passthru": null,
|
||||
"pinned": false,
|
||||
"src": {
|
||||
"deepClone": false,
|
||||
"fetchSubmodules": false,
|
||||
"leaveDotGit": false,
|
||||
"name": null,
|
||||
"owner": "hrsh7th",
|
||||
"repo": "nvim-cmp",
|
||||
"rev": "b555203ce4bd7ff6192e759af3362f9d217e8c89",
|
||||
"sha256": "sha256-Z/Qy2ErbCa7dbjZVuJUkMmb4d24amNunNgRcbCGPfOg=",
|
||||
"type": "github"
|
||||
},
|
||||
"version": "b555203ce4bd7ff6192e759af3362f9d217e8c89"
|
||||
},
|
||||
"nvim-colorizer": {
|
||||
"cargoLocks": null,
|
||||
"date": "2024-12-28",
|
||||
|
|
72
_sources/generated.nix
generated
72
_sources/generated.nix
generated
|
@ -38,66 +38,6 @@
|
|||
};
|
||||
date = "2024-06-12";
|
||||
};
|
||||
cmp-buffer = {
|
||||
pname = "cmp-buffer";
|
||||
version = "3022dbc9166796b644a841a02de8dd1cc1d311fa";
|
||||
src = fetchFromGitHub {
|
||||
owner = "hrsh7th";
|
||||
repo = "cmp-buffer";
|
||||
rev = "3022dbc9166796b644a841a02de8dd1cc1d311fa";
|
||||
fetchSubmodules = false;
|
||||
sha256 = "sha256-dG4U7MtnXThoa/PD+qFtCt76MQ14V1wX8GMYcvxEnbM=";
|
||||
};
|
||||
date = "2022-08-10";
|
||||
};
|
||||
cmp-cmdline = {
|
||||
pname = "cmp-cmdline";
|
||||
version = "d250c63aa13ead745e3a40f61fdd3470efde3923";
|
||||
src = fetchFromGitHub {
|
||||
owner = "hrsh7th";
|
||||
repo = "cmp-cmdline";
|
||||
rev = "d250c63aa13ead745e3a40f61fdd3470efde3923";
|
||||
fetchSubmodules = false;
|
||||
sha256 = "sha256-iBmXp+gUSMbgfkv7c7RDQAwPq02e07wEnBETP0dWBOo=";
|
||||
};
|
||||
date = "2024-03-22";
|
||||
};
|
||||
cmp-nvim-lsp = {
|
||||
pname = "cmp-nvim-lsp";
|
||||
version = "99290b3ec1322070bcfb9e846450a46f6efa50f0";
|
||||
src = fetchFromGitHub {
|
||||
owner = "hrsh7th";
|
||||
repo = "cmp-nvim-lsp";
|
||||
rev = "99290b3ec1322070bcfb9e846450a46f6efa50f0";
|
||||
fetchSubmodules = false;
|
||||
sha256 = "sha256-iaihXNCF5bB5MdeoosD/kc3QtpA/QaIDZVLiLIurBSM=";
|
||||
};
|
||||
date = "2024-12-10";
|
||||
};
|
||||
cmp-path = {
|
||||
pname = "cmp-path";
|
||||
version = "91ff86cd9c29299a64f968ebb45846c485725f23";
|
||||
src = fetchFromGitHub {
|
||||
owner = "hrsh7th";
|
||||
repo = "cmp-path";
|
||||
rev = "91ff86cd9c29299a64f968ebb45846c485725f23";
|
||||
fetchSubmodules = false;
|
||||
sha256 = "sha256-thppiiV3wjIaZnAXmsh7j3DUc6ceSCvGzviwFUnoPaI=";
|
||||
};
|
||||
date = "2022-10-03";
|
||||
};
|
||||
cmp_luasnip = {
|
||||
pname = "cmp_luasnip";
|
||||
version = "98d9cb5c2c38532bd9bdb481067b20fea8f32e90";
|
||||
src = fetchFromGitHub {
|
||||
owner = "saadparwaiz1";
|
||||
repo = "cmp_luasnip";
|
||||
rev = "98d9cb5c2c38532bd9bdb481067b20fea8f32e90";
|
||||
fetchSubmodules = false;
|
||||
sha256 = "sha256-86lKQPPyqFz8jzuLajjHMKHrYnwW6+QOcPyQEx6B+gw=";
|
||||
};
|
||||
date = "2024-11-04";
|
||||
};
|
||||
copilot-lua = {
|
||||
pname = "copilot-lua";
|
||||
version = "886ee73b6d464b2b3e3e6a7ff55ce87feac423a9";
|
||||
|
@ -364,18 +304,6 @@
|
|||
};
|
||||
date = "2024-12-31";
|
||||
};
|
||||
nvim-cmp = {
|
||||
pname = "nvim-cmp";
|
||||
version = "b555203ce4bd7ff6192e759af3362f9d217e8c89";
|
||||
src = fetchFromGitHub {
|
||||
owner = "hrsh7th";
|
||||
repo = "nvim-cmp";
|
||||
rev = "b555203ce4bd7ff6192e759af3362f9d217e8c89";
|
||||
fetchSubmodules = false;
|
||||
sha256 = "sha256-Z/Qy2ErbCa7dbjZVuJUkMmb4d24amNunNgRcbCGPfOg=";
|
||||
};
|
||||
date = "2024-12-20";
|
||||
};
|
||||
nvim-colorizer = {
|
||||
pname = "nvim-colorizer";
|
||||
version = "8a65c448122fc8fac9c67b2e857b6e830a4afd0b";
|
||||
|
|
|
@ -43,7 +43,8 @@ return {
|
|||
telescope = {
|
||||
enabled = true,
|
||||
},
|
||||
cmp = true,
|
||||
cmp = false,
|
||||
blink_cmp = true,
|
||||
lsp_trouble = true,
|
||||
nvimtree = true,
|
||||
which_key = false,
|
||||
|
|
|
@ -1,176 +1,226 @@
|
|||
return {
|
||||
{ "nvim-cmp", lazy = false },
|
||||
{ "cmp-buffer", lazy = false },
|
||||
{ "cmp-cmdline", lazy = false },
|
||||
{ "cmp-nvim-lsp", lazy = false },
|
||||
{ "cmp-path", lazy = false },
|
||||
{ "cmp_luasnip", lazy = false },
|
||||
{ "lspkind.nvim", lazy = false },
|
||||
{ "none-ls.nvim", lazy = false },
|
||||
{ "lsp-status.nvim", lazy = false },
|
||||
{ "ltex-extra.nvim", lazy = false },
|
||||
{ "schemastore.nvim", lazy = false },
|
||||
{ "py_lsp.nvim", lazy = false },
|
||||
{ "typescript-tools.nvim", lazy = false },
|
||||
{ "luasnip", lazy = false },
|
||||
{
|
||||
"blink.cmp",
|
||||
event = "DeferredUIEnter",
|
||||
after = function()
|
||||
require("blink.cmp").setup({
|
||||
keymap = {
|
||||
["<c-space>"] = { "show", "show_documentation", "hide_documentation", "fallback" },
|
||||
["<C-e>"] = { "hide" },
|
||||
["<tab>"] = {
|
||||
"select_and_accept",
|
||||
"snippet_forward",
|
||||
"fallback",
|
||||
},
|
||||
["<s-tab>"] = { "snippet_backward", "fallback" },
|
||||
["<down>"] = { "select_next", "fallback" },
|
||||
["<up>"] = { "select_prev", "fallback" },
|
||||
["<c-j>"] = { "scroll_documentation_down", "fallback" },
|
||||
["<c-k>"] = { "scroll_documentation_up", "fallback" },
|
||||
},
|
||||
|
||||
appearance = {},
|
||||
|
||||
completion = {
|
||||
list = {
|
||||
cycle = {
|
||||
from_top = false,
|
||||
from_bottom = false,
|
||||
},
|
||||
},
|
||||
|
||||
menu = {
|
||||
min_width = vim.o.pumwidth,
|
||||
max_height = vim.o.pumheight,
|
||||
scrolloff = 0,
|
||||
draw = {
|
||||
align_to_component = "label", -- or 'none' to disable
|
||||
padding = 1,
|
||||
gap = 1,
|
||||
treesitter = { "buffer", "lsp" },
|
||||
columns = { { "kind_icon" }, { "label", "label_description", gap = 1 }, { "source_name" } },
|
||||
components = {
|
||||
source_name = {
|
||||
width = { max = 30 },
|
||||
text = function(ctx)
|
||||
return string.format("(%s)", ctx.source_name)
|
||||
end,
|
||||
highlight = "BlinkCmpSource",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
ghost_text = {
|
||||
enabled = true,
|
||||
},
|
||||
},
|
||||
|
||||
-- default list of enabled providers defined so that you can extend it
|
||||
-- elsewhere in your config, without redefining it, due to `opts_extend`
|
||||
sources = {
|
||||
default = { "lsp", "path", "snippets", "buffer" },
|
||||
|
||||
-- -- By default, we choose providers for the cmdline based on the current cmdtype
|
||||
-- You may disable cmdline completions by replacing this with an empty table
|
||||
cmdline = function()
|
||||
local type = vim.fn.getcmdtype()
|
||||
-- Search forward and backward
|
||||
if type == "/" or type == "?" then
|
||||
return { "buffer", "lsp" }
|
||||
end
|
||||
-- Commands
|
||||
if type == ":" then
|
||||
return { "cmdline" }
|
||||
end
|
||||
return {}
|
||||
end,
|
||||
|
||||
transform_items = function(_, items)
|
||||
return vim
|
||||
.iter(ipairs(items))
|
||||
:map(function(_, item)
|
||||
if item.kind == require("blink.cmp.types").CompletionItemKind.Snippet then
|
||||
item.score_offset = item.score_offset + 1
|
||||
end
|
||||
return item
|
||||
end)
|
||||
:totable()
|
||||
end,
|
||||
min_keyword_length = function()
|
||||
local default = 1
|
||||
return vim.bo.filetype == "markdown" and 2 or default
|
||||
end,
|
||||
},
|
||||
|
||||
-- experimental signature help support
|
||||
signature = {
|
||||
enabled = true,
|
||||
},
|
||||
|
||||
fuzzy = {
|
||||
-- when enabled, allows for a number of typos relative to the length of the query
|
||||
-- disabling this matches the behavior of fzf
|
||||
use_typo_resistance = false,
|
||||
-- frecency tracks the most recently/frequently used items and boosts the score of the item
|
||||
use_frecency = false,
|
||||
-- proximity bonus boosts the score of items matching nearby words
|
||||
use_proximity = true,
|
||||
|
||||
prebuilt_binaries = {
|
||||
download = false,
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"none-ls.nvim",
|
||||
event = "DeferredUIEnter",
|
||||
after = function()
|
||||
local null = require("null-ls")
|
||||
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
|
||||
local sources = {
|
||||
-- general
|
||||
null.builtins.formatting.treefmt.with({
|
||||
condition = function(utils)
|
||||
return utils.root_has_file("treefmt.toml")
|
||||
end,
|
||||
}),
|
||||
|
||||
-- nix
|
||||
null.builtins.formatting.nixfmt,
|
||||
null.builtins.diagnostics.statix,
|
||||
null.builtins.diagnostics.deadnix,
|
||||
|
||||
-- go
|
||||
null.builtins.formatting.gofumpt,
|
||||
|
||||
-- webdev
|
||||
null.builtins.formatting.prettier.with({
|
||||
filetypes = {
|
||||
"html",
|
||||
"astro",
|
||||
"vue",
|
||||
},
|
||||
}),
|
||||
|
||||
-- shell
|
||||
null.builtins.formatting.shfmt,
|
||||
|
||||
-- lua
|
||||
null.builtins.formatting.stylua,
|
||||
null.builtins.diagnostics.selene,
|
||||
|
||||
-- docs
|
||||
null.builtins.diagnostics.alex,
|
||||
null.builtins.diagnostics.proselint,
|
||||
}
|
||||
|
||||
null.setup({
|
||||
sources = sources,
|
||||
on_attach = function(client, bufnr)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({
|
||||
bufnr = bufnr,
|
||||
filter = function(c)
|
||||
return c.name == "null-ls"
|
||||
end,
|
||||
})
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local toggle_formatters = function()
|
||||
null.toggle({ methods = null.methods.FORMATTING })
|
||||
end
|
||||
|
||||
local toggle_diagnostics = function()
|
||||
null.toggle({ methods = null.methods.DIAGNOSTICS })
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("ToggleFormatters", toggle_formatters, {})
|
||||
vim.api.nvim_create_user_command("ToggleDiagnostics", toggle_diagnostics, {})
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"nvim-lspconfig",
|
||||
event = "DeferredUIEnter",
|
||||
after = function()
|
||||
local plugins = {
|
||||
"nvim-cmp",
|
||||
"cmp-buffer",
|
||||
"cmp-cmdline",
|
||||
"cmp-nvim-lsp",
|
||||
"cmp-path",
|
||||
"cmp_luasnip",
|
||||
"lspkind.nvim",
|
||||
"none-ls.nvim",
|
||||
"lsp-status.nvim",
|
||||
"ltex-extra.nvim",
|
||||
"schemastore.nvim",
|
||||
"py_lsp.nvim",
|
||||
"typescript-tools.nvim",
|
||||
"luasnip",
|
||||
{ "blink.cmp" },
|
||||
{ "lsp-status.nvim" },
|
||||
{ "ltex-extra.nvim" },
|
||||
{ "schemastore.nvim" },
|
||||
{ "py_lsp.nvim" },
|
||||
{ "typescript-tools.nvim" },
|
||||
}
|
||||
|
||||
for _, plugin in ipairs(plugins) do
|
||||
require("lz.n").trigger_load({ plugin })
|
||||
end
|
||||
require("lz.n").load(plugins)
|
||||
|
||||
local lsp_present, lspconfig = pcall(require, "lspconfig")
|
||||
local cmp_present, cmp = pcall(require, "cmp")
|
||||
local navic_present, navic = pcall(require, "nvim-navic")
|
||||
local luasnip_present, luasnip = pcall(require, "luasnip")
|
||||
|
||||
if not lsp_present then
|
||||
vim.notify("lspnot present", vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
if not cmp_present then
|
||||
vim.notify("cmp not present", vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
if not luasnip_present then
|
||||
vim.notify("luasnip not present", vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
vim.opt.completeopt = "menu,menuone,noselect"
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
|
||||
-- border style
|
||||
require("lspconfig.ui.windows").default_options.border = vim.g.bc.style
|
||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
|
||||
border = vim.g.bc.style,
|
||||
})
|
||||
local cmp_borders = {
|
||||
border = {
|
||||
vim.g.bc.topleft,
|
||||
vim.g.bc.horiz,
|
||||
vim.g.bc.topright,
|
||||
vim.g.bc.vert,
|
||||
vim.g.bc.botright,
|
||||
vim.g.bc.horiz,
|
||||
vim.g.bc.botleft,
|
||||
vim.g.bc.vert,
|
||||
},
|
||||
winhighlight = "Normal:CmpPmenu,FloatBorder:CmpBorder,CursorLine:PmenuSel,Search:None",
|
||||
}
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
window = {
|
||||
completion = cmp_borders,
|
||||
documentation = cmp_borders,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<CR>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
if luasnip.expandable() then
|
||||
luasnip.expand()
|
||||
else
|
||||
cmp.confirm({
|
||||
select = true,
|
||||
})
|
||||
end
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.locally_jumpable(1) then
|
||||
luasnip.jump(1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
-- { name = "copilot" },
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "path" },
|
||||
{ name = "luasnip" },
|
||||
}, {
|
||||
{ name = "buffer" },
|
||||
}),
|
||||
formatting = {
|
||||
fields = { "kind", "abbr", "menu" },
|
||||
format = function(entry, vim_item)
|
||||
local kind = require("lspkind").cmp_format({
|
||||
mode = "symbol_text",
|
||||
ellipsis_char = "…",
|
||||
maxwidth = 50,
|
||||
symbol_map = { Copilot = "" },
|
||||
})(entry, vim_item)
|
||||
local strings = vim.split(kind.kind, "%s", { trimempty = true })
|
||||
|
||||
kind.kind = " " .. (strings[1] or "") .. " "
|
||||
kind.menu = " (" .. (strings[2] or "") .. ")"
|
||||
|
||||
return kind
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("BufRead", {
|
||||
group = vim.api.nvim_create_augroup("CmpSourceCargo", { clear = true }),
|
||||
pattern = "Cargo.toml",
|
||||
callback = function()
|
||||
cmp.setup.buffer({ sources = { { name = "crates" } } })
|
||||
end,
|
||||
})
|
||||
|
||||
cmp.setup.cmdline({ "/", "?" }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = "buffer" },
|
||||
},
|
||||
})
|
||||
|
||||
cmp.setup.cmdline(":", {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "path", option = { trailing_slash = true } },
|
||||
}, {
|
||||
{ name = "cmdline" },
|
||||
}),
|
||||
})
|
||||
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
|
||||
group = vim.api.nvim_create_augroup("UserLspConfig", { clear = true }),
|
||||
callback = function(ev)
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
|
||||
|
@ -187,18 +237,25 @@ return {
|
|||
end
|
||||
|
||||
local opts = { buffer = ev.buf }
|
||||
local function use_border(cb)
|
||||
return function()
|
||||
cb({ border = vim.g.bc.style })
|
||||
end
|
||||
end
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
||||
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
|
||||
vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set({ "n", "v" }, "<space>ca", vim.lsp.buf.code_action, opts)
|
||||
vim.keymap.set("n", "K", use_border(vim.lsp.buf.hover), opts)
|
||||
vim.keymap.set("n", "<C-k>", use_border(vim.lsp.buf.signature_help), opts)
|
||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
|
||||
vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts)
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
||||
vim.keymap.set("n", "<space>fm", function()
|
||||
vim.keymap.set("n", "<leader>fm", function()
|
||||
vim.lsp.buf.format({ async = true })
|
||||
end, opts)
|
||||
end,
|
||||
})
|
||||
|
||||
local capabilities = require("blink.cmp").get_lsp_capabilities({}, true)
|
||||
|
||||
local common = { capabilities = capabilities }
|
||||
|
||||
-- setup python
|
||||
|
@ -276,7 +333,6 @@ return {
|
|||
},
|
||||
},
|
||||
lua_ls = {
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
|
@ -306,7 +362,6 @@ return {
|
|||
marksman = {},
|
||||
nil_ls = {
|
||||
autostart = true,
|
||||
capabilities = capabilities,
|
||||
cmd = { "nil" },
|
||||
settings = {
|
||||
["nil"] = {
|
||||
|
@ -370,84 +425,6 @@ return {
|
|||
for server, config in pairs(servers) do
|
||||
lspconfig[server].setup(vim.tbl_extend("force", common, config))
|
||||
end
|
||||
|
||||
-- null ls stuff
|
||||
local null_present, null = pcall(require, "null-ls")
|
||||
|
||||
if not null_present then
|
||||
return
|
||||
end
|
||||
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
|
||||
local sources = {
|
||||
-- general
|
||||
null.builtins.formatting.treefmt.with({
|
||||
condition = function(utils)
|
||||
return utils.root_has_file("treefmt.toml")
|
||||
end,
|
||||
}),
|
||||
|
||||
-- nix
|
||||
null.builtins.formatting.nixfmt,
|
||||
null.builtins.diagnostics.statix,
|
||||
null.builtins.diagnostics.deadnix,
|
||||
|
||||
-- go
|
||||
null.builtins.formatting.gofumpt,
|
||||
|
||||
-- webdev
|
||||
null.builtins.formatting.prettier.with({
|
||||
filetypes = {
|
||||
"html",
|
||||
"astro",
|
||||
"vue",
|
||||
},
|
||||
}),
|
||||
|
||||
-- shell
|
||||
null.builtins.formatting.shfmt,
|
||||
|
||||
-- lua
|
||||
null.builtins.formatting.stylua,
|
||||
null.builtins.diagnostics.selene,
|
||||
|
||||
-- docs
|
||||
null.builtins.diagnostics.alex,
|
||||
null.builtins.diagnostics.proselint,
|
||||
}
|
||||
|
||||
null.setup({
|
||||
sources = sources,
|
||||
on_attach = function(client, bufnr)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({
|
||||
bufnr = bufnr,
|
||||
filter = function(c)
|
||||
return c.name == "null-ls"
|
||||
end,
|
||||
})
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
local toggle_formatters = function()
|
||||
null.toggle({ methods = null.methods.FORMATTING })
|
||||
end
|
||||
|
||||
local toggle_diagnostics = function()
|
||||
null.toggle({ methods = null.methods.DIAGNOSTICS })
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("ToggleFormatters", toggle_formatters, {})
|
||||
vim.api.nvim_create_user_command("ToggleDiagnostics", toggle_diagnostics, {})
|
||||
end,
|
||||
},
|
||||
|
||||
|
|
|
@ -11,30 +11,6 @@ passthru.as = "catppuccin"
|
|||
fetch.github = "laytan/cloak.nvim"
|
||||
src.git = "https://github.com/laytan/cloak.nvim"
|
||||
|
||||
[nvim-cmp]
|
||||
fetch.github = "hrsh7th/nvim-cmp"
|
||||
src.git = "https://github.com/hrsh7th/nvim-cmp"
|
||||
|
||||
[cmp-buffer]
|
||||
fetch.github = "hrsh7th/cmp-buffer"
|
||||
src.git = "https://github.com/hrsh7th/cmp-buffer"
|
||||
|
||||
[cmp-cmdline]
|
||||
fetch.github = "hrsh7th/cmp-cmdline"
|
||||
src.git = "https://github.com/hrsh7th/cmp-cmdline"
|
||||
|
||||
[cmp-nvim-lsp]
|
||||
fetch.github = "hrsh7th/cmp-nvim-lsp"
|
||||
src.git = "https://github.com/hrsh7th/cmp-nvim-lsp"
|
||||
|
||||
[cmp-path]
|
||||
fetch.github = "hrsh7th/cmp-path"
|
||||
src.git = "https://github.com/hrsh7th/cmp-path"
|
||||
|
||||
[cmp_luasnip]
|
||||
fetch.github = "saadparwaiz1/cmp_luasnip"
|
||||
src.git = "https://github.com/saadparwaiz1/cmp_luasnip"
|
||||
|
||||
[copilot-lua]
|
||||
fetch.github = "zbirenbaum/copilot.lua"
|
||||
src.git = "https://github.com/zbirenbaum/copilot.lua"
|
||||
|
|
|
@ -198,6 +198,7 @@ let
|
|||
treesitter
|
||||
|
||||
# extra plugsns beacuse they often fail or need extra steps
|
||||
vimPlugins.blink-cmp
|
||||
vimPlugins.cord-nvim
|
||||
vimPlugins.telescope-fzf-native-nvim
|
||||
];
|
||||
|
|
Loading…
Add table
Reference in a new issue