more work
This commit is contained in:
parent
de17c084e8
commit
484f0e9715
4 changed files with 81 additions and 76 deletions
|
@ -1,7 +1,7 @@
|
|||
local icons = require("config.icons")
|
||||
local funcs = require("funcs")
|
||||
local f = require("funcs")
|
||||
|
||||
local maps = funcs.empty_map_table()
|
||||
local maps = f.empty_map_table()
|
||||
local sections = {
|
||||
p = { desc = icons.ui.Package .. " Packages" },
|
||||
b = { desc = icons.ui.Tab .. " Buffers" },
|
||||
|
@ -27,8 +27,8 @@ maps.n["|"] = { "<cmd>vsplit<cr>", desc = "Vertical split" }
|
|||
maps.n["\\"] = { "<cmd>split<cr>", desc = "Horizontal split" }
|
||||
maps.v["<"] = { "<gv", desc = "Unindent line" }
|
||||
maps.v[">"] = { ">gv", desc = "Indent line" }
|
||||
maps.n["<Leader>c"] = { function() funcs.buf_close() end, desc = "Close buffer" }
|
||||
maps.n["<Leader>C"] = { function() funcs.buf_close(0, true) end, desc = "Force close buffer" }
|
||||
maps.n["<Leader>c"] = { function() f.buf_close() end, desc = "Close buffer" }
|
||||
maps.n["<Leader>C"] = { function() f.buf_close(0, true) end, desc = "Force close buffer" }
|
||||
maps.n["<C-b>"] = { "<C-a>" }
|
||||
maps.n["<C-f>"] = { "<Nop>" }
|
||||
maps.i["<C-h>"] = { "<C-W>" }
|
||||
|
@ -61,7 +61,7 @@ maps.n["<Leader>pp"] = { function() require("lazy").profile() end, desc = "Profi
|
|||
maps.n["<Leader>pd"] = { function() require("lazy").debug() end, desc = "Debug" }
|
||||
maps.n["<Leader>p?"] = { function() require("lazy").help() end, desc = "Help" }
|
||||
|
||||
if funcs.is_available("bufferline.nvim") then
|
||||
if f.is_available("bufferline.nvim") then
|
||||
maps.n["<S-l>"] = { function() require("bufferline").cycle(1) end, desc = "Switch to next buffer" }
|
||||
maps.n["<S-h>"] = { function() require("bufferline").cycle(-1) end, desc = "Switch to previous buffer" }
|
||||
maps.n["<A-l>"] = { function() require("bufferline").move(1) end, desc = "Move buffer to next" }
|
||||
|
@ -86,7 +86,7 @@ if funcs.is_available("bufferline.nvim") then
|
|||
maps.n["<Leader>bst"] = { function() require("bufferline").sort_by("tabs") end, desc = "By tabs" }
|
||||
end
|
||||
|
||||
if funcs.is_available("Comment.nvim") then
|
||||
if f.is_available("Comment.nvim") then
|
||||
maps.n["<Leader>/"] = {
|
||||
function() require("Comment.api").toggle.linewise.count(vim.v.count > 0 and vim.v.count or 1) end,
|
||||
desc = "Toggle comment line",
|
||||
|
@ -97,7 +97,7 @@ if funcs.is_available("Comment.nvim") then
|
|||
}
|
||||
end
|
||||
|
||||
if funcs.is_available("gitsigns.nvim") then
|
||||
if f.is_available("gitsigns.nvim") then
|
||||
maps.n["<Leader>g"] = sections.g
|
||||
maps.n["]g"] = { function() require("gitsigns").next_hunk() end, desc = "Next Git hunk" }
|
||||
maps.n["[g"] = { function() require("gitsigns").prev_hunk() end, desc = "Previous Git hunk" }
|
||||
|
@ -112,21 +112,21 @@ if funcs.is_available("gitsigns.nvim") then
|
|||
maps.n["<Leader>gd"] = { function() require("gitsigns").diffthis() end, desc = "View Git diff" }
|
||||
end
|
||||
|
||||
if funcs.is_available("lf.nvim") then
|
||||
if f.is_available("lf.nvim") then
|
||||
maps.n["<Leader>e"] = { "<Cmd>Lf<CR>", desc = "File Manager" }
|
||||
end
|
||||
|
||||
if funcs.is_available("mason.nvim") then
|
||||
if f.is_available("mason.nvim") then
|
||||
maps.n["<Leader>pm"] = { "<cmd>Mason<cr>", desc = "Mason" }
|
||||
maps.n["<Leader>pM"] = { "<cmd>MasonUpdateAll<cr>", desc = "Update Mason Packages" }
|
||||
end
|
||||
|
||||
if funcs.is_available "aerial.nvim" then
|
||||
if f.is_available "aerial.nvim" then
|
||||
maps.n["<leader>l"] = sections.l
|
||||
maps.n["<leader>lS"] = { function() require("aerial").toggle() end, desc = "Symbols outline" }
|
||||
end
|
||||
|
||||
if funcs.is_available("telescope.nvim") then
|
||||
if f.is_available("telescope.nvim") then
|
||||
maps.n["<Leader>f"] = sections.f
|
||||
maps.n["<Leader>g"] = sections.g
|
||||
maps.n["<Leader>gb"] = {
|
||||
|
@ -187,33 +187,33 @@ if funcs.is_available("telescope.nvim") then
|
|||
}
|
||||
end
|
||||
|
||||
if funcs.is_available("toggleterm.nvim") then
|
||||
if f.is_available("toggleterm.nvim") then
|
||||
maps.n["<leader>t"] = sections.t
|
||||
if vim.fn.executable "lazygit" == 1 then
|
||||
maps.n["<leader>g"] = sections.g
|
||||
maps.n["<leader>gg"] = {
|
||||
function()
|
||||
local worktree = funcs.file_worktree()
|
||||
local worktree = f.file_worktree()
|
||||
local flags = worktree
|
||||
and (" --work-tree=%s --git-dir=%s"):format(worktree.toplevel, worktree.gitdir)
|
||||
or ""
|
||||
funcs.toggle_term_cmd("lazygit " .. flags)
|
||||
f.toggle_term_cmd("lazygit " .. flags)
|
||||
end,
|
||||
desc = "ToggleTerm lazygit",
|
||||
}
|
||||
maps.n["<leader>tl"] = maps.n["<leader>gg"]
|
||||
end
|
||||
if vim.fn.executable "node" == 1 then
|
||||
maps.n["<leader>tn"] = { function() funcs.toggle_term_cmd "node" end, desc = "ToggleTerm node" }
|
||||
maps.n["<leader>tn"] = { function() f.toggle_term_cmd "node" end, desc = "ToggleTerm node" }
|
||||
end
|
||||
if vim.fn.executable("gdu") == 1 then
|
||||
maps.n["<leader>tu"] = { function() funcs.toggle_term_cmd("gdu") end, desc = "ToggleTerm gdu" }
|
||||
maps.n["<leader>tu"] = { function() f.toggle_term_cmd("gdu") end, desc = "ToggleTerm gdu" }
|
||||
end
|
||||
if vim.fn.executable "btm" == 1 then
|
||||
maps.n["<leader>tt"] = { function() funcs.toggle_term_cmd "btm" end, desc = "ToggleTerm btm" }
|
||||
maps.n["<leader>tt"] = { function() f.toggle_term_cmd "btm" end, desc = "ToggleTerm btm" }
|
||||
end
|
||||
local python = vim.fn.executable "python" == 1 and "python" or vim.fn.executable "python3" == 1 and "python3"
|
||||
if python then maps.n["<leader>tp"] = { function() funcs.toggle_term_cmd(python) end, desc = "ToggleTerm python" } end
|
||||
if python then maps.n["<leader>tp"] = { function() f.toggle_term_cmd(python) end, desc = "ToggleTerm python" } end
|
||||
maps.n["<leader>tf"] = { "<cmd>ToggleTerm direction=float<cr>", desc = "ToggleTerm float" }
|
||||
maps.n["<leader>th"] = { "<cmd>ToggleTerm size=10 direction=horizontal<cr>", desc = "ToggleTerm horizontal split" }
|
||||
maps.n["<leader>tv"] = { "<cmd>ToggleTerm size=80 direction=vertical<cr>", desc = "ToggleTerm vertical split" }
|
||||
|
@ -224,7 +224,7 @@ if funcs.is_available("toggleterm.nvim") then
|
|||
-- maps.t["<C-'>"] = maps.n["<F7>"]
|
||||
end
|
||||
|
||||
if funcs.is_available "nvim-dap" then
|
||||
if f.is_available "nvim-dap" then
|
||||
local conditional_breakpoint = function()
|
||||
vim.ui.input({ prompt = "Condition: " }, function(condition)
|
||||
if condition then require("dap").set_breakpoint(condition) end
|
||||
|
@ -255,7 +255,7 @@ if funcs.is_available "nvim-dap" then
|
|||
maps.n["<leader>dR"] = { function() require("dap").repl.toggle() end, desc = "Toggle REPL" }
|
||||
maps.n["<leader>ds"] = { function() require("dap").run_to_cursor() end, desc = "Run To Cursor" }
|
||||
|
||||
if funcs.is_available "nvim-dap-ui" then
|
||||
if f.is_available "nvim-dap-ui" then
|
||||
maps.n["<leader>dE"] = {
|
||||
function()
|
||||
vim.ui.input({ prompt = "Expression: " }, function(expr)
|
||||
|
@ -270,7 +270,7 @@ if funcs.is_available "nvim-dap" then
|
|||
end
|
||||
end
|
||||
|
||||
if funcs.is_available "nvim-ufo" then
|
||||
if f.is_available "nvim-ufo" then
|
||||
maps.n["zR"] = { function() require("ufo").openAllFolds() end, desc = "Open all folds" }
|
||||
maps.n["zM"] = { function() require("ufo").closeAllFolds() end, desc = "Close all folds" }
|
||||
maps.n["zr"] = { function() require("ufo").openFoldsExceptKinds() end, desc = "Fold less" }
|
||||
|
@ -278,4 +278,4 @@ if funcs.is_available "nvim-ufo" then
|
|||
maps.n["zp"] = { function() require("ufo").peekFoldedLinesUnderCursor() end, desc = "Peek fold" }
|
||||
end
|
||||
|
||||
funcs.set_mappings(maps)
|
||||
f.set_mappings(maps)
|
||||
|
|
|
@ -147,4 +147,43 @@ function M.set_mappings(map_table, base)
|
|||
if package.loaded["which-key"] then M.which_key_register() end
|
||||
end
|
||||
|
||||
function M.lsp_on_attach(client, bufnr)
|
||||
local lsp_mappings = M.empty_map_table()
|
||||
|
||||
-- TODO: CONDITIONALLY GATE THIS
|
||||
lsp_mappings.n["<leader>lf"] = { function() vim.lsp.buf.format() end, desc = "Format" }
|
||||
|
||||
lsp_mappings.n["<leader>ld"] = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" }
|
||||
lsp_mappings.n["[d"] = { function() vim.diagnostic.goto_prev() end, desc = "Previous diagnostic" }
|
||||
lsp_mappings.n["]d"] = { function() vim.diagnostic.goto_next() end, desc = "Next diagnostic" }
|
||||
lsp_mappings.n["gl"] = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" }
|
||||
|
||||
if M.is_available("telescope.nvim") then
|
||||
lsp_mappings.n["<leader>lD"] = {
|
||||
function() require("telescope.builtin").diagnostics() end,
|
||||
desc = "Search diagnostics",
|
||||
}
|
||||
end
|
||||
|
||||
if M.is_available "mason-lspconfig.nvim" then
|
||||
lsp_mappings.n["<leader>li"] = { "<cmd>LspInfo<cr>", desc = "LSP information" }
|
||||
end
|
||||
|
||||
if M.is_available "null-ls.nvim" then
|
||||
lsp_mappings.n["<leader>lI"] = { "<cmd>NullLsInfo<cr>", desc = "Null-ls information" }
|
||||
end
|
||||
|
||||
if client.supports_method "textDocument/codeAction" then
|
||||
lsp_mappings.n["<leader>la"] = {
|
||||
function() vim.lsp.buf.code_action() end,
|
||||
desc = "LSP code action",
|
||||
}
|
||||
lsp_mappings.v["<leader>la"] = lsp_mappings.n["<leader>la"]
|
||||
end
|
||||
|
||||
M.set_mappings(lsp_mappings, { buffer = bufnr })
|
||||
end
|
||||
|
||||
|
||||
|
||||
return M
|
||||
|
|
|
@ -1,45 +1,9 @@
|
|||
local M = { "nvimtools/none-ls.nvim" }
|
||||
local f = require("funcs")
|
||||
|
||||
M.event = { "BufReadPre", "BufNewFile" }
|
||||
|
||||
M.dependencies = { "mason-null-ls.nvim" }
|
||||
|
||||
local lsp_maps = function(client, bufnr)
|
||||
local lsp_mappings = f.empty_map_table()
|
||||
|
||||
-- TODO: CONDITIONALLY GATE THIS
|
||||
lsp_mappings.n["<leader>lf"] = { function() vim.lsp.buf.format() end, desc = "Format" }
|
||||
|
||||
lsp_mappings.n["<leader>ld"] = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" }
|
||||
lsp_mappings.n["[d"] = { function() vim.diagnostic.goto_prev() end, desc = "Previous diagnostic" }
|
||||
lsp_mappings.n["]d"] = { function() vim.diagnostic.goto_next() end, desc = "Next diagnostic" }
|
||||
lsp_mappings.n["gl"] = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" }
|
||||
|
||||
if f.is_available("telescope.nvim") then
|
||||
lsp_mappings.n["<leader>lD"] = {
|
||||
function() require("telescope.builtin").diagnostics() end,
|
||||
desc = "Search diagnostics",
|
||||
}
|
||||
end
|
||||
|
||||
if f.is_available "mason-lspconfig.nvim" then
|
||||
lsp_mappings.n["<leader>li"] = { "<cmd>LspInfo<cr>", desc = "LSP information" }
|
||||
end
|
||||
|
||||
if f.is_available "null-ls.nvim" then
|
||||
lsp_mappings.n["<leader>lI"] = { "<cmd>NullLsInfo<cr>", desc = "Null-ls information" }
|
||||
end
|
||||
|
||||
if client.supports_method "textDocument/codeAction" then
|
||||
lsp_mappings.n["<leader>la"] = {
|
||||
function() vim.lsp.buf.code_action() end,
|
||||
desc = "LSP code action",
|
||||
}
|
||||
lsp_mappings.v["<leader>la"] = lsp_mappings.n["<leader>la"]
|
||||
end
|
||||
end
|
||||
|
||||
M.opts = function()
|
||||
local nls = require("null-ls")
|
||||
return {
|
||||
|
@ -55,7 +19,9 @@ M.opts = function()
|
|||
-- Various (yaml, markdown, json among others)
|
||||
nls.builtins.formatting.prettierd,
|
||||
},
|
||||
on_attach = lsp_maps
|
||||
on_attach = function()
|
||||
return { on_attach = require("funcs").lsp_on_attach }
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -4,23 +4,23 @@ M.main = "ibl"
|
|||
|
||||
M.event = { "BufReadPre", "BufNewFile" }
|
||||
|
||||
M.keys = {
|
||||
{
|
||||
"<c-c>",
|
||||
function()
|
||||
local ok, start = require("indent_blankline.utils").get_current_context(
|
||||
vim.g.indent_blankline_context_patterns,
|
||||
vim.g.indent_blankline_use_treesitter_scope
|
||||
)
|
||||
if ok then
|
||||
vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start, 0 })
|
||||
vim.cmd [[normal! _]]
|
||||
end
|
||||
end,
|
||||
desc = "Jump to context",
|
||||
},
|
||||
}
|
||||
|
||||
-- FIX: This keybind is broken and should be moved to config/keymaps.lua
|
||||
-- M.keys = {
|
||||
-- {
|
||||
-- "<c-c>",
|
||||
-- function()
|
||||
-- local ok, start = require("indent_blankline.utils").get_current_context(
|
||||
-- vim.g.indent_blankline_context_patterns,
|
||||
-- vim.g.indent_blankline_use_treesitter_scope
|
||||
-- )
|
||||
-- if ok then
|
||||
-- vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start, 0 })
|
||||
-- vim.cmd [[normal! _]]
|
||||
-- end
|
||||
-- end,
|
||||
-- desc = "Jump to context",
|
||||
-- },
|
||||
-- }
|
||||
|
||||
M.dependencies = {
|
||||
"nvim-treesitter",
|
||||
|
|
Loading…
Add table
Reference in a new issue