misc clean

This commit is contained in:
siduck 2024-02-27 12:31:36 +05:30
parent a5fc21b4f1
commit afd8870358
5 changed files with 93 additions and 129 deletions

View File

@ -136,12 +136,3 @@ local new_cmd = vim.api.nvim_create_user_command
new_cmd("NvChadUpdate", function() new_cmd("NvChadUpdate", function()
require "nvchad.updater"() require "nvchad.updater"()
end, {}) end, {})
--------------------------------------- globals -------------------------------------------
vim.g.whichkey_maps = true
vim.g.blankline_maps = true
vim.g.terminal_maps = true
vim.g.telescope_maps = true
vim.g.nvimtree_maps = true
vim.g.comment_maps = true
vim.g.tabufline_maps = true

View File

@ -6,7 +6,6 @@ map("i", "<C-h>", "<Left>", { desc = "Move left | general" })
map("i", "<C-l>", "<Right>", { desc = "Move right | general" }) map("i", "<C-l>", "<Right>", { desc = "Move right | general" })
map("i", "<C-j>", "<Down>", { desc = "Move down | general" }) map("i", "<C-j>", "<Down>", { desc = "Move down | general" })
map("i", "<C-k>", "<Up>", { desc = "Move up | general" }) map("i", "<C-k>", "<Up>", { desc = "Move up | general" })
map("n", "<Esc>", "<cmd>noh<CR>", { desc = "Clear highlights | general" }) map("n", "<Esc>", "<cmd>noh<CR>", { desc = "Clear highlights | general" })
map("n", "<C-h>", "<C-w>h", { desc = "Window left | general" }) map("n", "<C-h>", "<C-w>h", { desc = "Window left | general" })
map("n", "<C-l>", "<C-w>l", { desc = "Window right | general" }) map("n", "<C-l>", "<C-w>l", { desc = "Window right | general" })
@ -19,134 +18,107 @@ map("n", "<leader>rn", "<cmd>set rnu!<CR>", { desc = "Toggle relative number | g
map("n", "<leader>b", "<cmd>enew<CR>", { desc = "New buffer | general" }) map("n", "<leader>b", "<cmd>enew<CR>", { desc = "New buffer | general" })
map("n", "<leader>ch", "<cmd>NvCheatsheet<CR>", { desc = "Mapping cheatsheet | general" }) map("n", "<leader>ch", "<cmd>NvCheatsheet<CR>", { desc = "Mapping cheatsheet | general" })
-- global lsp mappings
map("n", "<leader>fm", function() map("n", "<leader>fm", function()
vim.lsp.buf.format { async = true } vim.lsp.buf.format { async = true }
end, { desc = "LSP formatting | lsp" }) end, { desc = "LSP formatting | lsp" })
vim.keymap.set("n", "<leader>lf", vim.diagnostic.open_float, { desc = "floating diagnostics | lsp" }) map("n", "<leader>lf", vim.diagnostic.open_float, { desc = "floating diagnostics | lsp" })
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "prev diagnostic | lsp" }) map("n", "[d", vim.diagnostic.goto_prev, { desc = "prev diagnostic | lsp" })
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "next diagnostic | lsp" }) map("n", "]d", vim.diagnostic.goto_next, { desc = "next diagnostic | lsp" })
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, { desc = "diagnostic loclist | lsp" }) map("n", "<leader>q", vim.diagnostic.setloclist, { desc = "diagnostic loclist | lsp" })
-- tabufline
map("n", "<tab>", function()
require("nvchad.tabufline").tabuflineNext()
end, { desc = "Goto next buffer | tabufline" })
map("n", "<S-tab>", function()
require("nvchad.tabufline").tabuflinePrev()
end, { desc = "Goto prev buffer | tabufline" })
map("n", "<leader>x", function()
require("nvchad.tabufline").close_buffer()
end, { desc = "Close buffer | tabufline" })
map("n", "<leader>/", function()
require("Comment.api").toggle.linewise.current()
end, { desc = "Toggle comment | comment" })
-- Mappings for terminal mode
map( map(
"t", "v",
"<C-x>", "<leader>/",
vim.api.nvim_replace_termcodes("<C-\\><C-N>", true, true, true), "<ESC>:lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>",
{ desc = "Escape terminal mode | general" } { desc = "Toggle comment | comment" }
) )
-- Mappings for M.tabufline map("n", "<C-n>", "<cmd>NvimTreeToggle<CR>", { desc = "Toggle nvimtree | nvimtree" })
if vim.g.tabufline_maps then map("n", "<leader>e", "<cmd>NvimTreeFocus<CR>", { desc = "Focus nvimtree | nvimtree" })
map("n", "<tab>", function()
require("nvchad.tabufline").tabuflineNext()
end, { desc = "Goto next buffer | tabufline" })
map("n", "<S-tab>", function() map("n", "<leader>fw", "<cmd>Telescope live_grep<CR>", { desc = "Live grep | telescope" })
require("nvchad.tabufline").tabuflinePrev() map("n", "<leader>fb", "<cmd>Telescope buffers<CR>", { desc = "Find buffers | telescope" })
end, { desc = "Goto prev buffer | tabufline" }) map("n", "<leader>fh", "<cmd>Telescope help_tags<CR>", { desc = "Help page | telescope" })
map("n", "<leader>fo", "<cmd>Telescope oldfiles<CR>", { desc = "Find oldfiles | telescope" })
map("n", "<leader>fz", "<cmd>Telescope current_buffer_fuzzy_find<CR>", { desc = "Find in current buffer | telescope" })
map("n", "<leader>cm", "<cmd>Telescope git_commits<CR>", { desc = "Git commits | telescope" })
map("n", "<leader>gt", "<cmd>Telescope git_status<CR>", { desc = "Git status | telescope" })
map("n", "<leader>pt", "<cmd>Telescope terms<CR>", { desc = "Pick hidden term | telescope" })
map("n", "<leader>th", "<cmd>Telescope themes<CR>", { desc = "Nvchad themes | telescope" })
map("n", "<leader>ff", "<cmd>Telescope find_files<cr>", { desc = "Find files | telescope" })
map("n", "<leader>x", function() map(
require("nvchad.tabufline").close_buffer() "n",
end, { desc = "Close buffer | tabufline" }) "<leader>fa",
end "<cmd>Telescope find_files follow=true no_ignore=true hidden=true<CR>",
{ desc = "Find all | telescope" }
)
if vim.g.comment_maps then -- terminal
map("n", "<leader>/", function() map("t", "<C-x>", "<C-\\><C-N>", { desc = "Escape terminal mode | terminal" })
require("Comment.api").toggle.linewise.current() map("n", "<leader>h", function()
end, { desc = "Toggle comment | comment" }) require("nvchad.term").new { pos = "sp", size = 0.3 }
end, { desc = "New horizontal term | terminal" })
map( map("n", "<leader>v", function()
"v", require("nvchad.term").new { pos = "vsp", size = 0.3 }
"<leader>/", end, { desc = "New vertical term | terminal" })
"<ESC><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>",
{ desc = "Toggle comment | comment" }
)
end
if vim.g.nvimtree_maps then map({ "n", "t" }, "<A-v>", function()
map("n", "<C-n>", "<cmd>NvimTreeToggle<CR>", { desc = "Toggle nvimtree | nvimtree" }) require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm", size = 0.3 }
map("n", "<leader>e", "<cmd>NvimTreeFocus<CR>", { desc = "Focus nvimtree | nvimtree" }) end, { desc = "Toggleable vertical term | terminal" })
end
if vim.g.telescope_maps then map({ "n", "t" }, "<A-h>", function()
map("n", "<leader>fw", "<cmd>Telescope live_grep<CR>", { desc = "Live grep | telescope" }) require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm", size = 0.2 }
map("n", "<leader>fb", "<cmd>Telescope buffers<CR>", { desc = "Find buffers | telescope" }) end, { desc = "New horizontal term | terminal" })
map("n", "<leader>fh", "<cmd>Telescope help_tags<CR>", { desc = "Help page | telescope" })
map("n", "<leader>fo", "<cmd>Telescope oldfiles<CR>", { desc = "Find oldfiles | telescope" })
map( map({ "n", "t" }, "<A-i>", function()
"n", require("nvchad.term").toggle { pos = "float", id = "floatTerm" }
"<leader>fz", end, { desc = "Toggleable Floating term | terminal" })
"<cmd>Telescope current_buffer_fuzzy_find<CR>",
{ desc = "Find in current buffer | telescope" }
)
map("n", "<leader>cm", "<cmd>Telescope git_commits<CR>", { desc = "Git commits | telescope" }) map("t", "<ESC>", function()
map("n", "<leader>gt", "<cmd>Telescope git_status<CR>", { desc = "Git status | telescope" }) local win = vim.api.nvim_get_current_win()
map("n", "<leader>pt", "<cmd>Telescope terms<CR>", { desc = "Pick hidden term | telescope" }) vim.api.nvim_win_close(win, true)
map("n", "<leader>th", "<cmd>Telescope themes<CR>", { desc = "Nvchad themes | telescope" }) end, { desc = "Close term in terminal mode | terminal" })
map("n", "<leader>ff", "<cmd>Telescope find_files<CR>", { desc = "Find files | telescope" }) -- whichkey
map( map("n", "<leader>wK", "<cmd>WhichKey <CR>", { desc = "Which-key all keymaps | whichkey" })
"n", map("n", "<leader>wk", function()
"<leader>fa", vim.cmd("WhichKey " .. vim.fn.input "WhichKey: ")
"<cmd>Telescope find_files follow=true no_ignore=true hidden=true<CR>", end, { desc = "Which-key query lookup | whichkey" })
{ desc = "Find all | telescope" }
)
end
-- Mappings for M.terminal map("n", "<leader>cc", function()
if vim.g.terminal_maps then local config = { scope = {} }
map("n", "<leader>h", function() config.scope.exclude = { language = {}, node_type = {} }
require("nvchad.term").new { pos = "sp", size = 0.3 } config.scope.include = { node_type = {} }
end, { desc = "New horizontal term | terminal" }) local node = require("ibl.scope").get(vim.api.nvim_get_current_buf(), config)
map("n", "<leader>v", function() if node then
require("nvchad.term").new { pos = "vsp", size = 0.3 } local start_row, _, end_row, _ = node:range()
end, { desc = "New vertical term | terminal" }) if start_row ~= end_row then
vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start_row + 1, 0 })
map({ "n", "t" }, "<A-v>", function() vim.api.nvim_feedkeys("_", "n", true)
require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm", size = 0.3 }
end, { desc = "Toggleable vertical term | terminal" })
map({ "n", "t" }, "<A-h>", function()
require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm", size = 0.2 }
end, { desc = "New horizontal term | terminal" })
map({ "n", "t" }, "<A-i>", function()
require("nvchad.term").toggle { pos = "float", id = "floatTerm" }
end, { desc = "Toggleable Floating term | terminal" })
map("t", "<ESC>", function()
local win = vim.api.nvim_get_current_win()
vim.api.nvim_win_close(win, true)
end, { desc = "Close term in terminal mode | terminal" })
end
if vim.g.whichkey_maps then
map("n", "<leader>wK", ":WhichKey <CR>", { desc = "Which-key all keymaps | whichkey" })
map("n", "<leader>wk", function()
vim.cmd("WhichKey " .. vim.fn.input "WhichKey: ")
end, { desc = "Which-key query lookup | whichkey" })
end
if vim.g.blankline_maps then
map("n", "<leader>cc", function()
local config = { scope = {} }
config.scope.exclude = { language = {}, node_type = {} }
config.scope.include = { node_type = {} }
local node = require("ibl.scope").get(vim.api.nvim_get_current_buf(), config)
if node then
local start_row, _, end_row, _ = node:range()
if start_row ~= end_row then
vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start_row + 1, 0 })
vim.api.nvim_feedkeys("_", "n", true)
end
end end
end, { desc = "Jump to current context | blankline" }) end
end end, { desc = "Jump to current context | blankline" })
pcall(require, "custom.mappings") pcall(require, "custom.mappings")

