add formatters and cool stuff
This commit is contained in:
parent
adcd621763
commit
c3ee469ed5
10 changed files with 766 additions and 697 deletions
|
@ -1 +1,2 @@
|
||||||
indent_type = "Spaces"
|
indent_type = "Spaces"
|
||||||
|
indent_width = 2
|
||||||
|
|
|
@ -151,6 +151,12 @@
|
||||||
lua-language-server
|
lua-language-server
|
||||||
nixd
|
nixd
|
||||||
nixfmt-rfc-style
|
nixfmt-rfc-style
|
||||||
|
nodePackages_latest.prettier
|
||||||
|
taplo
|
||||||
|
typstyle
|
||||||
|
rustfmt
|
||||||
|
black
|
||||||
|
stylua
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -226,6 +232,7 @@
|
||||||
diffview-nvim
|
diffview-nvim
|
||||||
barbecue-nvim
|
barbecue-nvim
|
||||||
undotree
|
undotree
|
||||||
|
conform-nvim
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -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-d>", "<C-d>zz")
|
||||||
vim.keymap.set("n", "<C-u>", "<C-u>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")
|
vim.cmd.CellularAutomaton("make_it_rain")
|
||||||
end)
|
end)
|
||||||
vim.keymap.set("n", "<leader>bruh", function ()
|
vim.keymap.set("n", "<leader>bruh", function()
|
||||||
vim.cmd.CellularAutomaton("game_of_life")
|
vim.cmd.CellularAutomaton("game_of_life")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -21,21 +21,39 @@ vim.keymap.set("n", "n", "nzzzv")
|
||||||
vim.keymap.set("n", "N", "Nzzzv")
|
vim.keymap.set("n", "N", "Nzzzv")
|
||||||
|
|
||||||
-- The greatest remap of all time -- the primeagen
|
-- 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
|
-- 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 to clipboard" })
|
||||||
vim.keymap.set({"n", "v"}, "<leader>Y",'"+Y', { desc = "yank rest of line 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 after cursor from clipboard" })
|
||||||
vim.keymap.set({"n", "v"}, "<leader>P",'"+P', { desc = "put before 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()
|
vim.cmd.Neogit()
|
||||||
end, { desc = "Open 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")
|
vim.cmd.Neogit("kind=floating commit")
|
||||||
end, { desc = "Open neogit commit menu" })
|
end, { desc = "Open neogit commit menu" })
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>u", function ()
|
vim.keymap.set("n", "<leader>u", function()
|
||||||
vim.cmd.UndotreeToggle()
|
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" })
|
||||||
|
|
|
@ -78,7 +78,7 @@ return {
|
||||||
prebuiltBinaries = {
|
prebuiltBinaries = {
|
||||||
-- Whether or not to automatically download a prebuilt binary from github. If this is set to `false`
|
-- 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`
|
-- you will need to manually build the fuzzy binary dependencies by running `cargo build --release`
|
||||||
download = true,
|
download = false,
|
||||||
-- When downloading a prebuilt binary force the downloader to resolve this version. If this is uset
|
-- 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).
|
-- then the downloader will attempt to infer the version from the checked out git tag (if any).
|
||||||
--
|
--
|
||||||
|
|
34
lua/plugins/conform.lua
Normal file
34
lua/plugins/conform.lua
Normal 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,
|
||||||
|
}
|
|
@ -42,4 +42,4 @@ return {
|
||||||
toggle_telescope(harpoon:list())
|
toggle_telescope(harpoon:list())
|
||||||
end, { desc = "Open harpoon window" })
|
end, { desc = "Open harpoon window" })
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,13 +46,12 @@ return {
|
||||||
inactive_winbar = {},
|
inactive_winbar = {},
|
||||||
extensions = {},
|
extensions = {},
|
||||||
})
|
})
|
||||||
-- listen lsp-progress event and refresh lualine
|
-- listen lsp-progress event and refresh lualine
|
||||||
vim.api.nvim_create_augroup("lualine_augroup", { clear = true })
|
vim.api.nvim_create_augroup("lualine_augroup", { clear = true })
|
||||||
vim.api.nvim_create_autocmd("User", {
|
vim.api.nvim_create_autocmd("User", {
|
||||||
group = "lualine_augroup",
|
group = "lualine_augroup",
|
||||||
pattern = "LspProgressStatusUpdated",
|
pattern = "LspProgressStatusUpdated",
|
||||||
callback = require("lualine").refresh,
|
callback = require("lualine").refresh,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,9 @@ return {
|
||||||
require("plugins.oil"),
|
require("plugins.oil"),
|
||||||
require("plugins.harpoon"),
|
require("plugins.harpoon"),
|
||||||
require("plugins.lualine"),
|
require("plugins.lualine"),
|
||||||
{ "lsp-progress",
|
require("plugins.conform"),
|
||||||
|
{
|
||||||
|
"lsp-progress",
|
||||||
after = function()
|
after = function()
|
||||||
require("lsp-progress").setup({
|
require("lsp-progress").setup({
|
||||||
client_format = function(client_name, spinner, series_messages)
|
client_format = function(client_name, spinner, series_messages)
|
||||||
|
@ -37,11 +39,7 @@ return {
|
||||||
end)
|
end)
|
||||||
local builder = {}
|
local builder = {}
|
||||||
for _, cli in ipairs(lsp_clients) do
|
for _, cli in ipairs(lsp_clients) do
|
||||||
if
|
if type(cli) == "table" and type(cli.name) == "string" and string.len(cli.name) > 0 then
|
||||||
type(cli) == "table"
|
|
||||||
and type(cli.name) == "string"
|
|
||||||
and string.len(cli.name) > 0
|
|
||||||
then
|
|
||||||
if messages_map[cli.name] then
|
if messages_map[cli.name] then
|
||||||
table.insert(builder, stringify(cli.name, messages_map[cli.name]))
|
table.insert(builder, stringify(cli.name, messages_map[cli.name]))
|
||||||
else
|
else
|
||||||
|
@ -56,7 +54,7 @@ return {
|
||||||
return ""
|
return ""
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
{ "telescope-ui-select.nvim", priority = 70 },
|
{ "telescope-ui-select.nvim", priority = 70 },
|
||||||
{
|
{
|
||||||
|
@ -148,36 +146,36 @@ return {
|
||||||
event = "BufEnter",
|
event = "BufEnter",
|
||||||
after = function()
|
after = function()
|
||||||
require("mini.ai").setup()
|
require("mini.ai").setup()
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"mini.surround",
|
"mini.surround",
|
||||||
event = "BufEnter",
|
event = "BufEnter",
|
||||||
after = function()
|
after = function()
|
||||||
require("mini.surround").setup()
|
require("mini.surround").setup()
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"mini.starter",
|
"mini.starter",
|
||||||
after = function ()
|
after = function()
|
||||||
require("mini.starter").setup()
|
require("mini.starter").setup()
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"mini.notify",
|
"mini.notify",
|
||||||
event = "BufEnter",
|
event = "BufEnter",
|
||||||
after = function ()
|
after = function()
|
||||||
require("mini.notify").setup({
|
require("mini.notify").setup({
|
||||||
lsp_progress = { enable = false }
|
lsp_progress = { enable = false },
|
||||||
})
|
})
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"mini.trailspace",
|
"mini.trailspace",
|
||||||
event = "BufEnter",
|
event = "BufEnter",
|
||||||
after = function ()
|
after = function()
|
||||||
require("mini.trailspace").setup()
|
require("mini.trailspace").setup()
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cellular-automaton.nvim",
|
"cellular-automaton.nvim",
|
||||||
|
@ -185,7 +183,7 @@ return {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"indent-blankline.nvim",
|
"indent-blankline.nvim",
|
||||||
after = function ()
|
after = function()
|
||||||
require("ibl").setup({
|
require("ibl").setup({
|
||||||
indent = {
|
indent = {
|
||||||
char = "│",
|
char = "│",
|
||||||
|
@ -201,35 +199,34 @@ return {
|
||||||
"toggleterm",
|
"toggleterm",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
)
|
end,
|
||||||
end
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"mini.bufremove",
|
"mini.bufremove",
|
||||||
event = "BufEnter",
|
event = "BufEnter",
|
||||||
after = function ()
|
after = function()
|
||||||
require("mini.bufremove").setup()
|
require("mini.bufremove").setup()
|
||||||
|
|
||||||
vim.keymap.set({"n", "v"}, "<leader>bd", function ()
|
vim.keymap.set({ "n", "v" }, "<leader>bd", function()
|
||||||
MiniBufremove.delete()
|
MiniBufremove.delete()
|
||||||
end)
|
end)
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"mini.hipatterns",
|
"mini.hipatterns",
|
||||||
event = "BufEnter",
|
event = "BufEnter",
|
||||||
after = function ()
|
after = function()
|
||||||
require("mini.hipatterns").setup()
|
require("mini.hipatterns").setup()
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"gitsigns.nvim",
|
"gitsigns.nvim",
|
||||||
event = "BufEnter",
|
event = "BufEnter",
|
||||||
after = function ()
|
after = function()
|
||||||
require('gitsigns').setup{
|
require("gitsigns").setup({
|
||||||
on_attach = function(bufnr)
|
on_attach = function(bufnr)
|
||||||
local gitsigns = require('gitsigns')
|
local gitsigns = require("gitsigns")
|
||||||
|
|
||||||
local function map(mode, l, r, opts)
|
local function map(mode, l, r, opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
@ -238,59 +235,67 @@ return {
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Navigation
|
-- Navigation
|
||||||
map('n', ']c', function()
|
map("n", "]c", function()
|
||||||
if vim.wo.diff then
|
if vim.wo.diff then
|
||||||
vim.cmd.normal({']c', bang = true})
|
vim.cmd.normal({ "]c", bang = true })
|
||||||
else
|
else
|
||||||
gitsigns.nav_hunk('next')
|
gitsigns.nav_hunk("next")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
map('n', '[c', function()
|
map("n", "[c", function()
|
||||||
if vim.wo.diff then
|
if vim.wo.diff then
|
||||||
vim.cmd.normal({'[c', bang = true})
|
vim.cmd.normal({ "[c", bang = true })
|
||||||
else
|
else
|
||||||
gitsigns.nav_hunk('prev')
|
gitsigns.nav_hunk("prev")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Actions
|
-- Actions
|
||||||
map('n', '<leader>gs', gitsigns.stage_hunk)
|
map("n", "<leader>gs", gitsigns.stage_hunk)
|
||||||
map('n', '<leader>gr', gitsigns.reset_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>gs", function()
|
||||||
map('v', '<leader>gr', function() gitsigns.reset_hunk {vim.fn.line('.'), vim.fn.line('v')} end)
|
gitsigns.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
|
||||||
map('n', '<leader>gS', gitsigns.stage_buffer)
|
end)
|
||||||
map('n', '<leader>gu', gitsigns.undo_stage_hunk)
|
map("v", "<leader>gr", function()
|
||||||
map('n', '<leader>gR', gitsigns.reset_buffer)
|
gitsigns.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
|
||||||
map('n', '<leader>gp', gitsigns.preview_hunk)
|
end)
|
||||||
map('n', '<leader>gb', function() gitsigns.blame_line{full=true} end)
|
map("n", "<leader>gS", gitsigns.stage_buffer)
|
||||||
map('n', '<leader>gb', gitsigns.toggle_current_line_blame)
|
map("n", "<leader>gu", gitsigns.undo_stage_hunk)
|
||||||
map('n', '<leader>gd', gitsigns.diffthis)
|
map("n", "<leader>gR", gitsigns.reset_buffer)
|
||||||
map('n', '<leader>gD', function() gitsigns.diffthis('~') end)
|
map("n", "<leader>gp", gitsigns.preview_hunk)
|
||||||
map('n', '<leader>gtd', gitsigns.toggle_deleted)
|
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
|
-- Text object
|
||||||
map({'o', 'x'}, 'ih', ':<C-U>Gitsigns select_hunk<CR>')
|
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>")
|
||||||
end
|
end,
|
||||||
}
|
})
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"neogit",
|
"neogit",
|
||||||
cmd = "Neogit",
|
cmd = "Neogit",
|
||||||
after = function ()
|
after = function()
|
||||||
require("neogit").setup({
|
require("neogit").setup({
|
||||||
graph_style = "unicode",
|
graph_style = "unicode",
|
||||||
integrations = {
|
integrations = {
|
||||||
telescope = true,
|
telescope = true,
|
||||||
diffview = true
|
diffview = true,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"diffiew.nvim",
|
"diffiew.nvim",
|
||||||
cmd = {"DiffviewOpen", "DiffviewClose", "DiffviewToggleFiles", "DiffviewFocusFiles", "DiffviewRefresh"},
|
cmd = { "DiffviewOpen", "DiffviewClose", "DiffviewToggleFiles", "DiffviewFocusFiles", "DiffviewRefresh" },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"barbecue.nvim",
|
"barbecue.nvim",
|
||||||
|
@ -318,10 +323,10 @@ return {
|
||||||
require("barbecue.ui").update()
|
require("barbecue.ui").update()
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"undotree",
|
"undotree",
|
||||||
cmd = "UndotreeToggle"
|
cmd = "UndotreeToggle",
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,13 @@ return {
|
||||||
vim.keymap.set("n", "<leader>gd", builtin.lsp_definitions, { desc = "Go to LSP definition" })
|
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>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>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>fs",
|
||||||
|
builtin.lsp_workspace_symbols,
|
||||||
|
{ desc = "Search through entire workspace symbols" }
|
||||||
|
)
|
||||||
vim.keymap.set("n", "<leader>fd", builtin.diagnostics, { desc = "Search through LSP diagnostics" })
|
vim.keymap.set("n", "<leader>fd", builtin.diagnostics, { desc = "Search through LSP diagnostics" })
|
||||||
end,
|
end,
|
||||||
priority = 60
|
priority = 60,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue