astronvim-user-config/plugins.lua

431 lines
16 KiB
Lua

return {{
"mbbill/undotree",
name = "undotree",
lazy = false,
}, {
"lewis6991/satellite.nvim",
name = "satellite",
lazy = false,
config = function()
require("satellite").setup {
current_only = false,
winblend = 50,
zindex = 40,
excluded_filetypes = {},
width = 2,
handlers = {
cursor = {
enable = true,
overlap = true,
-- Supports any number of symbols
symbols = { '', '', '', '' }
-- symbols = { '⎻', '⎼' }
-- Highlights:
-- - SatelliteCursor (default links to NonText
},
search = {
enable = true,
-- Highlights:
-- - SatelliteSearch (default links to Search)
-- - SatelliteSearchCurrent (default links to SearchCurrent)
},
diagnostic = {
enable = true,
signs = {'-', '=', ''},
min_severity = vim.diagnostic.severity.HINT,
-- Highlights:
-- - SatelliteDiagnosticError (default links to DiaSatelliteEnablegnosticError)
-- - SatelliteDiagnosticWarn (default links to DiagnosticWarn)
-- - SatelliteDiagnosticInfo (default links to DiagnosticInfo)
-- - SatelliteDiagnosticHint (default links to DiagnosticHint)
},
gitsigns = {
enable = true,
signs = { -- can only be a single character (multibyte is okay)
add = "",
change = "",
delete = "-",
},
-- Highlights:
-- SatelliteGitSignsAdd (default links to GitSignsAdd)
-- SatelliteGitSignsChange (default links to GitSignsChange)
-- SatelliteGitSignsDelete (default links to GitSignsDelete)
},
marks = {
enable = true,
show_builtins = false, -- shows the builtin marks like [ ] < >
key = 'm'
-- Highlights:
-- SatelliteMark (default links to Normal)
},
quickfix = {
signs = { '-', '=', '' },
-- Highlights:
-- SatelliteQuickfix (default links to WarningMsg)
}
},
}
end,
}, {
"catppuccin/nvim",
name = "catppuccin",
config = function()
require("catppuccin").setup {
flavour = "mocha",
-- Colors adapted from https://github.com/one-dark/jetbrains-one-dark-theme
-- Catppuccin colors: https://github.com/catppuccin/catppuccin/blob/main/docs/style-guide.md
-- Catppuccin Neovim config: https://github.com/catppuccin/nvim/#configuration
color_overrides = {
mocha = {
text = "#BBBBBB",
base = "#282c34",
crust = "#21252b",
mauve = "#D55FDE",
blue = "#61AFEF",
teal = "#2BBAC5",
red = "#EF596F",
green = "#89CA78",
peach = "#D19A66",
yellow = "#E5C07B",
sapphire = "#009191",
maroon = "#f9c89a"
}
},
integrations = {
cmp = true,
neotree = true,
mason = true,
which_key = true,
dap_ui = true,
leap = true,
semantic_tokens = true,
dap = true,
aerial = true,
},
custom_highlights = function(C)
-- :Telescope highlights for a general list
-- Rust-analyzer tokens: https://rust-analyzer.github.io/manual.html#semantic-syntax-highlighting
-- @lsp.mod.* for modifiers
-- @lsp.modtype.* for types with modifiers
-- @lsp.type.* for token types
return {
LeapBackdrop = { fg = C.overlay0 },
Error = { fg = C.red, italic = true, underline = true },
["@lsp.type.interface"] = { fg = C.yellow },
["@function.builtin"] = { fg = C.blue },
["@lsp.typemod.method.builtIn"] = { fg = C.blue },
["@lsp.mod.mutable"] = { underline = true },
["@lsp.mod.consuming"] = { bold = true },
["@lsp.type.lifetime"] = { fg = C.teal },
["@variable.builtin"] = { fg = C.mauve },
["StorageClass"] = { fg = C.mauve },
["@constructor.lua"] = { fg = C.overlay2 },
["@preproc"] = { fg = C.maroon },
["@debug"] = { fg = C.maroon },
["@field"] = { fg = C.red },
["@property"] = { fg = C.red },
["@lsp.type.formatSpecifier"] = { fg = C.teal },
["@lsp.type.escapeSequence"] = { fg = C.teal },
PreProc = { fg = C.maroon },
Special = { fg = C.teal },
["@namespace"] = { fg = C.overlay2 },
["@define"] = { fg = C.maroon },
["@string.escape"] = { fg = C.teal },
Operator = { fg = C.text },
CmpItemKindSnippet = { fg = C.base, bg = C.green },
CmpItemKindKeyword = { fg = C.base, bg = C.mauve },
CmpItemKindText = { fg = C.base, bg = C.teal },
CmpItemKindMethod = { fg = C.base, bg = C.blue },
CmpItemKindConstructor = { fg = C.base, bg = C.blue },
CmpItemKindFunction = { fg = C.base, bg = C.blue },
CmpItemKindFolder = { fg = C.base, bg = C.blue },
CmpItemKindModule = { fg = C.base, bg = C.blue },
CmpItemKindConstant = { fg = C.base, bg = C.peach },
CmpItemKindField = { fg = C.base, bg = C.red },
CmpItemKindProperty = { fg = C.base, bg = C.red },
CmpItemKindEnum = { fg = C.base, bg = C.peach },
CmpItemKindUnit = { fg = C.base, bg = C.peach },
CmpItemKindClass = { fg = C.base, bg = C.yellow },
CmpItemKindVariable = { fg = C.base, bg = C.flamingo },
CmpItemKindFile = { fg = C.base, bg = C.blue },
CmpItemKindInterface = { fg = C.base, bg = C.yellow },
CmpItemKindColor = { fg = C.base, bg = C.red },
CmpItemKindReference = { fg = C.base, bg = C.red },
CmpItemKindEnumMember = { fg = C.base, bg = C.red },
CmpItemKindStruct = { fg = C.base, bg = C.blue },
CmpItemKindValue = { fg = C.base, bg = C.peach },
CmpItemKindEvent = { fg = C.base, bg = C.blue },
CmpItemKindOperator = { fg = C.base, bg = C.blue },
CmpItemKindTypeParameter = { fg = C.base, bg = C.blue },
CmpItemKindCopilot = { fg = C.base, bg = C.teal },
}
end,
}
end,
}, {
"hrsh7th/nvim-cmp",
-- override the options table that is used in the `require("cmp").setup()` call
opts = function(_, opts)
-- opts parameter is the default options table
-- the function is lazy loaded so cmp is able to be required
local lspkind = require("lspkind")
local cmp = require("cmp")
-- Completion sources
opts.sources = cmp.config.sources({
{ name = "crates", priority = 1250 },
{ name = "nvim_lsp", priority = 1000 },
{ name = "luasnip", priority = 750 },
{ name = "buffer", priority = 500 },
{ name = "path", priority = 250 },
})
-- Custom comparator to sort LSP text and snippets last
local types = require("cmp.types")
local function compareLspKind(entry1, entry2)
local kind1 = entry1:get_kind() --- @type lsp.CompletionItemKind | number
local kind2 = entry2:get_kind() --- @type lsp.CompletionItemKind | number
kind1 = kind1 == types.lsp.CompletionItemKind.Text and 100 or kind1
kind2 = kind2 == types.lsp.CompletionItemKind.Text and 100 or kind2
kind1 = kind1 == types.lsp.CompletionItemKind.Snippet and 90 or kind1
kind2 = kind2 == types.lsp.CompletionItemKind.Snippet and 90 or kind2
if kind1 ~= kind2 then
local diff = kind1 - kind2
if diff < 0 then
return true
elseif diff > 0 then
return false
end
end
return nil
end
-- Custom comparators for sorting of options
local compare = require('cmp.config.compare')
opts.sorting = {
priority_weight = 2,
comparators = {
compare.offset,
compare.exact,
compare.score,
compare.recently_used,
compareLspKind,
compare.sort_text,
compare.length,
compare.order,
},
}
-- Make the cmp prompt pretty
-- How to customize: https://docs.astronvim.com/recipes/cmp/
-- From: https://github.com/johnallen3d/dotfiles/blob/46300be412aba524743f8e3d47fff4df3deb2857/dot_config/nvim/lua/config/plugins/cmp.lua
opts.formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
local kind = lspkind.cmp_format({
mode = "symbol_text",
maxwidth = 50,
})(entry, vim_item)
local strings = vim.split(kind.kind, "%s", { trimempty = true })
kind.kind = " " .. strings[1] .. " "
kind.menu = " (" .. strings[2] .. ")"
return kind
end,
}
-- Use PageUp and PageDown to navigate through completions
local luasnip = require("luasnip")
opts.mapping["<PageDown>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item({ count = 5 })
elseif luasnip.jumpable(5) then
luasnip.jump(5)
else
fallback()
end
end, { "i", "s" })
opts.mapping["<PageUp>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item({ count = 5 })
elseif luasnip.jumpable(-5) then
luasnip.jump(-5)
else
fallback()
end
end, { "i", "s" })
-- return the new table to be used
return opts
end,
}, {
"lewis6991/hover.nvim",
name = "hover",
config = function()
require("hover").setup {
init = function()
-- Require providers
require("hover.providers.lsp")
-- require('hover.providers.gh')
-- require('hover.providers.gh_user')
-- require('hover.providers.jira')
-- require('hover.providers.man')
-- require('hover.providers.dictionary')
end,
preview_opts = {
border = 'single'
},
-- Whether the contents of a currently open hover window should be moved
-- to a :h preview-window when pressing the hover keymap.
preview_window = false,
title = true,
mouse_providers = {
'LSP'
},
mouse_delay = 1000
}
end
}, {
"ggandor/leap.nvim",
name = "leap",
lazy = false,
config = function()
local leap = require('leap')
leap.setup {
highlight_unlabeled_phase_one_targets = true
}
leap.create_default_mappings()
-- Magic trick from https://github.com/ggandor/leap.nvim/issues/65#issuecomment-1637749795
-- to highlight already matched parts
local function highlight_unlabeled_phase_one_targets(targets, first_idx, last_idx)
local hl = require('leap.highlight')
for i = first_idx or 1, last_idx or #targets do
local target = targets[i]
if target.chars then
local bufnr = target.wininfo.bufnr
local id = vim.api.nvim_buf_set_extmark(
bufnr, hl.ns, target.pos[1] - 1, target.pos[2] - 1,
{
virt_text = { { table.concat(target.chars), "LeapMatch" } },
virt_text_pos = "overlay",
hl_mode = "combine",
priority = hl.priority.label,
}
)
-- This way Leap automatically cleans up your stuff together with its own.
table.insert(hl.extmarks, { bufnr, id })
end
end
-- Continue with Leap's native function body.
return true
end
leap.opts.on_beacons = highlight_unlabeled_phase_one_targets
end
}, {
"rebelot/heirline.nvim",
opts = function(_, opts)
-- Config override from: https://docs.astronvim.com/recipes/status#default-statusline-with-mode-text
local status = require("astronvim.utils.status")
opts.statusline = { -- statusline
hl = { fg = "fg", bg = "bg" },
status.component.mode { mode_text = { padding = { left = 1, right = 1 } } }, -- add the mode text
status.component.git_branch(),
status.component.file_info { filetype = {}, filename = false, file_modified = false },
status.component.git_diff(),
status.component.diagnostics(),
status.component.fill(),
status.component.cmd_info(),
status.component.fill(),
status.component.lsp(),
status.component.treesitter(),
status.component.nav(),
-- remove the 2nd mode indicator on the right
}
-- return the final configuration table
return opts
end,
}, {
"onsails/lspkind.nvim",
opts = function(_, opts)
-- use codicons preset
opts.preset = "codicons"
-- set some missing symbol types
opts.symbol_map = {
Array = "",
Boolean = "",
Key = "",
Namespace = "",
Null = "",
Number = "",
Object = "",
Package = "",
String = "",
}
return opts
end,
}, {
-- Rust crates helper
"saecki/crates.nvim",
tag = "stable",
lazy = false,
dependencies = "nvim-lua/plenary.nvim",
config = function()
require("crates").setup({
null_ls = {
enabled = true,
name = "crates",
},
})
end,
}, {
-- Nicer-loking cmdline, search, ...
"folke/noice.nvim",
event = "VeryLazy",
config = function ()
require("noice").setup({
lsp = {
hover = {
enabled = false
},
signature = {
enabled = false
}
}
})
end,
dependencies = {
"MunifTanjim/nui.nvim",
"rcarriga/nvim-notify",
}
}, {
"monaqa/dial.nvim",
config = function()
-- Increment and decrement these groups with a keybind
local augend = require("dial.augend")
require("dial.config").augends:register_group({
["default"] = {
augend.integer.alias.decimal,
augend.integer.alias.hex,
augend.date.alias["%Y/%m/%d"],
augend.date.alias["%Y-%m-%d"],
augend.semver.alias.semver,
augend.misc.alias.markdown_header,
augend.constant.alias.bool
}
})
end
}, {
"ray-x/lsp_signature.nvim",
lazy = false,
config = function()
require("lsp_signature").setup({
floating_window = false,
hint_prefix = "🦊 ",
doc_lines = 0
})
end
}}