View File

@ -75,10 +75,12 @@ local options = {
["<C-f>"] = cmp.mapping.scroll_docs(4), ["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(), ["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.close(), ["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm { ["<CR>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Insert, behavior = cmp.ConfirmBehavior.Insert,
select = true, select = true,
}, },
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
@ -87,10 +89,8 @@ local options = {
else else
fallback() fallback()
end end
end, { end, { "i", "s" }),
"i",
"s",
}),
["<S-Tab>"] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
@ -99,10 +99,7 @@ local options = {
else else
fallback() fallback()
end end
end, { end, { "i", "s" }),
"i",
"s",
}),
}, },
sources = { sources = {
{ name = "nvim_lsp" }, { name = "nvim_lsp" },

View File

@ -31,7 +31,11 @@ M.on_attach = function(client, bufnr)
end, opts "List workspace folders | lsp") end, opts "List workspace folders | lsp")
map("n", "<leader>D", vim.lsp.buf.type_definition, opts "Go to type definition | lsp") map("n", "<leader>D", vim.lsp.buf.type_definition, opts "Go to type definition | lsp")
map("n", "<leader>rn", vim.lsp.buf.rename, opts "Rename symbol | lsp")
map("n", "<leader>ra", function()
require "nvchad.renamer"()
end, opts "NvRename symbol | lsp")
map({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts "Code action | lsp") map({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts "Code action | lsp")
map("n", "gr", vim.lsp.buf.references, opts "Show references | lsp") map("n", "gr", vim.lsp.buf.references, opts "Show references | lsp")
end end

View File

@ -81,7 +81,7 @@ local default_plugins = {
"lewis6991/gitsigns.nvim", "lewis6991/gitsigns.nvim",
event = "User FilePost", event = "User FilePost",
opts = function() opts = function()
return require("plugins.configs.gitsigns") return require "plugins.configs.gitsigns"
end, end,
config = function(_, opts) config = function(_, opts)
dofile(vim.g.base46_cache .. "git") dofile(vim.g.base46_cache .. "git")