add formatters and cool stuff

This commit is contained in:
Youwen Wu 2024-10-10 00:48:10 -07:00
parent adcd621763
commit c3ee469ed5
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3
10 changed files with 766 additions and 697 deletions

View file

@ -1 +1,2 @@
indent_type = "Spaces"
indent_width = 2

View file

@ -151,6 +151,12 @@
lua-language-server
nixd
nixfmt-rfc-style
nodePackages_latest.prettier
taplo
typstyle
rustfmt
black
stylua
];
};
@ -226,6 +232,7 @@
diffview-nvim
barbecue-nvim
undotree
conform-nvim
];
};

View file

@ -9,10 +9,10 @@ vim.keymap.set("t", "<C-Esc>", "<C-\\><C-n>")
vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz")
vim.keymap.set("n", "<leader>mr", function ()
vim.keymap.set("n", "<leader>mr", function()
vim.cmd.CellularAutomaton("make_it_rain")
end)
vim.keymap.set("n", "<leader>bruh", function ()
vim.keymap.set("n", "<leader>bruh", function()
vim.cmd.CellularAutomaton("game_of_life")
end)
@ -21,21 +21,39 @@ vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")
-- The greatest remap of all time -- the primeagen
vim.keymap.set({"n", "v"}, "<leader>d",'"_d', { desc = "same as `d` but send to black hole register"})
vim.keymap.set({"n", "v"}, "<leader>D",'"_D', { desc = "same as `D` but send to black hole register"})
vim.keymap.set({ "n", "v" }, "<leader>d", '"_d', { desc = "same as `d` but send to black hole register" })
vim.keymap.set({ "n", "v" }, "<leader>D", '"_D', { desc = "same as `D` but send to black hole register" })
-- The real greatest remap(s) of all time -- me
vim.keymap.set({"n", "v"}, "<leader>y",'"+y', { desc = "yank to clipboard"})
vim.keymap.set({"n", "v"}, "<leader>Y",'"+Y', { desc = "yank rest of line to clipboard"})
vim.keymap.set({"n", "v"}, "<leader>p",'"+p', { desc = "put after cursor from clipboard"})
vim.keymap.set({"n", "v"}, "<leader>P",'"+P', { desc = "put before cursor from clipboard"})
vim.keymap.set({ "n", "v" }, "<leader>y", '"+y', { desc = "yank to clipboard" })
vim.keymap.set({ "n", "v" }, "<leader>Y", '"+Y', { desc = "yank rest of line to clipboard" })
vim.keymap.set({ "n", "v" }, "<leader>p", '"+p', { desc = "put after cursor from clipboard" })
vim.keymap.set({ "n", "v" }, "<leader>P", '"+P', { desc = "put before cursor from clipboard" })
vim.keymap.set("n", "<leader>gg", function ()
vim.keymap.set("n", "<leader>gg", function()
vim.cmd.Neogit()
end, { desc = "Open neogit" })
vim.keymap.set("n", "<leader>gc", function ()
vim.keymap.set("n", "<leader>gc", function()
vim.cmd.Neogit("kind=floating commit")
end, { desc = "Open neogit commit menu" })
vim.keymap.set("n", "<leader>u", function ()
vim.keymap.set("n", "<leader>u", function()
vim.cmd.UndotreeToggle()
end, {desc = "Toggle undotree"})
end, { desc = "Toggle undotree" })
vim.keymap.set({ "n", "v" }, "<leader>cf", function()
require("conform").format({ async = true })
end)
vim.keymap.set({ "n", "v" }, "<leader>ctf", function()
if vim.g.disable_autoformat then
vim.g.disable_autoformat = false
else
vim.g.disable_autoformat = true
end
end, { desc = "Disable autoformat on save globally" })
vim.keymap.set({ "n", "v" }, "<leader>cbf", function()
if vim.b[0].disable_autoformat then
vim.b[0].disable_autoformat = false
else
vim.b[0].disable_autoformat = true
end
end, { desc = "Disable autoformat on save buffer" })

View file

@ -1,242 +1,242 @@
return {
"blink-cmp",
event = "BufEnter",
after = function()
require("blink-cmp").setup({
-- for keymap, all values may be string | string[]
-- use an empty table to disable a keymap
keymap = {
show = "<C-space>",
hide = "<C-e>",
accept = "<Tab>",
select_prev = { "<Up>", "<C-p>" },
select_next = { "<Down>", "<C-n>" },
"blink-cmp",
event = "BufEnter",
after = function()
require("blink-cmp").setup({
-- for keymap, all values may be string | string[]
-- use an empty table to disable a keymap
keymap = {
show = "<C-space>",
hide = "<C-e>",
accept = "<Tab>",
select_prev = { "<Up>", "<C-p>" },
select_next = { "<Down>", "<C-n>" },
show_documentation = {},
hide_documentation = {},
scroll_documentation_up = "<C-b>",
scroll_documentation_down = "<C-f>",
show_documentation = {},
hide_documentation = {},
scroll_documentation_up = "<C-b>",
scroll_documentation_down = "<C-f>",
snippet_forward = "<Tab>",
snippet_backward = "<S-Tab>",
snippet_forward = "<Tab>",
snippet_backward = "<S-Tab>",
},
accept = {
create_undo_point = true,
auto_brackets = {
enabled = false,
default_brackets = { "(", ")" },
override_brackets_for_filetypes = {},
-- Overrides the default blocked filetypes
force_allow_filetypes = {},
blocked_filetypes = {},
-- Synchronously use the kind of the item to determine if brackets should be added
kind_resolution = {
enabled = true,
blocked_filetypes = { "typescript", "typescriptreact", "javascript", "javascriptreact", "vue" },
},
-- Asynchronously use semantic token to determine if brackets should be added
semantic_token_resolution = {
enabled = true,
blocked_filetypes = {},
},
},
},
trigger = {
completion = {
-- regex used to get the text when fuzzy matching
-- changing this may break some sources, so please report if you run into issues
-- todo: shouldnt this also affect the accept command? should this also be per language?
keyword_regex = "[%w_\\-]",
-- LSPs can indicate when to show the completion window via trigger characters
-- however, some LSPs (*cough* tsserver *cough*) return characters that would essentially
-- always show the window. We block these by default
blocked_trigger_characters = { " ", "\n", "\t" },
-- when true, will show the completion window when the cursor comes after a trigger character when entering insert mode
show_on_insert_on_trigger_character = true,
},
signature_help = {
enabled = false,
blocked_trigger_characters = {},
blocked_retrigger_characters = {},
-- when true, will show the signature help window when the cursor comes after a trigger character when entering insert mode
show_on_insert_on_trigger_character = true,
},
},
fuzzy = {
-- frencency tracks the most recently/frequently used items and boosts the score of the item
use_frecency = true,
-- proximity bonus boosts the score of items with a value in the buffer
use_proximity = true,
max_items = 200,
-- controls which sorts to use and in which order, these three are currently the only allowed options
sorts = { "label", "kind", "score" },
prebuiltBinaries = {
-- Whether or not to automatically download a prebuilt binary from github. If this is set to `false`
-- you will need to manually build the fuzzy binary dependencies by running `cargo build --release`
download = false,
-- When downloading a prebuilt binary force the downloader to resolve this version. If this is uset
-- then the downloader will attempt to infer the version from the checked out git tag (if any).
--
-- Beware that if the FFI ABI changes while tracking main then this may result in blink breaking.
forceVersion = nil,
},
},
sources = {
-- similar to nvim-cmp's sources, but we point directly to the source's lua module
-- multiple groups can be provided, where it'll fallback to the next group if the previous
-- returns no completion items
-- WARN: This API will have breaking changes during the beta
providers = {
{
{ "blink.cmp.sources.lsp" },
{ "blink.cmp.sources.path" },
{ "blink.cmp.sources.snippets", score_offset = -3 },
},
{ { "blink.cmp.sources.buffer" } },
},
-- FOR REF: full example
providers = {
{
-- all of these properties work on every source
{
"blink.cmp.sources.lsp",
keyword_length = 0,
score_offset = 0,
trigger_characters = { "f", "o", "o" },
opts = {},
},
accept = {
create_undo_point = true,
auto_brackets = {
enabled = false,
default_brackets = { "(", ")" },
override_brackets_for_filetypes = {},
-- Overrides the default blocked filetypes
force_allow_filetypes = {},
blocked_filetypes = {},
-- Synchronously use the kind of the item to determine if brackets should be added
kind_resolution = {
enabled = true,
blocked_filetypes = { "typescript", "typescriptreact", "javascript", "javascriptreact", "vue" },
},
-- Asynchronously use semantic token to determine if brackets should be added
semantic_token_resolution = {
enabled = true,
blocked_filetypes = {},
},
},
-- the follow two sources have additional options
{
"blink.cmp.sources.path",
opts = {
trailing_slash = false,
label_trailing_slash = true,
get_cwd = function(context)
return vim.fn.expand(("#%d:p:h"):format(context.bufnr))
end,
show_hidden_files_by_default = true,
},
},
trigger = {
completion = {
-- regex used to get the text when fuzzy matching
-- changing this may break some sources, so please report if you run into issues
-- todo: shouldnt this also affect the accept command? should this also be per language?
keyword_regex = "[%w_\\-]",
-- LSPs can indicate when to show the completion window via trigger characters
-- however, some LSPs (*cough* tsserver *cough*) return characters that would essentially
-- always show the window. We block these by default
blocked_trigger_characters = { " ", "\n", "\t" },
-- when true, will show the completion window when the cursor comes after a trigger character when entering insert mode
show_on_insert_on_trigger_character = true,
},
signature_help = {
enabled = false,
blocked_trigger_characters = {},
blocked_retrigger_characters = {},
-- when true, will show the signature help window when the cursor comes after a trigger character when entering insert mode
show_on_insert_on_trigger_character = true,
},
{
"blink.cmp.sources.snippets",
score_offset = -3,
-- similar to https://github.com/garymjr/nvim-snippets
opts = {
friendly_snippets = true,
search_paths = { vim.fn.stdpath("config") .. "/snippets" },
global_snippets = { "all" },
extended_filetypes = {},
ignored_filetypes = {},
},
},
},
{ { "blink.cmp.sources.buffer" } },
},
},
fuzzy = {
-- frencency tracks the most recently/frequently used items and boosts the score of the item
use_frecency = true,
-- proximity bonus boosts the score of items with a value in the buffer
use_proximity = true,
max_items = 200,
-- controls which sorts to use and in which order, these three are currently the only allowed options
sorts = { "label", "kind", "score" },
windows = {
autocomplete = {
min_width = 30,
max_width = 60,
max_height = 10,
border = "none",
winhighlight = "Normal:BlinkCmpMenu,FloatBorder:BlinkCmpMenuBorder,CursorLine:BlinkCmpMenuSelection,Search:None",
-- keep the cursor X lines away from the top/bottom of the window
scrolloff = 2,
-- which directions to show the window,
-- falling back to the next direction when there's not enough space
direction_priority = { "s", "n" },
-- whether to preselect the first item in the completion list
preselect = true,
-- Controls how the completion items are rendered on the popup window
-- 'simple' will render the item's kind icon the left alongside the label
-- 'reversed' will render the label on the left and the kind icon + name on the right
-- 'function(blink.cmp.CompletionRenderContext): blink.cmp.Component[]' for custom rendering
draw = "simple",
-- Controls the cycling behavior when reaching the beginning or end of the completion list.
cycle = {
-- When `true`, calling `select_next` at the *bottom* of the completion list will select the *first* completion item.
from_bottom = true,
-- When `true`, calling `select_prev` at the *top* of the completion list will select the *last* completion item.
from_top = true,
},
},
documentation = {
min_width = 10,
max_width = 60,
max_height = 20,
border = "padded",
winhighlight = "Normal:BlinkCmpDoc,FloatBorder:BlinkCmpDocBorder,CursorLine:BlinkCmpDocCursorLine,Search:None",
-- which directions to show the documentation window,
-- for each of the possible autocomplete window directions,
-- falling back to the next direction when there's not enough space
direction_priority = {
autocomplete_north = { "e", "w", "n", "s" },
autocomplete_south = { "e", "w", "s", "n" },
},
auto_show = true,
auto_show_delay_ms = 500,
update_delay_ms = 100,
},
signature_help = {
min_width = 1,
max_width = 100,
max_height = 10,
border = "padded",
winhighlight = "Normal:BlinkCmpSignatureHelp,FloatBorder:BlinkCmpSignatureHelpBorder",
},
},
prebuiltBinaries = {
-- Whether or not to automatically download a prebuilt binary from github. If this is set to `false`
-- you will need to manually build the fuzzy binary dependencies by running `cargo build --release`
download = true,
-- When downloading a prebuilt binary force the downloader to resolve this version. If this is uset
-- then the downloader will attempt to infer the version from the checked out git tag (if any).
--
-- Beware that if the FFI ABI changes while tracking main then this may result in blink breaking.
forceVersion = nil,
},
},
highlight = {
ns = vim.api.nvim_create_namespace("blink_cmp"),
-- 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,
},
sources = {
-- similar to nvim-cmp's sources, but we point directly to the source's lua module
-- multiple groups can be provided, where it'll fallback to the next group if the previous
-- returns no completion items
-- WARN: This API will have breaking changes during the beta
providers = {
{
{ "blink.cmp.sources.lsp" },
{ "blink.cmp.sources.path" },
{ "blink.cmp.sources.snippets", score_offset = -3 },
},
{ { "blink.cmp.sources.buffer" } },
},
-- FOR REF: full example
providers = {
{
-- all of these properties work on every source
{
"blink.cmp.sources.lsp",
keyword_length = 0,
score_offset = 0,
trigger_characters = { "f", "o", "o" },
opts = {},
},
-- the follow two sources have additional options
{
"blink.cmp.sources.path",
opts = {
trailing_slash = false,
label_trailing_slash = true,
get_cwd = function(context)
return vim.fn.expand(("#%d:p:h"):format(context.bufnr))
end,
show_hidden_files_by_default = true,
},
},
{
"blink.cmp.sources.snippets",
score_offset = -3,
-- similar to https://github.com/garymjr/nvim-snippets
opts = {
friendly_snippets = true,
search_paths = { vim.fn.stdpath("config") .. "/snippets" },
global_snippets = { "all" },
extended_filetypes = {},
ignored_filetypes = {},
},
},
},
{ { "blink.cmp.sources.buffer" } },
},
},
-- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
-- adjusts spacing to ensure icons are aligned
nerd_font_variant = "normal",
windows = {
autocomplete = {
min_width = 30,
max_width = 60,
max_height = 10,
border = "none",
winhighlight = "Normal:BlinkCmpMenu,FloatBorder:BlinkCmpMenuBorder,CursorLine:BlinkCmpMenuSelection,Search:None",
-- keep the cursor X lines away from the top/bottom of the window
scrolloff = 2,
-- which directions to show the window,
-- falling back to the next direction when there's not enough space
direction_priority = { "s", "n" },
-- whether to preselect the first item in the completion list
preselect = true,
-- Controls how the completion items are rendered on the popup window
-- 'simple' will render the item's kind icon the left alongside the label
-- 'reversed' will render the label on the left and the kind icon + name on the right
-- 'function(blink.cmp.CompletionRenderContext): blink.cmp.Component[]' for custom rendering
draw = "simple",
-- Controls the cycling behavior when reaching the beginning or end of the completion list.
cycle = {
-- When `true`, calling `select_next` at the *bottom* of the completion list will select the *first* completion item.
from_bottom = true,
-- When `true`, calling `select_prev` at the *top* of the completion list will select the *last* completion item.
from_top = true,
},
},
documentation = {
min_width = 10,
max_width = 60,
max_height = 20,
border = "padded",
winhighlight = "Normal:BlinkCmpDoc,FloatBorder:BlinkCmpDocBorder,CursorLine:BlinkCmpDocCursorLine,Search:None",
-- which directions to show the documentation window,
-- for each of the possible autocomplete window directions,
-- falling back to the next direction when there's not enough space
direction_priority = {
autocomplete_north = { "e", "w", "n", "s" },
autocomplete_south = { "e", "w", "s", "n" },
},
auto_show = true,
auto_show_delay_ms = 500,
update_delay_ms = 100,
},
signature_help = {
min_width = 1,
max_width = 100,
max_height = 10,
border = "padded",
winhighlight = "Normal:BlinkCmpSignatureHelp,FloatBorder:BlinkCmpSignatureHelpBorder",
},
},
kind_icons = {
Text = "󰉿",
Method = "󰊕",
Function = "󰊕",
Constructor = "󰒓",
highlight = {
ns = vim.api.nvim_create_namespace("blink_cmp"),
-- 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,
},
Field = "󰜢",
Variable = "󰆦",
Property = "󰖷",
-- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
-- adjusts spacing to ensure icons are aligned
nerd_font_variant = "normal",
Class = "󱡠",
Interface = "󱡠",
Struct = "󱡠",
Module = "󰅩",
kind_icons = {
Text = "󰉿",
Method = "󰊕",
Function = "󰊕",
Constructor = "󰒓",
Unit = "󰪚",
Value = "󰦨",
Enum = "󰦨",
EnumMember = "󰦨",
Field = "󰜢",
Variable = "󰆦",
Property = "󰖷",
Keyword = "󰻾",
Constant = "󰏿",
Class = "󱡠",
Interface = "󱡠",
Struct = "󱡠",
Module = "󰅩",
Unit = "󰪚",
Value = "󰦨",
Enum = "󰦨",
EnumMember = "󰦨",
Keyword = "󰻾",
Constant = "󰏿",
Snippet = "󱄽",
Color = "󰏘",
File = "󰈔",
Reference = "󰬲",
Folder = "󰉋",
Event = "󱐋",
Operator = "󰪚",
TypeParameter = "󰬛",
},
})
end,
Snippet = "󱄽",
Color = "󰏘",
File = "󰈔",
Reference = "󰬲",
Folder = "󰉋",
Event = "󱐋",
Operator = "󰪚",
TypeParameter = "󰬛",
},
})
end,
}

34
lua/plugins/conform.lua Normal file
View file

@ -0,0 +1,34 @@
return {
"conform.nvim",
event = "BufWritePre",
cmd = "ConformInfo",
after = function()
require("conform").setup({
format_on_save = function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
return { timeout_ms = 500, lsp_fallback = true }
end,
default_format_opts = {
lsp_format = "fallback",
},
formatters_by_ft = {
lua = { "stylua" },
python = { "black" },
rust = { "rustfmt" },
javascript = { "prettierd", "prettier", stop_after_first = true },
typescript = { "prettierd", "prettier", stop_after_first = true },
nix = { "nixfmt" },
haskell = { "fourmolu", "ormolu", stop_after_first = true },
json = { "prettierd", "prettier", stop_after_first = true },
toml = { "taplo", stop_after_first = true },
yaml = { "prettierd", "prettier", stop_after_first = true },
typst = { "typstyle" },
},
})
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
end,
}

View file

@ -1,45 +1,45 @@
return {
"harpoon2",
after = function()
local harpoon = require("harpoon")
"harpoon2",
after = function()
local harpoon = require("harpoon")
vim.keymap.set("n", "<leader>a", function()
harpoon:list():add()
end)
vim.keymap.set("n", "<C-h><C-a>", function()
harpoon:list():select(1)
end)
vim.keymap.set("n", "<C-h><C-s>", function()
harpoon:list():select(2)
end)
vim.keymap.set("n", "<C-h><C-d>", function()
harpoon:list():select(3)
end)
vim.keymap.set("n", "<C-h><C-f>", function()
harpoon:list():select(4)
end)
vim.keymap.set("n", "<leader>a", function()
harpoon:list():add()
end)
vim.keymap.set("n", "<C-h><C-a>", function()
harpoon:list():select(1)
end)
vim.keymap.set("n", "<C-h><C-s>", function()
harpoon:list():select(2)
end)
vim.keymap.set("n", "<C-h><C-d>", function()
harpoon:list():select(3)
end)
vim.keymap.set("n", "<C-h><C-f>", function()
harpoon:list():select(4)
end)
local conf = require("telescope.config").values
local function toggle_telescope(harpoon_files)
local file_paths = {}
for _, item in ipairs(harpoon_files.items) do
table.insert(file_paths, item.value)
end
local conf = require("telescope.config").values
local function toggle_telescope(harpoon_files)
local file_paths = {}
for _, item in ipairs(harpoon_files.items) do
table.insert(file_paths, item.value)
end
require("telescope.pickers")
.new({}, {
prompt_title = "Harpoon",
finder = require("telescope.finders").new_table({
results = file_paths,
}),
previewer = conf.file_previewer({}),
sorter = conf.generic_sorter({}),
})
:find()
end
require("telescope.pickers")
.new({}, {
prompt_title = "Harpoon",
finder = require("telescope.finders").new_table({
results = file_paths,
}),
previewer = conf.file_previewer({}),
sorter = conf.generic_sorter({}),
})
:find()
end
vim.keymap.set("n", "<C-h><C-h>", function()
toggle_telescope(harpoon:list())
end, { desc = "Open harpoon window" })
end,
}
vim.keymap.set("n", "<C-h><C-h>", function()
toggle_telescope(harpoon:list())
end, { desc = "Open harpoon window" })
end,
}

View file

@ -1,58 +1,57 @@
return {
"lualine.nvim",
event = "BufEnter",
after = function()
require("lualine").setup({
options = {
icons_enabled = true,
theme = "auto",
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
disabled_filetypes = {
statusline = { "ministarter" },
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = true,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
},
},
sections = {
lualine_a = { "branch" },
lualine_b = {
function()
return require("lsp-progress").progress()
end,
},
lualine_c = { "progress", "filetype" },
lualine_x = { "encoding", "fileformat" },
lualine_y = { "diff", "diagnostics" },
lualine_z = { "location" },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {},
})
-- listen lsp-progress event and refresh lualine
vim.api.nvim_create_augroup("lualine_augroup", { clear = true })
vim.api.nvim_create_autocmd("User", {
group = "lualine_augroup",
pattern = "LspProgressStatusUpdated",
callback = require("lualine").refresh,
})
end,
"lualine.nvim",
event = "BufEnter",
after = function()
require("lualine").setup({
options = {
icons_enabled = true,
theme = "auto",
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
disabled_filetypes = {
statusline = { "ministarter" },
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = true,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
},
},
sections = {
lualine_a = { "branch" },
lualine_b = {
function()
return require("lsp-progress").progress()
end,
},
lualine_c = { "progress", "filetype" },
lualine_x = { "encoding", "fileformat" },
lualine_y = { "diff", "diagnostics" },
lualine_z = { "location" },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { "filename" },
lualine_x = { "location" },
lualine_y = {},
lualine_z = {},
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {},
})
-- listen lsp-progress event and refresh lualine
vim.api.nvim_create_augroup("lualine_augroup", { clear = true })
vim.api.nvim_create_autocmd("User", {
group = "lualine_augroup",
pattern = "LspProgressStatusUpdated",
callback = require("lualine").refresh,
})
end,
}

View file

@ -1,192 +1,190 @@
return {
require("plugins.blink-cmp"),
require("plugins.telescope"),
require("plugins.oil"),
require("plugins.harpoon"),
require("plugins.lualine"),
{ "lsp-progress",
after = function()
require("lsp-progress").setup({
client_format = function(client_name, spinner, series_messages)
if #series_messages == 0 then
return nil
end
return {
name = client_name,
body = spinner .. " " .. table.concat(series_messages, ", "),
}
end,
format = function(client_messages)
--- @param name string
--- @param msg string?
--- @return string
local function stringify(name, msg)
return msg and string.format("%s %s", name, msg) or name
end
require("plugins.blink-cmp"),
require("plugins.telescope"),
require("plugins.oil"),
require("plugins.harpoon"),
require("plugins.lualine"),
require("plugins.conform"),
{
"lsp-progress",
after = function()
require("lsp-progress").setup({
client_format = function(client_name, spinner, series_messages)
if #series_messages == 0 then
return nil
end
return {
name = client_name,
body = spinner .. " " .. table.concat(series_messages, ", "),
}
end,
format = function(client_messages)
--- @param name string
--- @param msg string?
--- @return string
local function stringify(name, msg)
return msg and string.format("%s %s", name, msg) or name
end
local sign = "󰆧" -- nf-fa-gear \uf013
local lsp_clients = vim.lsp.get_clients()
local messages_map = {}
for _, climsg in ipairs(client_messages) do
messages_map[climsg.name] = climsg.body
end
local sign = "󰆧" -- nf-fa-gear \uf013
local lsp_clients = vim.lsp.get_clients()
local messages_map = {}
for _, climsg in ipairs(client_messages) do
messages_map[climsg.name] = climsg.body
end
if #lsp_clients > 0 then
table.sort(lsp_clients, function(a, b)
return a.name < b.name
end)
local builder = {}
for _, cli in ipairs(lsp_clients) do
if
type(cli) == "table"
and type(cli.name) == "string"
and string.len(cli.name) > 0
then
if messages_map[cli.name] then
table.insert(builder, stringify(cli.name, messages_map[cli.name]))
else
table.insert(builder, stringify(cli.name))
if #lsp_clients > 0 then
table.sort(lsp_clients, function(a, b)
return a.name < b.name
end)
local builder = {}
for _, cli in ipairs(lsp_clients) do
if type(cli) == "table" and type(cli.name) == "string" and string.len(cli.name) > 0 then
if messages_map[cli.name] then
table.insert(builder, stringify(cli.name, messages_map[cli.name]))
else
table.insert(builder, stringify(cli.name))
end
end
end
if #builder > 0 then
return sign .. " " .. table.concat(builder, ", ")
end
end
if #builder > 0 then
return sign .. " " .. table.concat(builder, ", ")
end
end
return ""
end,
})
end
},
{ "telescope-ui-select.nvim", priority = 70 },
{
"nvim-autopairs",
event = "BufEnter",
after = function()
require("nvim-autopairs").setup()
return ""
end,
},
{
"nvim-lspconfig",
event = "BufEnter",
after = function()
require("lsp")
end,
},
{
"sleuth",
event = "BufEnter",
},
{
"which-key.nvim",
after = function()
require("which-key").setup({
delay = 1000,
})
end,
},
{ "nvim-web-devicons" },
{ "rose-pine" },
{ "render-markdown.nvim" },
{ "markdown-preview.nvim" },
{
"trouble.nvim",
event = "LspAttach",
after = function()
require("trouble").setup()
vim.keymap.set("n", "<leader>xx", function()
vim.cmd("Trouble diagnostics toggle")
end, { desc = "Diagnostics" })
vim.keymap.set("n", "<leader>xX", function()
vim.cmd("Trouble diagnostics toggle filter.buf=0")
end, { desc = "Buffer diagnostics" })
vim.keymap.set("n", "<leader>cs", function()
vim.cmd("Trouble symbols toggle")
end, { desc = "Symbols" })
vim.keymap.set("n", "<leader>cl", function()
vim.cmd("Trouble lsp toggle win.position=right")
end, { desc = "LSP definitions / references /..." })
vim.keymap.set("n", "<leader>ql", function()
vim.cmd("Trouble qflist toggle")
end, { desc = "Quickfix list (trouble)" })
end,
},
{
"typst-preview",
after = function()
require("typst-preview").setup({
dependencies_bin = {
["typst-preview"] = nixCats("bin.tinymist"),
["websocat"] = nixCats("bin.websocat"),
},
})
end,
},
{
"toggleterm.nvim",
after = function()
require("toggleterm").setup({
shade_terminals = false,
})
})
end,
},
{ "telescope-ui-select.nvim", priority = 70 },
{
"nvim-autopairs",
event = "BufEnter",
after = function()
require("nvim-autopairs").setup()
end,
},
{
"nvim-lspconfig",
event = "BufEnter",
after = function()
require("lsp")
end,
},
{
"sleuth",
event = "BufEnter",
},
{
"which-key.nvim",
after = function()
require("which-key").setup({
delay = 1000,
})
end,
},
{ "nvim-web-devicons" },
{ "rose-pine" },
{ "render-markdown.nvim" },
{ "markdown-preview.nvim" },
{
"trouble.nvim",
event = "LspAttach",
after = function()
require("trouble").setup()
vim.keymap.set("n", "<leader>xx", function()
vim.cmd("Trouble diagnostics toggle")
end, { desc = "Diagnostics" })
vim.keymap.set("n", "<leader>xX", function()
vim.cmd("Trouble diagnostics toggle filter.buf=0")
end, { desc = "Buffer diagnostics" })
vim.keymap.set("n", "<leader>cs", function()
vim.cmd("Trouble symbols toggle")
end, { desc = "Symbols" })
vim.keymap.set("n", "<leader>cl", function()
vim.cmd("Trouble lsp toggle win.position=right")
end, { desc = "LSP definitions / references /..." })
vim.keymap.set("n", "<leader>ql", function()
vim.cmd("Trouble qflist toggle")
end, { desc = "Quickfix list (trouble)" })
end,
},
{
"typst-preview",
after = function()
require("typst-preview").setup({
dependencies_bin = {
["typst-preview"] = nixCats("bin.tinymist"),
["websocat"] = nixCats("bin.websocat"),
},
})
end,
},
{
"toggleterm.nvim",
after = function()
require("toggleterm").setup({
shade_terminals = false,
})
vim.keymap.set({ "n", "t", "v" }, "<C-l>", function()
vim.cmd("ToggleTerm direction=float")
end)
vim.keymap.set("n", "<leader>tv", function()
vim.cmd("ToggleTerm direction=vertical")
end)
vim.keymap.set("n", "<leader>tt", function()
vim.cmd("ToggleTerm direction=horizontal")
end)
vim.keymap.set("n", "<leader>ts", function()
vim.cmd("TermSelect")
end)
end,
},
{
"mini.ai",
event = "BufEnter",
after = function()
require("mini.ai").setup()
end
},
{
"mini.surround",
event = "BufEnter",
after = function()
require("mini.surround").setup()
end
},
{
"mini.starter",
after = function ()
require("mini.starter").setup()
end
},
{
"mini.notify",
event = "BufEnter",
after = function ()
require("mini.notify").setup({
lsp_progress = { enable = false }
})
end
},
{
"mini.trailspace",
event = "BufEnter",
after = function ()
require("mini.trailspace").setup()
end
},
{
"cellular-automaton.nvim",
cmd = "CellularAutomaton",
},
{
"indent-blankline.nvim",
after = function ()
require("ibl").setup({
vim.keymap.set({ "n", "t", "v" }, "<C-l>", function()
vim.cmd("ToggleTerm direction=float")
end)
vim.keymap.set("n", "<leader>tv", function()
vim.cmd("ToggleTerm direction=vertical")
end)
vim.keymap.set("n", "<leader>tt", function()
vim.cmd("ToggleTerm direction=horizontal")
end)
vim.keymap.set("n", "<leader>ts", function()
vim.cmd("TermSelect")
end)
end,
},
{
"mini.ai",
event = "BufEnter",
after = function()
require("mini.ai").setup()
end,
},
{
"mini.surround",
event = "BufEnter",
after = function()
require("mini.surround").setup()
end,
},
{
"mini.starter",
after = function()
require("mini.starter").setup()
end,
},
{
"mini.notify",
event = "BufEnter",
after = function()
require("mini.notify").setup({
lsp_progress = { enable = false },
})
end,
},
{
"mini.trailspace",
event = "BufEnter",
after = function()
require("mini.trailspace").setup()
end,
},
{
"cellular-automaton.nvim",
cmd = "CellularAutomaton",
},
{
"indent-blankline.nvim",
after = function()
require("ibl").setup({
indent = {
char = "",
tab_char = "",
@ -201,127 +199,134 @@ return {
"toggleterm",
},
},
}
)
end
},
{
"mini.bufremove",
event = "BufEnter",
after = function ()
require("mini.bufremove").setup()
})
end,
},
{
"mini.bufremove",
event = "BufEnter",
after = function()
require("mini.bufremove").setup()
vim.keymap.set({"n", "v"}, "<leader>bd", function ()
MiniBufremove.delete()
end)
end
},
{
"mini.hipatterns",
event = "BufEnter",
after = function ()
require("mini.hipatterns").setup()
end
},
{
"gitsigns.nvim",
event = "BufEnter",
after = function ()
require('gitsigns').setup{
on_attach = function(bufnr)
local gitsigns = require('gitsigns')
vim.keymap.set({ "n", "v" }, "<leader>bd", function()
MiniBufremove.delete()
end)
end,
},
{
"mini.hipatterns",
event = "BufEnter",
after = function()
require("mini.hipatterns").setup()
end,
},
{
"gitsigns.nvim",
event = "BufEnter",
after = function()
require("gitsigns").setup({
on_attach = function(bufnr)
local gitsigns = require("gitsigns")
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map('n', ']c', function()
if vim.wo.diff then
vim.cmd.normal({']c', bang = true})
else
gitsigns.nav_hunk('next')
end
end)
-- Navigation
map("n", "]c", function()
if vim.wo.diff then
vim.cmd.normal({ "]c", bang = true })
else
gitsigns.nav_hunk("next")
end
end)
map('n', '[c', function()
if vim.wo.diff then
vim.cmd.normal({'[c', bang = true})
else
gitsigns.nav_hunk('prev')
end
end)
map("n", "[c", function()
if vim.wo.diff then
vim.cmd.normal({ "[c", bang = true })
else
gitsigns.nav_hunk("prev")
end
end)
-- Actions
map('n', '<leader>gs', gitsigns.stage_hunk)
map('n', '<leader>gr', gitsigns.reset_hunk)
map('v', '<leader>gs', function() gitsigns.stage_hunk {vim.fn.line('.'), vim.fn.line('v')} end)
map('v', '<leader>gr', function() gitsigns.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end)
map('n', '<leader>gS', gitsigns.stage_buffer)
map('n', '<leader>gu', gitsigns.undo_stage_hunk)
map('n', '<leader>gR', gitsigns.reset_buffer)
map('n', '<leader>gp', gitsigns.preview_hunk)
map('n', '<leader>gb', function() gitsigns.blame_line{full=true} end)
map('n', '<leader>gb', gitsigns.toggle_current_line_blame)
map('n', '<leader>gd', gitsigns.diffthis)
map('n', '<leader>gD', function() gitsigns.diffthis('~') end)
map('n', '<leader>gtd', gitsigns.toggle_deleted)
-- Actions
map("n", "<leader>gs", gitsigns.stage_hunk)
map("n", "<leader>gr", gitsigns.reset_hunk)
map("v", "<leader>gs", function()
gitsigns.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
end)
map("v", "<leader>gr", function()
gitsigns.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
end)
map("n", "<leader>gS", gitsigns.stage_buffer)
map("n", "<leader>gu", gitsigns.undo_stage_hunk)
map("n", "<leader>gR", gitsigns.reset_buffer)
map("n", "<leader>gp", gitsigns.preview_hunk)
map("n", "<leader>gb", function()
gitsigns.blame_line({ full = true })
end)
map("n", "<leader>gb", gitsigns.toggle_current_line_blame)
map("n", "<leader>gd", gitsigns.diffthis)
map("n", "<leader>gD", function()
gitsigns.diffthis("~")
end)
map("n", "<leader>gtd", gitsigns.toggle_deleted)
-- Text object
map({'o', 'x'}, 'ih', ':<C-U>Gitsigns select_hunk<CR>')
end
-- Text object
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>")
end,
})
end,
},
{
"neogit",
cmd = "Neogit",
after = function()
require("neogit").setup({
graph_style = "unicode",
integrations = {
telescope = true,
diffview = true,
},
})
end,
},
{
"diffiew.nvim",
cmd = { "DiffviewOpen", "DiffviewClose", "DiffviewToggleFiles", "DiffviewFocusFiles", "DiffviewRefresh" },
},
{
"barbecue.nvim",
event = "BufEnter",
after = function()
require("barbecue").setup()
-- triggers CursorHold event faster
vim.opt.updatetime = 200
require("barbecue").setup({
create_autocmd = false, -- prevent barbecue from updating itself automatically
})
vim.api.nvim_create_autocmd({
"WinResized",
"BufWinEnter",
"CursorHold",
"InsertLeave",
-- include this if you have set `show_modified` to `true`
"BufModifiedSet",
}, {
group = vim.api.nvim_create_augroup("barbecue.updater", {}),
callback = function()
require("barbecue.ui").update()
end,
})
end,
},
{
"undotree",
cmd = "UndotreeToggle",
},
}
end
},
{
"neogit",
cmd = "Neogit",
after = function ()
require("neogit").setup({
graph_style = "unicode",
integrations = {
telescope = true,
diffview = true
}
})
end
},
{
"diffiew.nvim",
cmd = {"DiffviewOpen", "DiffviewClose", "DiffviewToggleFiles", "DiffviewFocusFiles", "DiffviewRefresh"},
},
{
"barbecue.nvim",
event = "BufEnter",
after = function()
require("barbecue").setup()
-- triggers CursorHold event faster
vim.opt.updatetime = 200
require("barbecue").setup({
create_autocmd = false, -- prevent barbecue from updating itself automatically
})
vim.api.nvim_create_autocmd({
"WinResized",
"BufWinEnter",
"CursorHold",
"InsertLeave",
-- include this if you have set `show_modified` to `true`
"BufModifiedSet",
}, {
group = vim.api.nvim_create_augroup("barbecue.updater", {}),
callback = function()
require("barbecue.ui").update()
end,
})
end
},
{
"undotree",
cmd = "UndotreeToggle"
}
}

View file

@ -1,39 +1,39 @@
return {
"oil.nvim",
after = function()
require("oil").setup({
columns = {
"size",
"icon",
},
use_default_keymaps = false,
keymaps = {
["J"] = "actions.parent",
["Q"] = "actions.close",
["<C-h>"] = "actions.select_split",
["<C-l>"] = "actions.refresh",
["<C-p>"] = "actions.preview",
["<C-s>"] = "actions.select_vsplit",
["<C-t>"] = "actions.select_tab",
["<CR>"] = "actions.select",
["K"] = "actions.select",
["_"] = "actions.open_cwd",
["`"] = "actions.cd",
["g."] = "actions.toggle_hidden",
["g?"] = "actions.show_help",
["g\\"] = "actions.toggle_trash",
["gs"] = "actions.change_sort",
["gx"] = "actions.open_external",
["~"] = "actions.tcd",
},
})
"oil.nvim",
after = function()
require("oil").setup({
columns = {
"size",
"icon",
},
use_default_keymaps = false,
keymaps = {
["J"] = "actions.parent",
["Q"] = "actions.close",
["<C-h>"] = "actions.select_split",
["<C-l>"] = "actions.refresh",
["<C-p>"] = "actions.preview",
["<C-s>"] = "actions.select_vsplit",
["<C-t>"] = "actions.select_tab",
["<CR>"] = "actions.select",
["K"] = "actions.select",
["_"] = "actions.open_cwd",
["`"] = "actions.cd",
["g."] = "actions.toggle_hidden",
["g?"] = "actions.show_help",
["g\\"] = "actions.toggle_trash",
["gs"] = "actions.change_sort",
["gx"] = "actions.open_external",
["~"] = "actions.tcd",
},
})
vim.keymap.set("n", "<leader>e", function()
vim.cmd("Oil")
end, { desc = "Open file explorer in current file directory" })
vim.keymap.set("n", "<leader>e", function()
vim.cmd("Oil")
end, { desc = "Open file explorer in current file directory" })
vim.keymap.set("n", "<leader>fe", function()
vim.cmd("Oil " .. vim.fn.getcwd())
end, { desc = "Open file explorer in current working directory" })
end,
vim.keymap.set("n", "<leader>fe", function()
vim.cmd("Oil " .. vim.fn.getcwd())
end, { desc = "Open file explorer in current working directory" })
end,
}

View file

@ -1,36 +1,41 @@
return {
"telescope.nvim",
after = function()
require("telescope").setup({
extensions = {
["ui-select"] = {
require("telescope.themes").get_dropdown({}),
},
},
})
"telescope.nvim",
after = function()
require("telescope").setup({
extensions = {
["ui-select"] = {
require("telescope.themes").get_dropdown({}),
},
},
})
require("telescope").load_extension("ui-select")
require("telescope").load_extension("ui-select")
local builtin = require("telescope.builtin")
local builtin = require("telescope.builtin")
vim.keymap.set("n", "<leader> ", function()
local is_git = vim.fn.finddir(".git", vim.fn.getcwd() .. ";")
if is_git then
builtin.git_files()
else
builtin.find_files()
end
end, { desc = "Grep through all files tracked by git, or fall back to just cwd" })
vim.keymap.set("n", "<leader> ", function()
local is_git = vim.fn.finddir(".git", vim.fn.getcwd() .. ";")
if is_git then
builtin.git_files()
else
builtin.find_files()
end
end, { desc = "Grep through all files tracked by git, or fall back to just cwd" })
vim.keymap.set("n", "<leader>ff", builtin.find_files, { desc = "Grep through all files in cwd" })
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action)
vim.keymap.set("n", "<leader>/", builtin.live_grep)
vim.keymap.set("n", "<leader>k", builtin.buffers)
vim.keymap.set("n", "<leader>gd", builtin.lsp_definitions, { desc = "Go to LSP definition" })
vim.keymap.set("n", "<leader>gi", builtin.lsp_implementations, { desc = "Go to implementations" })
vim.keymap.set("n", "<leader>j", builtin.lsp_document_symbols, { desc = "Search through document symbols" })
vim.keymap.set("n", "<leader>fs", builtin.lsp_workspace_symbols, { desc = "Search through entire workspace symbols" })
vim.keymap.set("n", "<leader>fd", builtin.diagnostics, { desc = "Search through LSP diagnostics" })
end,
priority = 60
vim.keymap.set("n", "<leader>ff", builtin.find_files, { desc = "Grep through all files in cwd" })
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action)
vim.keymap.set("n", "<leader>/", builtin.live_grep)
vim.keymap.set("n", "<leader>k", builtin.buffers)
vim.keymap.set("n", "<leader>gd", builtin.lsp_definitions, { desc = "Go to LSP definition" })
vim.keymap.set("n", "<leader>gi", builtin.lsp_implementations, { desc = "Go to implementations" })
vim.keymap.set("n", "<leader>j", builtin.lsp_document_symbols, { desc = "Search through document symbols" })
vim.keymap.set(
"n",
"<leader>fs",
builtin.lsp_workspace_symbols,
{ desc = "Search through entire workspace symbols" }
)
vim.keymap.set("n", "<leader>fd", builtin.diagnostics, { desc = "Search through LSP diagnostics" })
end,
priority = 60,
}