mirror of
https://github.com/Keyitdev/dotfiles.git
synced 2026-09-24 01:52:09 +00:00
New version: created v3
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
local status_ok, Comment = pcall(require, "Comment")
|
||||
if status_ok then
|
||||
local utils = require "Comment.utils"
|
||||
Comment.setup(astronvim.user_plugin_opts("plugins.Comment", {
|
||||
pre_hook = function(ctx)
|
||||
local location = nil
|
||||
if ctx.ctype == utils.ctype.block then
|
||||
location = require("ts_context_commentstring.utils").get_cursor_location()
|
||||
elseif ctx.cmotion == utils.cmotion.v or ctx.cmotion == utils.cmotion.V then
|
||||
location = require("ts_context_commentstring.utils").get_visual_start_location()
|
||||
end
|
||||
|
||||
return require("ts_context_commentstring.internal").calculate_commentstring {
|
||||
key = ctx.ctype == utils.ctype.line and "__default" or "__multiline",
|
||||
location = location,
|
||||
}
|
||||
end,
|
||||
}))
|
||||
end
|
||||
@@ -0,0 +1,52 @@
|
||||
local status_ok, aerial = pcall(require, "aerial")
|
||||
if status_ok then
|
||||
aerial.setup(astronvim.user_plugin_opts("plugins.aerial", {
|
||||
close_behavior = "global",
|
||||
backends = { "lsp", "treesitter", "markdown" },
|
||||
min_width = 28,
|
||||
show_guides = true,
|
||||
filter_kind = false,
|
||||
icons = {
|
||||
Array = "",
|
||||
Boolean = "⊨",
|
||||
Class = "",
|
||||
Constant = "",
|
||||
Constructor = "",
|
||||
Key = "",
|
||||
Function = "",
|
||||
Method = "ƒ",
|
||||
Namespace = "",
|
||||
Null = "NULL",
|
||||
Number = "#",
|
||||
Object = "⦿",
|
||||
Property = "",
|
||||
TypeParameter = "𝙏",
|
||||
Variable = "",
|
||||
Enum = "ℰ",
|
||||
Package = "",
|
||||
EnumMember = "",
|
||||
File = "",
|
||||
Module = "",
|
||||
Field = "",
|
||||
Interface = "ﰮ",
|
||||
String = "𝓐",
|
||||
Struct = "𝓢",
|
||||
Event = "",
|
||||
Operator = "+",
|
||||
},
|
||||
guides = {
|
||||
mid_item = "├ ",
|
||||
last_item = "└ ",
|
||||
nested_top = "│ ",
|
||||
whitespace = " ",
|
||||
},
|
||||
on_attach = function(bufnr)
|
||||
-- Jump forwards/backwards with '{' and '}'
|
||||
vim.keymap.set("n", "{", "<cmd>AerialPrev<cr>", { buffer = bufnr, desc = "Jump backwards in Aerial" })
|
||||
vim.keymap.set("n", "}", "<cmd>AerialNext<cr>", { buffer = bufnr, desc = "Jump forwards in Aerial" })
|
||||
-- Jump up the tree with '[[' or ']]'
|
||||
vim.keymap.set("n", "[[", "<cmd>AerialPrevUp<cr>", { buffer = bufnr, desc = "Jump up and backwards in Aerial" })
|
||||
vim.keymap.set("n", "]]", "<cmd>AerialNextUp<cr>", { buffer = bufnr, desc = "Jump up and forwards in Aerial" })
|
||||
end,
|
||||
}))
|
||||
end
|
||||
@@ -0,0 +1,40 @@
|
||||
local status_ok, alpha = pcall(require, "alpha")
|
||||
if status_ok then
|
||||
local alpha_button = astronvim.alpha_button
|
||||
alpha.setup(astronvim.user_plugin_opts("plugins.alpha", {
|
||||
layout = {
|
||||
{ type = "padding", val = vim.fn.max { 2, vim.fn.floor(vim.fn.winheight(0) * 0.2) } },
|
||||
{
|
||||
type = "text",
|
||||
val = astronvim.user_plugin_opts("header", {
|
||||
" █████ ███████ ████████ ██████ ██████",
|
||||
"██ ██ ██ ██ ██ ██ ██ ██",
|
||||
"███████ ███████ ██ ██████ ██ ██",
|
||||
"██ ██ ██ ██ ██ ██ ██ ██",
|
||||
"██ ██ ███████ ██ ██ ██ ██████",
|
||||
" ",
|
||||
" ███ ██ ██ ██ ██ ███ ███",
|
||||
" ████ ██ ██ ██ ██ ████ ████",
|
||||
" ██ ██ ██ ██ ██ ██ ██ ████ ██",
|
||||
" ██ ██ ██ ██ ██ ██ ██ ██ ██",
|
||||
" ██ ████ ████ ██ ██ ██",
|
||||
}, false),
|
||||
opts = { position = "center", hl = "DashboardHeader" },
|
||||
},
|
||||
{ type = "padding", val = 5 },
|
||||
{
|
||||
type = "group",
|
||||
val = {
|
||||
alpha_button("LDR f f", " Find File "),
|
||||
alpha_button("LDR f o", " Recents "),
|
||||
alpha_button("LDR f w", " Find Word "),
|
||||
alpha_button("LDR f n", " New File "),
|
||||
alpha_button("LDR f m", " Bookmarks "),
|
||||
alpha_button("LDR S l", " Last Session "),
|
||||
},
|
||||
opts = { spacing = 1 },
|
||||
},
|
||||
},
|
||||
opts = {},
|
||||
}))
|
||||
end
|
||||
@@ -0,0 +1,33 @@
|
||||
local status_ok, npairs = pcall(require, "nvim-autopairs")
|
||||
if status_ok then
|
||||
npairs.setup(astronvim.user_plugin_opts("plugins.nvim-autopairs", {
|
||||
check_ts = true,
|
||||
ts_config = {
|
||||
lua = { "string", "source" },
|
||||
javascript = { "string", "template_string" },
|
||||
java = false,
|
||||
},
|
||||
disable_filetype = { "TelescopePrompt", "spectre_panel" },
|
||||
fast_wrap = {
|
||||
map = "<M-e>",
|
||||
chars = { "{", "[", "(", '"', "'" },
|
||||
pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""),
|
||||
offset = 0,
|
||||
end_key = "$",
|
||||
keys = "qwertyuiopzxcvbnmasdfghjkl",
|
||||
check_comma = true,
|
||||
highlight = "PmenuSel",
|
||||
highlight_grey = "LineNr",
|
||||
},
|
||||
}))
|
||||
|
||||
local rules = astronvim.user_plugin_opts("nvim-autopairs").add_rules
|
||||
if vim.tbl_contains({ "function", "table" }, type(rules)) then
|
||||
npairs.add_rules(type(rules) == "function" and rules(npairs) or rules)
|
||||
end
|
||||
|
||||
local cmp_status_ok, cmp = pcall(require, "cmp")
|
||||
if cmp_status_ok then
|
||||
cmp.event:on("confirm_done", require("nvim-autopairs.completion.cmp").on_confirm_done { map_char = { tex = "" } })
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
local status_ok, better_escape = pcall(require, "better_escape")
|
||||
if status_ok then
|
||||
better_escape.setup(astronvim.user_plugin_opts "plugins.better_escape")
|
||||
end
|
||||
@@ -0,0 +1,19 @@
|
||||
local status_ok, bufferline = pcall(require, "bufferline")
|
||||
if status_ok then
|
||||
bufferline.setup(astronvim.user_plugin_opts("plugins.bufferline", {
|
||||
options = {
|
||||
offsets = {
|
||||
{ filetype = "NvimTree", text = "", padding = 1 },
|
||||
{ filetype = "neo-tree", text = "", padding = 1 },
|
||||
{ filetype = "Outline", text = "", padding = 1 },
|
||||
},
|
||||
buffer_close_icon = "",
|
||||
modified_icon = "",
|
||||
close_icon = "",
|
||||
max_name_length = 14,
|
||||
max_prefix_length = 13,
|
||||
tab_size = 20,
|
||||
separator_style = "thin",
|
||||
},
|
||||
}))
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
local status_ok, cinnamon = pcall(require, "cinnamon")
|
||||
if status_ok then
|
||||
cinnamon.setup(astronvim.user_plugin_opts("plugins.cinnamon", {}))
|
||||
end
|
||||
@@ -0,0 +1,119 @@
|
||||
local cmp_status_ok, cmp = pcall(require, "cmp")
|
||||
local snip_status_ok, luasnip = pcall(require, "luasnip")
|
||||
if cmp_status_ok and snip_status_ok then
|
||||
local setup = cmp.setup
|
||||
local kind_icons = {
|
||||
Text = "",
|
||||
Method = "",
|
||||
Function = "",
|
||||
Constructor = "",
|
||||
Field = "ﰠ",
|
||||
Variable = "",
|
||||
Class = "",
|
||||
Interface = "",
|
||||
Module = "",
|
||||
Property = "",
|
||||
Unit = "",
|
||||
Value = "",
|
||||
Enum = "",
|
||||
Keyword = "",
|
||||
Snippet = "",
|
||||
Color = "",
|
||||
File = "",
|
||||
Reference = "",
|
||||
Folder = "",
|
||||
EnumMember = "",
|
||||
Constant = "",
|
||||
Struct = "פּ",
|
||||
Event = "",
|
||||
Operator = "",
|
||||
TypeParameter = "",
|
||||
}
|
||||
|
||||
local function has_words_before()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match "%s" == nil
|
||||
end
|
||||
|
||||
setup(astronvim.user_plugin_opts("plugins.cmp", {
|
||||
preselect = cmp.PreselectMode.None,
|
||||
formatting = {
|
||||
fields = { "kind", "abbr", "menu" },
|
||||
format = function(_, vim_item)
|
||||
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
duplicates = {
|
||||
nvim_lsp = 1,
|
||||
luasnip = 1,
|
||||
cmp_tabnine = 1,
|
||||
buffer = 1,
|
||||
path = 1,
|
||||
},
|
||||
confirm_opts = {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = false,
|
||||
},
|
||||
window = {
|
||||
documentation = {
|
||||
border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
|
||||
},
|
||||
},
|
||||
mapping = {
|
||||
["<Up>"] = cmp.mapping.select_prev_item(),
|
||||
["<Down>"] = cmp.mapping.select_next_item(),
|
||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||
["<C-k>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-j>"] = cmp.mapping.select_next_item(),
|
||||
["<C-d>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
|
||||
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
|
||||
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
|
||||
["<C-y>"] = cmp.config.disable,
|
||||
["<C-e>"] = cmp.mapping {
|
||||
i = cmp.mapping.abort(),
|
||||
c = cmp.mapping.close(),
|
||||
},
|
||||
["<CR>"] = cmp.mapping.confirm { select = false },
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expandable() then
|
||||
luasnip.expand()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {
|
||||
"i",
|
||||
"s",
|
||||
}),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {
|
||||
"i",
|
||||
"s",
|
||||
}),
|
||||
},
|
||||
}))
|
||||
for setup_opt, setup_table in pairs(astronvim.user_plugin_opts("cmp.setup", {})) do
|
||||
for pattern, options in pairs(setup_table) do
|
||||
setup[setup_opt](pattern, options)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
local status_ok, colorizer = pcall(require, "colorizer")
|
||||
if status_ok then
|
||||
local colorizer_opts = astronvim.user_plugin_opts("plugins.colorizer", {
|
||||
{ "*" },
|
||||
{
|
||||
RGB = true, -- #RGB hex codes
|
||||
RRGGBB = true, -- #RRGGBB hex codes
|
||||
names = false, -- "Name" codes like Blue
|
||||
RRGGBBAA = false, -- #RRGGBBAA hex codes
|
||||
rgb_fn = false, -- CSS rgb() and rgba() functions
|
||||
hsl_fn = false, -- CSS hsl() and hsla() functions
|
||||
css = false, -- Enable all css features: rgb_fn, hsl_fn, names, RGB, RRGGBB
|
||||
css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn
|
||||
mode = "background", -- Set the display mode
|
||||
},
|
||||
})
|
||||
colorizer.setup(colorizer_opts[1], colorizer_opts[2])
|
||||
end
|
||||
@@ -0,0 +1,46 @@
|
||||
local status_ok, feline = pcall(require, "feline")
|
||||
if status_ok then
|
||||
local C = require "default_theme.colors"
|
||||
local hl = require("core.status").hl
|
||||
local provider = require("core.status").provider
|
||||
local conditional = require("core.status").conditional
|
||||
-- stylua: ignore
|
||||
feline.setup(astronvim.user_plugin_opts("plugins.feline", {
|
||||
disable = { filetypes = { "^NvimTree$", "^neo%-tree$", "^dashboard$", "^Outline$", "^aerial$" } },
|
||||
theme = hl.group("StatusLine", { fg = C.fg, bg = C.bg_1 }),
|
||||
components = {
|
||||
active = {
|
||||
{
|
||||
{ provider = provider.spacer(), hl = hl.mode() },
|
||||
{ provider = provider.spacer(2) },
|
||||
{ provider = "git_branch", hl = hl.fg("Conditional", { fg = C.purple_1, style = "bold" }), icon = " " },
|
||||
{ provider = provider.spacer(3), enabled = conditional.git_available },
|
||||
{ provider = { name = "file_type", opts = { filetype_icon = true, case = "lowercase" } }, enabled = conditional.has_filetype },
|
||||
{ provider = provider.spacer(2), enabled = conditional.has_filetype },
|
||||
{ provider = "git_diff_added", hl = hl.fg("GitSignsAdd", { fg = C.green }), icon = " " },
|
||||
{ provider = "git_diff_changed", hl = hl.fg("GitSignsChange", { fg = C.orange_1 }), icon = " 柳" },
|
||||
{ provider = "git_diff_removed", hl = hl.fg("GitSignsDelete", { fg = C.red_1 }), icon = " " },
|
||||
{ provider = provider.spacer(2), enabled = conditional.git_changed },
|
||||
{ provider = "diagnostic_errors", hl = hl.fg("DiagnosticError", { fg = C.red_1 }), icon = " " },
|
||||
{ provider = "diagnostic_warnings", hl = hl.fg("DiagnosticWarn", { fg = C.orange_1 }), icon = " " },
|
||||
{ provider = "diagnostic_info", hl = hl.fg("DiagnosticInfo", { fg = C.white_2 }), icon = " " },
|
||||
{ provider = "diagnostic_hints", hl = hl.fg("DiagnosticHint", { fg = C.yellow_1 }), icon = " " },
|
||||
},
|
||||
{
|
||||
{ provider = provider.lsp_progress, enabled = conditional.bar_width() },
|
||||
{ provider = provider.lsp_client_names(true), short_provider = provider.lsp_client_names(), enabled = conditional.bar_width(), icon = " " },
|
||||
{ provider = provider.spacer(2), enabled = conditional.bar_width() },
|
||||
{ provider = provider.treesitter_status, enabled = conditional.bar_width(), hl = hl.fg("GitSignsAdd", { fg = C.green }) },
|
||||
{ provider = provider.spacer(2) },
|
||||
{ provider = "position" },
|
||||
{ provider = provider.spacer(2) },
|
||||
{ provider = "line_percentage" },
|
||||
{ provider = provider.spacer() },
|
||||
{ provider = "scroll_bar", hl = hl.fg("TypeDef", { fg = C.yellow }) },
|
||||
{ provider = provider.spacer(2) },
|
||||
{ provider = provider.spacer(), hl = hl.mode() },
|
||||
},
|
||||
},
|
||||
},
|
||||
}))
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
local status_ok, gitsigns = pcall(require, "gitsigns")
|
||||
if status_ok then
|
||||
gitsigns.setup(astronvim.user_plugin_opts("plugins.gitsigns", {
|
||||
signs = {
|
||||
add = { text = "▎" },
|
||||
change = { text = "▎" },
|
||||
delete = { text = "▎" },
|
||||
topdelete = { text = "契" },
|
||||
changedelete = { text = "▎" },
|
||||
},
|
||||
}))
|
||||
end
|
||||
@@ -0,0 +1,17 @@
|
||||
local status_ok, icons = pcall(require, "nvim-web-devicons")
|
||||
if status_ok then
|
||||
icons.set_icon(astronvim.user_plugin_opts("plugins.nvim-web-devicons", {
|
||||
deb = { icon = "", name = "Deb" },
|
||||
lock = { icon = "", name = "Lock" },
|
||||
mp3 = { icon = "", name = "Mp3" },
|
||||
mp4 = { icon = "", name = "Mp4" },
|
||||
out = { icon = "", name = "Out" },
|
||||
["robots.txt"] = { icon = "ﮧ", name = "Robots" },
|
||||
ttf = { icon = "", name = "TrueTypeFont" },
|
||||
rpm = { icon = "", name = "Rpm" },
|
||||
woff = { icon = "", name = "WebOpenFontFormat" },
|
||||
woff2 = { icon = "", name = "WebOpenFontFormat2" },
|
||||
xz = { icon = "", name = "Xz" },
|
||||
zip = { icon = "", name = "Zip" },
|
||||
}))
|
||||
end
|
||||
@@ -0,0 +1,50 @@
|
||||
local status_ok, indent_blankline = pcall(require, "indent_blankline")
|
||||
if status_ok then
|
||||
indent_blankline.setup(astronvim.user_plugin_opts("plugins.indent_blankline", {
|
||||
buftype_exclude = {
|
||||
"nofile",
|
||||
"terminal",
|
||||
"lsp-installer",
|
||||
"lspinfo",
|
||||
},
|
||||
filetype_exclude = {
|
||||
"help",
|
||||
"startify",
|
||||
"aerial",
|
||||
"alpha",
|
||||
"dashboard",
|
||||
"packer",
|
||||
"neogitstatus",
|
||||
"NvimTree",
|
||||
"neo-tree",
|
||||
"Trouble",
|
||||
},
|
||||
context_patterns = {
|
||||
"class",
|
||||
"return",
|
||||
"function",
|
||||
"method",
|
||||
"^if",
|
||||
"^while",
|
||||
"jsx_element",
|
||||
"^for",
|
||||
"^object",
|
||||
"^table",
|
||||
"block",
|
||||
"arguments",
|
||||
"if_statement",
|
||||
"else_clause",
|
||||
"jsx_element",
|
||||
"jsx_self_closing_element",
|
||||
"try_statement",
|
||||
"catch_clause",
|
||||
"import_statement",
|
||||
"operation_type",
|
||||
},
|
||||
show_trailing_blankline_indent = false,
|
||||
use_treesitter = true,
|
||||
char = "▏",
|
||||
context_char = "▏",
|
||||
show_current_context = true,
|
||||
}))
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
local status_ok, indent_o_matic = pcall(require, "indent-o-matic")
|
||||
if status_ok then
|
||||
indent_o_matic.setup(astronvim.user_plugin_opts "plugins.indent-o-matic")
|
||||
end
|
||||
@@ -0,0 +1,167 @@
|
||||
astronvim.lsp = {}
|
||||
local user_plugin_opts = astronvim.user_plugin_opts
|
||||
local conditional_func = astronvim.conditional_func
|
||||
|
||||
local function lsp_highlight_document(client)
|
||||
if client.resolved_capabilities.document_highlight then
|
||||
vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true })
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
group = "lsp_document_highlight",
|
||||
pattern = "<buffer>",
|
||||
callback = vim.lsp.buf.document_highlight,
|
||||
})
|
||||
vim.api.nvim_create_autocmd("CursorMoved", {
|
||||
group = "lsp_document_highlight",
|
||||
pattern = "<buffer>",
|
||||
callback = vim.lsp.buf.clear_references,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
astronvim.lsp.on_attach = function(client, bufnr)
|
||||
astronvim.set_mappings(
|
||||
user_plugin_opts("lsp.mappings", {
|
||||
n = {
|
||||
["K"] = {
|
||||
function()
|
||||
vim.lsp.buf.hover()
|
||||
end,
|
||||
desc = "Hover symbol details",
|
||||
buffer = bufnr,
|
||||
},
|
||||
["<leader>la"] = {
|
||||
function()
|
||||
vim.lsp.buf.code_action()
|
||||
end,
|
||||
desc = "LSP code action",
|
||||
buffer = bufnr,
|
||||
},
|
||||
["<leader>lf"] = {
|
||||
function()
|
||||
vim.lsp.buf.formatting_sync()
|
||||
end,
|
||||
desc = "Format code",
|
||||
buffer = bufnr,
|
||||
},
|
||||
["<leader>lh"] = {
|
||||
function()
|
||||
vim.lsp.buf.signature_help()
|
||||
end,
|
||||
desc = "Signature help",
|
||||
buffer = bufnr,
|
||||
},
|
||||
["<leader>lr"] = {
|
||||
function()
|
||||
vim.lsp.buf.rename()
|
||||
end,
|
||||
desc = "Rename current symbol",
|
||||
buffer = bufnr,
|
||||
},
|
||||
["gD"] = {
|
||||
function()
|
||||
vim.lsp.buf.declaration()
|
||||
end,
|
||||
desc = "Declaration of current symbol",
|
||||
buffer = bufnr,
|
||||
},
|
||||
["gI"] = {
|
||||
function()
|
||||
vim.lsp.buf.implementation()
|
||||
end,
|
||||
desc = "Implementation of current symbol",
|
||||
buffer = bufnr,
|
||||
},
|
||||
["gd"] = {
|
||||
function()
|
||||
vim.lsp.buf.definition()
|
||||
end,
|
||||
desc = "Show the definition of current symbol",
|
||||
buffer = bufnr,
|
||||
},
|
||||
["gr"] = {
|
||||
function()
|
||||
vim.lsp.buf.references()
|
||||
end,
|
||||
desc = "References of current symbol",
|
||||
buffer = bufnr,
|
||||
},
|
||||
["<leader>ld"] = {
|
||||
function()
|
||||
vim.diagnostic.open_float()
|
||||
end,
|
||||
desc = "Hover diagnostics",
|
||||
buffer = bufnr,
|
||||
},
|
||||
["[d"] = {
|
||||
function()
|
||||
vim.diagnostic.goto_prev()
|
||||
end,
|
||||
desc = "Previous diagnostic",
|
||||
buffer = bufnr,
|
||||
},
|
||||
["]d"] = {
|
||||
function()
|
||||
vim.diagnostic.goto_next()
|
||||
end,
|
||||
desc = "Next diagnostic",
|
||||
buffer = bufnr,
|
||||
},
|
||||
["gl"] = {
|
||||
function()
|
||||
vim.diagnostic.open_float()
|
||||
end,
|
||||
desc = "Hover diagnostics",
|
||||
buffer = bufnr,
|
||||
},
|
||||
},
|
||||
}),
|
||||
{ buffer = bufnr }
|
||||
)
|
||||
|
||||
vim.api.nvim_buf_create_user_command(bufnr, "Format", function()
|
||||
vim.lsp.buf.formatting()
|
||||
end, { desc = "Format file with LSP" })
|
||||
|
||||
local on_attach_override = user_plugin_opts("lsp.on_attach", nil, false)
|
||||
local aerial_avail, aerial = pcall(require, "aerial")
|
||||
conditional_func(on_attach_override, true, client, bufnr)
|
||||
conditional_func(aerial.on_attach, aerial_avail, client, bufnr)
|
||||
lsp_highlight_document(client)
|
||||
end
|
||||
|
||||
astronvim.lsp.capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
astronvim.lsp.capabilities.textDocument.completion.completionItem.documentationFormat = { "markdown", "plaintext" }
|
||||
astronvim.lsp.capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
astronvim.lsp.capabilities.textDocument.completion.completionItem.preselectSupport = true
|
||||
astronvim.lsp.capabilities.textDocument.completion.completionItem.insertReplaceSupport = true
|
||||
astronvim.lsp.capabilities.textDocument.completion.completionItem.labelDetailsSupport = true
|
||||
astronvim.lsp.capabilities.textDocument.completion.completionItem.deprecatedSupport = true
|
||||
astronvim.lsp.capabilities.textDocument.completion.completionItem.commitCharactersSupport = true
|
||||
astronvim.lsp.capabilities.textDocument.completion.completionItem.tagSupport = { valueSet = { 1 } }
|
||||
astronvim.lsp.capabilities.textDocument.completion.completionItem.resolveSupport = {
|
||||
properties = { "documentation", "detail", "additionalTextEdits" },
|
||||
}
|
||||
|
||||
function astronvim.lsp.server_settings(server_name)
|
||||
local server = require("lspconfig")[server_name]
|
||||
local opts = user_plugin_opts(
|
||||
"lsp.server-settings." .. server_name,
|
||||
user_plugin_opts("lsp.server-settings." .. server_name, {
|
||||
capabilities = vim.tbl_deep_extend("force", astronvim.lsp.capabilities, server.capabilities or {}),
|
||||
}, true, "configs")
|
||||
)
|
||||
local old_on_attach = server.on_attach
|
||||
local user_on_attach = opts.on_attach
|
||||
opts.on_attach = function(client, bufnr)
|
||||
conditional_func(old_on_attach, true, client, bufnr)
|
||||
astronvim.lsp.on_attach(client, bufnr)
|
||||
conditional_func(user_on_attach, true, client, bufnr)
|
||||
end
|
||||
return opts
|
||||
end
|
||||
|
||||
function astronvim.lsp.disable_formatting(client)
|
||||
client.resolved_capabilities.document_formatting = false
|
||||
end
|
||||
|
||||
return astronvim.lsp
|
||||
@@ -0,0 +1,55 @@
|
||||
local status_ok, lspconfig = pcall(require, "lspconfig")
|
||||
if status_ok then
|
||||
require "configs.lsp.handlers"
|
||||
local insert = table.insert
|
||||
local tbl_contains = vim.tbl_contains
|
||||
local sign_define = vim.fn.sign_define
|
||||
local user_plugin_opts = astronvim.user_plugin_opts
|
||||
local user_registration = user_plugin_opts("lsp.server_registration", nil, false)
|
||||
|
||||
local signs = {
|
||||
{ name = "DiagnosticSignError", text = "" },
|
||||
{ name = "DiagnosticSignWarn", text = "" },
|
||||
{ name = "DiagnosticSignHint", text = "" },
|
||||
{ name = "DiagnosticSignInfo", text = "" },
|
||||
}
|
||||
for _, sign in ipairs(signs) do
|
||||
sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" })
|
||||
end
|
||||
vim.diagnostic.config(user_plugin_opts("diagnostics", {
|
||||
virtual_text = true,
|
||||
signs = { active = signs },
|
||||
update_in_insert = true,
|
||||
underline = true,
|
||||
severity_sort = true,
|
||||
float = {
|
||||
focusable = false,
|
||||
style = "minimal",
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
header = "",
|
||||
prefix = "",
|
||||
},
|
||||
}))
|
||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" })
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" })
|
||||
|
||||
local servers = user_plugin_opts "lsp.servers"
|
||||
local skip_setup = user_plugin_opts "lsp.skip_setup"
|
||||
local installer_avail, lsp_installer = pcall(require, "nvim-lsp-installer")
|
||||
if installer_avail then
|
||||
for _, server in ipairs(lsp_installer.get_installed_servers()) do
|
||||
insert(servers, server.name)
|
||||
end
|
||||
end
|
||||
for _, server in ipairs(servers) do
|
||||
if not tbl_contains(skip_setup, server) then
|
||||
local opts = astronvim.lsp.server_settings(server)
|
||||
if type(user_registration) == "function" then
|
||||
user_registration(server, opts)
|
||||
else
|
||||
lspconfig[server].setup(opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1 @@
|
||||
return { on_attach = astronvim.lsp.disable_formatting }
|
||||
@@ -0,0 +1,17 @@
|
||||
return {
|
||||
on_attach = astronvim.lsp.disable_formatting,
|
||||
settings = {
|
||||
json = {
|
||||
schemas = require("schemastore").json.schemas(),
|
||||
},
|
||||
},
|
||||
setup = {
|
||||
commands = {
|
||||
Format = {
|
||||
function()
|
||||
vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 })
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
return {
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
typeCheckingMode = "off",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
return {
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
cargo = {
|
||||
loadOutDirsFromCheck = true,
|
||||
},
|
||||
checkOnSave = {
|
||||
command = "clippy",
|
||||
},
|
||||
experimental = {
|
||||
procAttrMacros = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
return {
|
||||
on_attach = astronvim.lsp.disable_formatting,
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
workspace = {
|
||||
library = {
|
||||
[vim.fn.expand "$VIMRUNTIME/lua"] = true,
|
||||
[astronvim.install.home .. "/lua"] = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
return { on_attach = astronvim.lsp.disable_formatting }
|
||||
@@ -0,0 +1,16 @@
|
||||
local user_settings = astronvim.user_plugin_opts "luasnip"
|
||||
local loader_avail, loader = pcall(require, "luasnip/loaders/from_vscode")
|
||||
if loader_avail then
|
||||
if user_settings.vscode_snippet_paths ~= nil then
|
||||
loader.lazy_load { paths = user_settings.vscode_snippet_paths }
|
||||
end
|
||||
loader.lazy_load()
|
||||
end
|
||||
local luasnip_avail, luasnip = pcall(require, "luasnip")
|
||||
if luasnip_avail then
|
||||
if type(user_settings.filetype_extend) == "table" then
|
||||
for filetype, snippets in pairs(user_settings.filetype_extend) do
|
||||
luasnip.filetype_extend(filetype, snippets)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,70 @@
|
||||
local status_ok, neotree = pcall(require, "neo-tree")
|
||||
if status_ok then
|
||||
neotree.setup(astronvim.user_plugin_opts("plugins.neo-tree", {
|
||||
close_if_last_window = true,
|
||||
popup_border_style = "rounded",
|
||||
enable_diagnostics = false,
|
||||
default_component_configs = {
|
||||
indent = {
|
||||
padding = 0,
|
||||
with_expanders = false,
|
||||
},
|
||||
icon = {
|
||||
folder_closed = "",
|
||||
folder_open = "",
|
||||
folder_empty = "",
|
||||
default = "",
|
||||
},
|
||||
git_status = {
|
||||
symbols = {
|
||||
added = "",
|
||||
deleted = "",
|
||||
modified = "",
|
||||
renamed = "➜",
|
||||
untracked = "★",
|
||||
ignored = "◌",
|
||||
unstaged = "✗",
|
||||
staged = "✓",
|
||||
conflict = "",
|
||||
},
|
||||
},
|
||||
},
|
||||
window = {
|
||||
width = 25,
|
||||
mappings = {
|
||||
["o"] = "open",
|
||||
},
|
||||
},
|
||||
filesystem = {
|
||||
filtered_items = {
|
||||
visible = false,
|
||||
hide_dotfiles = true,
|
||||
hide_gitignored = false,
|
||||
hide_by_name = {
|
||||
".DS_Store",
|
||||
"thumbs.db",
|
||||
"node_modules",
|
||||
"__pycache__",
|
||||
},
|
||||
},
|
||||
follow_current_file = true,
|
||||
hijack_netrw_behavior = "open_current",
|
||||
use_libuv_file_watcher = true,
|
||||
},
|
||||
git_status = {
|
||||
window = {
|
||||
position = "float",
|
||||
},
|
||||
},
|
||||
event_handlers = {
|
||||
{
|
||||
event = "vim_buffer_enter",
|
||||
handler = function(_)
|
||||
if vim.bo.filetype == "neo-tree" then
|
||||
vim.wo.signcolumn = "auto"
|
||||
end
|
||||
end,
|
||||
},
|
||||
},
|
||||
}))
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
local status_ok, notify = pcall(require, "notify")
|
||||
if status_ok then
|
||||
notify.setup(astronvim.user_plugin_opts("plugins.notify", { stages = "fade" }))
|
||||
|
||||
vim.notify = notify
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
local status_ok, null_ls = pcall(require, "null-ls")
|
||||
if status_ok then
|
||||
null_ls.setup(astronvim.user_plugin_opts "plugins.null-ls")
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer")
|
||||
if status_ok then
|
||||
lsp_installer.setup(astronvim.user_plugin_opts("plugins.nvim-lsp-installer", {
|
||||
ui = {
|
||||
icons = {
|
||||
server_installed = "✓",
|
||||
server_uninstalled = "✗",
|
||||
server_pending = "⟳",
|
||||
},
|
||||
},
|
||||
}))
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
local status_ok, session_manager = pcall(require, "session_manager")
|
||||
if status_ok then
|
||||
session_manager.setup(astronvim.user_plugin_opts("plugins.session_manager", { autosave_last_session = false }))
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
local status_ok, smart_splits = pcall(require, "smart-splits")
|
||||
if status_ok then
|
||||
smart_splits.setup(astronvim.user_plugin_opts("plugins.smart-splits", {
|
||||
ignored_filetypes = {
|
||||
"nofile",
|
||||
"quickfix",
|
||||
"qf",
|
||||
"prompt",
|
||||
},
|
||||
ignored_buftypes = { "nofile" },
|
||||
}))
|
||||
end
|
||||
@@ -0,0 +1,96 @@
|
||||
local status_ok, telescope = pcall(require, "telescope")
|
||||
if status_ok then
|
||||
local actions = require "telescope.actions"
|
||||
|
||||
astronvim.conditional_func(telescope.load_extension, pcall(require, "notify"), "notify")
|
||||
astronvim.conditional_func(telescope.load_extension, pcall(require, "aerial"), "aerial")
|
||||
|
||||
telescope.setup(astronvim.user_plugin_opts("plugins.telescope", {
|
||||
defaults = {
|
||||
|
||||
prompt_prefix = " ",
|
||||
selection_caret = "❯ ",
|
||||
path_display = { "truncate" },
|
||||
selection_strategy = "reset",
|
||||
sorting_strategy = "ascending",
|
||||
layout_strategy = "horizontal",
|
||||
layout_config = {
|
||||
horizontal = {
|
||||
prompt_position = "top",
|
||||
preview_width = 0.55,
|
||||
results_width = 0.8,
|
||||
},
|
||||
vertical = {
|
||||
mirror = false,
|
||||
},
|
||||
width = 0.87,
|
||||
height = 0.80,
|
||||
preview_cutoff = 120,
|
||||
},
|
||||
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-n>"] = actions.cycle_history_next,
|
||||
["<C-p>"] = actions.cycle_history_prev,
|
||||
|
||||
["<C-j>"] = actions.move_selection_next,
|
||||
["<C-k>"] = actions.move_selection_previous,
|
||||
|
||||
["<C-c>"] = actions.close,
|
||||
|
||||
["<Down>"] = actions.move_selection_next,
|
||||
["<Up>"] = actions.move_selection_previous,
|
||||
|
||||
["<CR>"] = actions.select_default,
|
||||
["<C-x>"] = actions.select_horizontal,
|
||||
["<C-v>"] = actions.select_vertical,
|
||||
["<C-t>"] = actions.select_tab,
|
||||
|
||||
["<C-u>"] = actions.preview_scrolling_up,
|
||||
["<C-d>"] = actions.preview_scrolling_down,
|
||||
|
||||
["<PageUp>"] = actions.results_scrolling_up,
|
||||
["<PageDown>"] = actions.results_scrolling_down,
|
||||
|
||||
["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
|
||||
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
|
||||
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
|
||||
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
|
||||
["<C-l>"] = actions.complete_tag,
|
||||
},
|
||||
|
||||
n = {
|
||||
["<esc>"] = actions.close,
|
||||
["<CR>"] = actions.select_default,
|
||||
["<C-x>"] = actions.select_horizontal,
|
||||
["<C-v>"] = actions.select_vertical,
|
||||
["<C-t>"] = actions.select_tab,
|
||||
|
||||
["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
|
||||
["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
|
||||
["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
|
||||
["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
|
||||
|
||||
["j"] = actions.move_selection_next,
|
||||
["k"] = actions.move_selection_previous,
|
||||
["H"] = actions.move_to_top,
|
||||
["M"] = actions.move_to_middle,
|
||||
["L"] = actions.move_to_bottom,
|
||||
|
||||
["<Down>"] = actions.move_selection_next,
|
||||
["<Up>"] = actions.move_selection_previous,
|
||||
["gg"] = actions.move_to_top,
|
||||
["G"] = actions.move_to_bottom,
|
||||
|
||||
["<C-u>"] = actions.preview_scrolling_up,
|
||||
["<C-d>"] = actions.preview_scrolling_down,
|
||||
|
||||
["<PageUp>"] = actions.results_scrolling_up,
|
||||
["<PageDown>"] = actions.results_scrolling_down,
|
||||
},
|
||||
},
|
||||
},
|
||||
pickers = {},
|
||||
extensions = {},
|
||||
}))
|
||||
end
|
||||
@@ -0,0 +1,16 @@
|
||||
local status_ok, toggleterm = pcall(require, "toggleterm")
|
||||
if status_ok then
|
||||
toggleterm.setup(astronvim.user_plugin_opts("plugins.toggleterm", {
|
||||
size = 10,
|
||||
open_mapping = [[<c-\>]],
|
||||
shading_factor = 2,
|
||||
direction = "float",
|
||||
float_opts = {
|
||||
border = "curved",
|
||||
highlights = {
|
||||
border = "Normal",
|
||||
background = "Normal",
|
||||
},
|
||||
},
|
||||
}))
|
||||
end
|
||||
@@ -0,0 +1,26 @@
|
||||
local status_ok, treesitter = pcall(require, "nvim-treesitter.configs")
|
||||
if status_ok then
|
||||
treesitter.setup(astronvim.user_plugin_opts("plugins.treesitter", {
|
||||
ensure_installed = {},
|
||||
sync_install = false,
|
||||
ignore_install = {},
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
context_commentstring = {
|
||||
enable = true,
|
||||
enable_autocmd = false,
|
||||
},
|
||||
rainbow = {
|
||||
enable = true,
|
||||
disable = { "html" },
|
||||
extended_mode = false,
|
||||
max_file_lines = nil,
|
||||
},
|
||||
autopairs = { enable = true },
|
||||
autotag = { enable = true },
|
||||
incremental_selection = { enable = true },
|
||||
indent = { enable = false },
|
||||
}))
|
||||
end
|
||||
@@ -0,0 +1,61 @@
|
||||
local status_ok, which_key = pcall(require, "which-key")
|
||||
if status_ok then
|
||||
local is_available = astronvim.is_available
|
||||
local user_plugin_opts = astronvim.user_plugin_opts
|
||||
local mappings = {
|
||||
n = {
|
||||
["<leader>"] = {
|
||||
f = { name = "File" },
|
||||
p = { name = "Packer" },
|
||||
l = { name = "LSP" },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local extra_sections = {
|
||||
g = "Git",
|
||||
s = "Search",
|
||||
S = "Session",
|
||||
t = "Terminal",
|
||||
}
|
||||
|
||||
local function init_table(mode, prefix, idx)
|
||||
if not mappings[mode][prefix][idx] then
|
||||
mappings[mode][prefix][idx] = { name = extra_sections[idx] }
|
||||
end
|
||||
end
|
||||
|
||||
if is_available "neovim-session-manager" then
|
||||
init_table("n", "<leader>", "S")
|
||||
end
|
||||
|
||||
if is_available "gitsigns.nvim" then
|
||||
init_table("n", "<leader>", "g")
|
||||
end
|
||||
|
||||
if is_available "toggleterm.nvim" then
|
||||
init_table("n", "<leader>", "g")
|
||||
init_table("n", "<leader>", "t")
|
||||
end
|
||||
|
||||
if is_available "telescope.nvim" then
|
||||
init_table("n", "<leader>", "s")
|
||||
init_table("n", "<leader>", "g")
|
||||
end
|
||||
|
||||
mappings = user_plugin_opts("which-key.register_mappings", mappings)
|
||||
-- support previous legacy notation, deprecate at some point
|
||||
mappings.n["<leader>"] = user_plugin_opts("which-key.register_n_leader", mappings.n["<leader>"])
|
||||
for mode, prefixes in pairs(mappings) do
|
||||
for prefix, mapping_table in pairs(prefixes) do
|
||||
which_key.register(mapping_table, {
|
||||
mode = mode,
|
||||
prefix = prefix,
|
||||
buffer = nil,
|
||||
silent = true,
|
||||
noremap = true,
|
||||
nowait = true,
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,21 @@
|
||||
local status_ok, which_key = pcall(require, "which-key")
|
||||
if status_ok then
|
||||
local show = which_key.show
|
||||
local show_override = astronvim.user_plugin_opts("which-key.show", nil, false)
|
||||
which_key.show = type(show_override) == "function" and show_override(show)
|
||||
or function(keys, opts)
|
||||
if vim.bo.filetype ~= "TelescopePrompt" then
|
||||
show(keys, opts)
|
||||
end
|
||||
end
|
||||
which_key.setup(astronvim.user_plugin_opts("plugins.which-key", {
|
||||
plugins = {
|
||||
spelling = { enabled = true },
|
||||
presets = { operators = false },
|
||||
},
|
||||
window = {
|
||||
border = "rounded",
|
||||
padding = { 2, 2, 2, 2 },
|
||||
},
|
||||
}))
|
||||
end
|
||||
Reference in New Issue
Block a user