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()
require "nvchad.updater"()
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-j>", "<Down>", { desc = "Move down | general" })
map("i", "<C-k>", "<Up>", { desc = "Move up | 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-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>ch", "<cmd>NvCheatsheet<CR>", { desc = "Mapping cheatsheet | general" })
-- global lsp mappings
map("n", "<leader>fm", function()
vim.lsp.buf.format { async = true }
end, { desc = "LSP formatting | lsp" })
vim.keymap.set("n", "<leader>lf", vim.diagnostic.open_float, { desc = "floating diagnostics | lsp" })
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "prev diagnostic | lsp" })
vim.keymap.set("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>lf", vim.diagnostic.open_float, { desc = "floating diagnostics | lsp" })
map("n", "[d", vim.diagnostic.goto_prev, { desc = "prev diagnostic | lsp" })
map("n", "]d", vim.diagnostic.goto_next, { desc = "next diagnostic | 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(
"t",
"<C-x>",
vim.api.nvim_replace_termcodes("<C-\\><C-N>", true, true, true),
{ desc = "Escape terminal mode | general" }
"v",
"<leader>/",
"<ESC>:lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>",
{ desc = "Toggle comment | comment" }
)
-- Mappings for M.tabufline
if vim.g.tabufline_maps then
map("n", "<tab>", function()
require("nvchad.tabufline").tabuflineNext()
end, { desc = "Goto next buffer | tabufline" })
map("n", "<C-n>", "<cmd>NvimTreeToggle<CR>", { desc = "Toggle nvimtree | nvimtree" })
map("n", "<leader>e", "<cmd>NvimTreeFocus<CR>", { desc = "Focus nvimtree | nvimtree" })
map("n", "<S-tab>", function()
require("nvchad.tabufline").tabuflinePrev()
end, { desc = "Goto prev buffer | tabufline" })
map("n", "<leader>fw", "<cmd>Telescope live_grep<CR>", { desc = "Live grep | telescope" })
map("n", "<leader>fb", "<cmd>Telescope buffers<CR>", { desc = "Find buffers | telescope" })
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()
require("nvchad.tabufline").close_buffer()
end, { desc = "Close buffer | tabufline" })
end
map(
"n",
"<leader>fa",
"<cmd>Telescope find_files follow=true no_ignore=true hidden=true<CR>",
{ desc = "Find all | telescope" }
)
if vim.g.comment_maps then
map("n", "<leader>/", function()
require("Comment.api").toggle.linewise.current()
end, { desc = "Toggle comment | comment" })
-- terminal
map("t", "<C-x>", "<C-\\><C-N>", { desc = "Escape terminal mode | terminal" })
map("n", "<leader>h", function()
require("nvchad.term").new { pos = "sp", size = 0.3 }
end, { desc = "New horizontal term | terminal" })
map(
"v",
"<leader>/",
"<ESC><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>",
{ desc = "Toggle comment | comment" }
)
end
map("n", "<leader>v", function()
require("nvchad.term").new { pos = "vsp", size = 0.3 }
end, { desc = "New vertical term | terminal" })
if vim.g.nvimtree_maps then
map("n", "<C-n>", "<cmd>NvimTreeToggle<CR>", { desc = "Toggle nvimtree | nvimtree" })
map("n", "<leader>e", "<cmd>NvimTreeFocus<CR>", { desc = "Focus nvimtree | nvimtree" })
end
map({ "n", "t" }, "<A-v>", function()
require("nvchad.term").toggle { pos = "vsp", id = "vtoggleTerm", size = 0.3 }
end, { desc = "Toggleable vertical term | terminal" })
if vim.g.telescope_maps then
map("n", "<leader>fw", "<cmd>Telescope live_grep<CR>", { desc = "Live grep | telescope" })
map("n", "<leader>fb", "<cmd>Telescope buffers<CR>", { desc = "Find buffers | telescope" })
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", "t" }, "<A-h>", function()
require("nvchad.term").toggle { pos = "sp", id = "htoggleTerm", size = 0.2 }
end, { desc = "New horizontal term | terminal" })
map(
"n",
"<leader>fz",
"<cmd>Telescope current_buffer_fuzzy_find<CR>",
{ desc = "Find in current buffer | telescope" }
)
map({ "n", "t" }, "<A-i>", function()
require("nvchad.term").toggle { pos = "float", id = "floatTerm" }
end, { desc = "Toggleable Floating term | terminal" })
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("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" })
map("n", "<leader>ff", "<cmd>Telescope find_files<CR>", { desc = "Find files | telescope" })
map(
"n",
"<leader>fa",
"<cmd>Telescope find_files follow=true no_ignore=true hidden=true<CR>",
{ desc = "Find all | telescope" }
)
end
-- whichkey
map("n", "<leader>wK", "<cmd>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" })
-- Mappings for M.terminal
if vim.g.terminal_maps then
map("n", "<leader>h", function()
require("nvchad.term").new { pos = "sp", size = 0.3 }
end, { desc = "New horizontal term | terminal" })
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)
map("n", "<leader>v", function()
require("nvchad.term").new { pos = "vsp", size = 0.3 }
end, { desc = "New vertical term | terminal" })
map({ "n", "t" }, "<A-v>", function()
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
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, { desc = "Jump to current context | blankline" })
end
end
end, { desc = "Jump to current context | blankline" })
pcall(require, "custom.mappings")

View file

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

View file

@ -31,7 +31,11 @@ M.on_attach = function(client, bufnr)
end, opts "List workspace folders | 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", "gr", vim.lsp.buf.references, opts "Show references | lsp")
end

View file

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