Fix: Whitespaces begone or something
This commit is contained in:
parent
7545885942
commit
4d66a5e231
11 changed files with 94 additions and 28 deletions
|
@ -17,13 +17,13 @@ map({ "n", "x" }, "<S-k>", "6k")
|
|||
map({ "n", "x" }, "M", "J", { desc = "Merge" }) -- Replace the join command
|
||||
map("n", "gh", vim.lsp.buf.hover, { desc = "Hover" }) -- Code action hover
|
||||
|
||||
|
||||
|
||||
-- Move to window using the <ctrl> hjkl keys
|
||||
map("n", "<C-h>", "<C-w>h", { desc = "Go to left window", remap = true })
|
||||
map("n", "<C-j>", "<C-w>j", { desc = "Go to lower window", remap = true })
|
||||
map("n", "<C-k>", "<C-w>k", { desc = "Go to upper window", remap = true })
|
||||
map("n", "<C-l>", "<C-w>l", { desc = "Go to right window", remap = true })
|
||||
|
||||
|
||||
-- Move between buffers
|
||||
map("n", "<S-h>", "<cmd>BufferLineCyclePrev<CR>", { desc = "Move buffer left", silent = true })
|
||||
map("n", "<S-l>", "<cmd>BufferLineCycleNext<CR>", { desc = "Move buffer right", silent = true })
|
||||
|
@ -50,6 +50,72 @@ map("n", "<leader>e", function()
|
|||
require("neo-tree.command").execute({ action = "show", position = "right", toggle = true, dir = vim.loop.cwd() })
|
||||
end, { desc = "Open Neotree", remap = true })
|
||||
|
||||
|
||||
-- Conform Formatting
|
||||
map({ "n", "v" }, "<leader>mp", function()
|
||||
require("conform").format({
|
||||
lsp_fallback = true,
|
||||
async = false,
|
||||
timeout_ms = 500,
|
||||
})
|
||||
end, { desc = "Format file or range (in visual mode)" })
|
||||
|
||||
-- diagnostic
|
||||
---@param next "f"|"b"
|
||||
---@param severity "ERROR"|"WARN"?
|
||||
local diagnostic_goto = function(next, severity)
|
||||
local go = (next == "f") and vim.diagnostic.goto_next or vim.diagnostic.goto_prev
|
||||
local severity_index = severity and vim.diagnostic.severity[severity] or nil
|
||||
return function()
|
||||
go({ severity = severity_index })
|
||||
end
|
||||
end
|
||||
map("n", "<leader>cd", vim.diagnostic.open_float, { desc = "Line Diagnostics" })
|
||||
map("n", "]d", diagnostic_goto("f"), { desc = "Next Diagnostic" })
|
||||
map("n", "[d", diagnostic_goto("b"), { desc = "Prev Diagnostic" })
|
||||
map("n", "]e", diagnostic_goto("f", "ERROR"), { desc = "Next Error" })
|
||||
map("n", "[e", diagnostic_goto("b", "ERROR"), { desc = "Prev Error" })
|
||||
map("n", "]w", diagnostic_goto("f", "WARN"), { desc = "Next Warning" })
|
||||
map("n", "[w", diagnostic_goto("b", "WARN"), { desc = "Prev Warning" })
|
||||
|
||||
----
|
||||
-- Plugins
|
||||
----
|
||||
|
||||
-- Telescope (fuzzy finder)
|
||||
local function telescope_git_fallback()
|
||||
vim.fn.system("git rev-parse --is-inside-work-tree")
|
||||
local is_git_repo = vim.v.shell_error == 0
|
||||
|
||||
if is_git_repo then
|
||||
require("telescope.builtin").git_files()
|
||||
else
|
||||
require("telescope.builtin").find_files()
|
||||
end
|
||||
end
|
||||
local function telescope_files()
|
||||
require("telescope.builtin").find_files({ cwd = vim.uv.cwd() })
|
||||
end
|
||||
local function telescope_oldfiles()
|
||||
require("telescope.builtin").oldfiles({ cwd = vim.uv.cwd() })
|
||||
end
|
||||
local function telescope_live_grep()
|
||||
vim.fn.system("git rev-parse --is-inside-work-tree")
|
||||
local is_git_repo = vim.v.shell_error == 0
|
||||
local git_root = vim.fn.fnamemodify(vim.fn.finddir(".git", ".;"), ":h")
|
||||
|
||||
require("telescope.builtin").live_grep({
|
||||
cwd = is_git_repo and git_root or vim.uv.cwd(),
|
||||
})
|
||||
end
|
||||
map("n", "<leader><space>", telescope_git_fallback, { desc = "Find files (git/fallback, cwd)" })
|
||||
map("n", "<leader>ff", telescope_files, { desc = "Find files (cwd)" })
|
||||
map("n", "<leader>fo", telescope_oldfiles, { desc = "Find files (cwd)" })
|
||||
map("n", "<leader>/", telescope_live_grep, { desc = "Live grep (cwd)" })
|
||||
map("n", "<leader>,", require("telescope.builtin").buffers, { desc = "Find buffers" })
|
||||
map("n", "<leader>\"", require("telescope.builtin").registers, { desc = "Find registers" })
|
||||
|
||||
|
||||
----
|
||||
-- Fixes
|
||||
----
|
||||
|
@ -80,3 +146,5 @@ map("t", "<C-k>", "<cmd>wincmd k<cr>", { desc = "Go to upper window" })
|
|||
map("t", "<C-l>", "<cmd>wincmd l<cr>", { desc = "Go to right window" })
|
||||
map("t", "<C-/>", "<cmd>close<cr>", { desc = "Hide Terminal" })
|
||||
map("t", "<c-_>", "<cmd>close<cr>", { desc = "which_key_ignore" })
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue