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_width = 2
|
||||
|
|
|
@ -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
|
||||
];
|
||||
};
|
||||
|
||||
|
|
|
@ -39,3 +39,21 @@ end, { desc = "Open neogit commit menu" })
|
|||
vim.keymap.set("n", "<leader>u", function()
|
||||
vim.cmd.UndotreeToggle()
|
||||
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 = {
|
||||
-- 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,
|
||||
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).
|
||||
--
|
||||
|
|
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,
|
||||
}
|
|
@ -54,5 +54,4 @@ vim.api.nvim_create_autocmd("User", {
|
|||
callback = require("lualine").refresh,
|
||||
})
|
||||
end,
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,9 @@ return {
|
|||
require("plugins.oil"),
|
||||
require("plugins.harpoon"),
|
||||
require("plugins.lualine"),
|
||||
{ "lsp-progress",
|
||||
require("plugins.conform"),
|
||||
{
|
||||
"lsp-progress",
|
||||
after = function()
|
||||
require("lsp-progress").setup({
|
||||
client_format = function(client_name, spinner, series_messages)
|
||||
|
@ -37,11 +39,7 @@ return {
|
|||
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 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
|
||||
|
@ -56,7 +54,7 @@ return {
|
|||
return ""
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
},
|
||||
{ "telescope-ui-select.nvim", priority = 70 },
|
||||
{
|
||||
|
@ -148,36 +146,36 @@ return {
|
|||
event = "BufEnter",
|
||||
after = function()
|
||||
require("mini.ai").setup()
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mini.surround",
|
||||
event = "BufEnter",
|
||||
after = function()
|
||||
require("mini.surround").setup()
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mini.starter",
|
||||
after = function()
|
||||
require("mini.starter").setup()
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mini.notify",
|
||||
event = "BufEnter",
|
||||
after = function()
|
||||
require("mini.notify").setup({
|
||||
lsp_progress = { enable = false }
|
||||
lsp_progress = { enable = false },
|
||||
})
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mini.trailspace",
|
||||
event = "BufEnter",
|
||||
after = function()
|
||||
require("mini.trailspace").setup()
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
"cellular-automaton.nvim",
|
||||
|
@ -201,9 +199,8 @@ return {
|
|||
"toggleterm",
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
end
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mini.bufremove",
|
||||
|
@ -214,22 +211,22 @@ return {
|
|||
vim.keymap.set({ "n", "v" }, "<leader>bd", function()
|
||||
MiniBufremove.delete()
|
||||
end)
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mini.hipatterns",
|
||||
event = "BufEnter",
|
||||
after = function()
|
||||
require("mini.hipatterns").setup()
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
"gitsigns.nvim",
|
||||
event = "BufEnter",
|
||||
after = function()
|
||||
require('gitsigns').setup{
|
||||
require("gitsigns").setup({
|
||||
on_attach = function(bufnr)
|
||||
local gitsigns = require('gitsigns')
|
||||
local gitsigns = require("gitsigns")
|
||||
|
||||
local function map(mode, l, r, opts)
|
||||
opts = opts or {}
|
||||
|
@ -238,42 +235,50 @@ return {
|
|||
end
|
||||
|
||||
-- Navigation
|
||||
map('n', ']c', function()
|
||||
map("n", "]c", function()
|
||||
if vim.wo.diff then
|
||||
vim.cmd.normal({']c', bang = true})
|
||||
vim.cmd.normal({ "]c", bang = true })
|
||||
else
|
||||
gitsigns.nav_hunk('next')
|
||||
gitsigns.nav_hunk("next")
|
||||
end
|
||||
end)
|
||||
|
||||
map('n', '[c', function()
|
||||
map("n", "[c", function()
|
||||
if vim.wo.diff then
|
||||
vim.cmd.normal({'[c', bang = true})
|
||||
vim.cmd.normal({ "[c", bang = true })
|
||||
else
|
||||
gitsigns.nav_hunk('prev')
|
||||
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)
|
||||
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
|
||||
}
|
||||
end
|
||||
map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>")
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"neogit",
|
||||
|
@ -283,10 +288,10 @@ return {
|
|||
graph_style = "unicode",
|
||||
integrations = {
|
||||
telescope = true,
|
||||
diffview = true
|
||||
}
|
||||
diffview = true,
|
||||
},
|
||||
})
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
"diffiew.nvim",
|
||||
|
@ -318,10 +323,10 @@ return {
|
|||
require("barbecue.ui").update()
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
"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>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>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
|
||||
priority = 60,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue